diff --git a/doc/src/sgml/ref/grant.sgml b/doc/src/sgml/ref/grant.sgml index 72ecc45..1114d98 100644 *** a/doc/src/sgml/ref/grant.sgml --- b/doc/src/sgml/ref/grant.sgml *************** GRANT rol *** 81,87 **** The GRANT command has two basic variants: one that grants privileges on a database object (table, column, view, sequence, ! database, foreign-data wrapper, foreign server, function, procedural language, schema, or tablespace), and one that grants membership in a role. These variants are similar in many ways, but they are different enough to be described separately. --- 81,87 ---- The GRANT command has two basic variants: one that grants privileges on a database object (table, column, view, sequence, ! foreign table, database, foreign-data wrapper, foreign server, function, procedural language, schema, or tablespace), and one that grants membership in a role. These variants are similar in many ways, but they are different enough to be described separately. *************** GRANT rol *** 101,107 **** There is also an option to grant privileges on all objects of the same type within one or more schemas. This functionality is currently supported only for tables, sequences, and functions (but note that ALL ! TABLES is considered to include views). --- 101,107 ---- There is also an option to grant privileges on all objects of the same type within one or more schemas. This functionality is currently supported only for tables, sequences, and functions (but note that ALL ! TABLES is considered to include views and foreign tables). *************** GRANT rol *** 166,172 **** Allows from any column, or the specific columns listed, of the specified table, ! view, or sequence. Also allows the use of TO. This privilege is also needed to reference existing column values in --- 166,172 ---- Allows from any column, or the specific columns listed, of the specified table, ! view, sequence, or foreign table. Also allows the use of TO. This privilege is also needed to reference existing column values in diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c index 48fa6d4..3532cfa 100644 *** a/src/backend/catalog/aclchk.c --- b/src/backend/catalog/aclchk.c *************** ExecGrant_Relation(InternalGrant *istmt) *** 1702,1715 **** errmsg("\"%s\" is not a sequence", NameStr(pg_class_tuple->relname)))); - /* Used GRANT FOREIGN TABLE on a non-foreign-table? */ - if (istmt->objtype == ACL_OBJECT_FOREIGN_TABLE && - pg_class_tuple->relkind != RELKIND_FOREIGN_TABLE) - ereport(ERROR, - (errcode(ERRCODE_WRONG_OBJECT_TYPE), - errmsg("\"%s\" is not a foreign table", - NameStr(pg_class_tuple->relname)))); - /* Adjust the default permissions based on object type */ if (istmt->all_privs && istmt->privileges == ACL_NO_RIGHTS) { --- 1702,1707 ---- diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index 27fdcca..720903b 100644 *** a/src/backend/parser/gram.y --- b/src/backend/parser/gram.y *************** privilege_target: *** 5388,5401 **** n->objs = $3; $$ = n; } - | FOREIGN TABLE qualified_name_list - { - PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget)); - n->targtype = ACL_TARGET_OBJECT; - n->objtype = ACL_OBJECT_FOREIGN_TABLE; - n->objs = $3; - $$ = n; - } | FUNCTION function_with_argtypes_list { PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget)); --- 5388,5393 ---- diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index e72c5b9..5412020 100644 *** a/src/bin/psql/tab-complete.c --- b/src/bin/psql/tab-complete.c *************** psql_completion(char *text, int start, i *** 2216,2222 **** " UNION SELECT 'DATABASE'" " UNION SELECT 'FOREIGN DATA WRAPPER'" " UNION SELECT 'FOREIGN SERVER'" - " UNION SELECT 'FOREIGN TABLE'" " UNION SELECT 'FUNCTION'" " UNION SELECT 'LANGUAGE'" " UNION SELECT 'LARGE OBJECT'" --- 2216,2221 ---- *************** psql_completion(char *text, int start, i *** 2228,2234 **** pg_strcasecmp(prev_wd, "FOREIGN") == 0) { static const char *const list_privilege_foreign[] = ! {"DATA WRAPPER", "SERVER", "TABLE", NULL}; COMPLETE_WITH_LIST(list_privilege_foreign); } --- 2227,2233 ---- pg_strcasecmp(prev_wd, "FOREIGN") == 0) { static const char *const list_privilege_foreign[] = ! {"DATA WRAPPER", "SERVER", NULL}; COMPLETE_WITH_LIST(list_privilege_foreign); } diff --git a/src/test/regress/expected/foreign_data.out b/src/test/regress/expected/foreign_data.out index a747334..2875773 100644 *** a/src/test/regress/expected/foreign_data.out --- b/src/test/regress/expected/foreign_data.out *************** ERROR: foreign-data wrapper "dummy" has *** 674,679 **** --- 674,689 ---- EXPLAIN SELECT * FROM ft1; -- ERROR ERROR: foreign-data wrapper "dummy" has no handler -- ALTER FOREIGN TABLE + GRANT SELECT(c1) ON TABLE ft1 TO regress_test_role; + GRANT ALL ON TABLE ft1 TO regress_test_role; + \dp ft1 + Access privileges + Schema | Name | Type | Access privileges | Column access privileges + --------+------+---------------+---------------------------------------+----------------------------------------- + public | ft1 | foreign table | foreign_data_user=r/foreign_data_user+| c1: + + | | | regress_test_role=r/foreign_data_user | regress_test_role=r/foreign_data_user + (1 row) + COMMENT ON FOREIGN TABLE ft1 IS 'foreign table'; COMMENT ON FOREIGN TABLE ft1 IS NULL; COMMENT ON COLUMN ft1.c1 IS 'foreign column'; diff --git a/src/test/regress/sql/foreign_data.sql b/src/test/regress/sql/foreign_data.sql index 3f39785..04b3ad5 100644 *** a/src/test/regress/sql/foreign_data.sql --- b/src/test/regress/sql/foreign_data.sql *************** SELECT * FROM ft1; *** 275,280 **** --- 275,283 ---- EXPLAIN SELECT * FROM ft1; -- ERROR -- ALTER FOREIGN TABLE + GRANT SELECT(c1) ON TABLE ft1 TO regress_test_role; + GRANT ALL ON TABLE ft1 TO regress_test_role; + \dp ft1 COMMENT ON FOREIGN TABLE ft1 IS 'foreign table'; COMMENT ON FOREIGN TABLE ft1 IS NULL; COMMENT ON COLUMN ft1.c1 IS 'foreign column';