问题
Using PostgreSQL 10.10, from superuser postgres
:
CREATE EXTENSION postgres_fdw;
GRANT USAGE ON FOREIGN DATA WRAPPER postgres_fdw TO my_user;
Then when doing the following from my_user
:
CREATE SERVER my_server
FOREIGN DATA WRAPPER postgres_fdw
OPTIONS (...);
This error message is displayed:
Query 1 ERROR: ERROR: foreign-data wrapper "postgres_fdw" does not exist
Here is the list of currently active foreign data wrappers (from psql):
postgres=# \dew
List of foreign-data wrappers
Name | Owner | Handler | Validator
--------------+----------+----------------------+------------------------
postgres_fdw | postgres | postgres_fdw_handler | postgres_fdw_validator
(1 row)
How comes, even after having been granted USAGE
, the user my_user
is still not able to see/use postgres_fdw foreign data wrapper, as if the latter didn't exist? Are there more steps necessary?
回答1:
Since foreign data wrappers do not live in a schema, the only explanation would be that CREATE EXTENSION
and CREATE SERVER
were run in different databases (foreign data wrappers are not “global objects”). YOu have to run these statements in the same database.
By the way, the explicit CREATE FOREIGN DATA WRAPPER
would result in an error, since a foreign data wrapper of that name is already created by the extension.
来源:https://stackoverflow.com/questions/61319954/foreign-data-wrapper-postgres-fdw-does-not-exist-even-if-it-does