Foreign-data wrapper “postgres_fdw” does not exist (even if it does)

让人想犯罪 __ 提交于 2020-04-30 06:31:19

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!