The source data is in a keys table in the public schema of database keys (reference pg docs: https://www.postgresql.org/docs/current/postgres-fdw.html) :
create table keys (
id varchar not null,
keyname varchar not null,
created timestamp default current_timestamp not null,
modified timestamp default current_timestamp not null
);
The referencing user/schema/database is vids/public/vids .
CREATE SERVER keys
FOREIGN DATA WRAPPER postgres_fdw
OPTIONS (host '1.2.3.4', port '5432', dbname 'keys');
CREATE USER MAPPING FOR vids
SERVER keys
OPTIONS (user 'keys', password 'keys');
create foreign table keys (
id varchar not null,
keyname varchar not null,
created timestamp default current_timestamp not null,
modified timestamp default current_timestamp not null
) server keys options (schema_name 'public', table_name 'keys');
vids=> select * from keys;
ERROR: permission denied for foreign table keys
I do not understand given that the user keys is the owner of the keys table in the foreign database. What should be done here?
From a comment by @jjanes:
the error message suggest the problem is on the local side". The local repfresentation of the foreign table is nowned by
vids
andvids
does not have permissions to it. So it never gets far enough to figure out ifkeys
has access tokeys
on the foreign side
So the correction to my steps was:
grant all on table keys to clips;