diff options
author | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2022-09-22 19:02:25 +0200 |
---|---|---|
committer | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2022-09-22 19:02:25 +0200 |
commit | 790bf615ddba8a0ba3b870915d03438ce9cb7860 (patch) | |
tree | c7d90ce91890f024292293bc74bac0ceaaa8d494 /src/backend | |
parent | ba50834551f936719450a287c0d7f1d0d769e9c9 (diff) | |
download | postgresql-790bf615ddba8a0ba3b870915d03438ce9cb7860.tar.gz postgresql-790bf615ddba8a0ba3b870915d03438ce9cb7860.zip |
Remove ALL keyword from TABLES IN SCHEMA for publication
This may be a bit too subtle, but removing that word from there makes
this clause no longer a perfect parallel of the GRANT variant "ALL
TABLES IN SCHEMA": indeed, for publications what we record is the schema
itself, not the tables therein, which means that any tables added to the
schema in the future are also published. This is completely different
to what GRANT does, which is affect only the tables that exist when the
command is executed.
There isn't resounding support for this change, but there are a few
positive votes and no opposition. Because the time to 15 RC1 is very
short, let's get this out now.
Backpatch to 15.
Discussion: https://postgr.es/m/2729c9e2-9aac-8cda-f2f4-34f2bcc18f4e
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/catalog/pg_publication.c | 4 | ||||
-rw-r--r-- | src/backend/commands/publicationcmds.c | 6 | ||||
-rw-r--r-- | src/backend/parser/gram.y | 18 | ||||
-rw-r--r-- | src/backend/replication/pgoutput/pgoutput.c | 3 |
4 files changed, 15 insertions, 16 deletions
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c index 6af35700051..e27db27f04a 100644 --- a/src/backend/catalog/pg_publication.c +++ b/src/backend/catalog/pg_publication.c @@ -837,7 +837,7 @@ GetAllTablesPublicationRelations(bool pubviaroot) /* * Gets the list of schema oids for a publication. * - * This should only be used FOR ALL TABLES IN SCHEMA publications. + * This should only be used FOR TABLES IN SCHEMA publications. */ List * GetPublicationSchemas(Oid pubid) @@ -957,7 +957,7 @@ GetSchemaPublicationRelations(Oid schemaid, PublicationPartOpt pub_partopt) } /* - * Gets the list of all relations published by FOR ALL TABLES IN SCHEMA + * Gets the list of all relations published by FOR TABLES IN SCHEMA * publication. */ List * diff --git a/src/backend/commands/publicationcmds.c b/src/backend/commands/publicationcmds.c index 8b574b86c47..15ab5aa99ec 100644 --- a/src/backend/commands/publicationcmds.c +++ b/src/backend/commands/publicationcmds.c @@ -847,11 +847,11 @@ CreatePublication(ParseState *pstate, CreatePublicationStmt *stmt) ObjectsInPublicationToOids(stmt->pubobjects, pstate, &relations, &schemaidlist); - /* FOR ALL TABLES IN SCHEMA requires superuser */ + /* FOR TABLES IN SCHEMA requires superuser */ if (schemaidlist != NIL && !superuser()) ereport(ERROR, errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), - errmsg("must be superuser to create FOR ALL TABLES IN SCHEMA publication")); + errmsg("must be superuser to create FOR TABLES IN SCHEMA publication")); if (relations != NIL) { @@ -1979,7 +1979,7 @@ AlterPublicationOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId) (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), errmsg("permission denied to change owner of publication \"%s\"", NameStr(form->pubname)), - errhint("The owner of a FOR ALL TABLES IN SCHEMA publication must be a superuser."))); + errhint("The owner of a FOR TABLES IN SCHEMA publication must be a superuser."))); } form->pubowner = newOwnerId; diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index d76c0af3940..0d8d2928509 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -10340,7 +10340,7 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec * pub_obj is one of: * * TABLE table [, ...] - * ALL TABLES IN SCHEMA schema [, ...] + * TABLES IN SCHEMA schema [, ...] * *****************************************************************************/ @@ -10375,7 +10375,7 @@ CreatePublicationStmt: ; /* - * FOR TABLE and FOR ALL TABLES IN SCHEMA specifications + * FOR TABLE and FOR TABLES IN SCHEMA specifications * * This rule parses publication objects with and without keyword prefixes. * @@ -10397,18 +10397,18 @@ PublicationObjSpec: $$->pubtable->columns = $3; $$->pubtable->whereClause = $4; } - | ALL TABLES IN_P SCHEMA ColId + | TABLES IN_P SCHEMA ColId { $$ = makeNode(PublicationObjSpec); $$->pubobjtype = PUBLICATIONOBJ_TABLES_IN_SCHEMA; - $$->name = $5; - $$->location = @5; + $$->name = $4; + $$->location = @4; } - | ALL TABLES IN_P SCHEMA CURRENT_SCHEMA + | TABLES IN_P SCHEMA CURRENT_SCHEMA { $$ = makeNode(PublicationObjSpec); $$->pubobjtype = PUBLICATIONOBJ_TABLES_IN_CUR_SCHEMA; - $$->location = @5; + $$->location = @4; } | ColId opt_column_list OptWhereClause { @@ -10484,7 +10484,7 @@ pub_obj_list: PublicationObjSpec * pub_obj is one of: * * TABLE table_name [, ...] - * ALL TABLES IN SCHEMA schema_name [, ...] + * TABLES IN SCHEMA schema_name [, ...] * *****************************************************************************/ @@ -18424,7 +18424,7 @@ preprocess_pubobj_list(List *pubobjspec_list, core_yyscan_t yyscanner) ereport(ERROR, errcode(ERRCODE_SYNTAX_ERROR), errmsg("invalid publication object list"), - errdetail("One of TABLE or ALL TABLES IN SCHEMA must be specified before a standalone table or schema name."), + errdetail("One of TABLE or TABLES IN SCHEMA must be specified before a standalone table or schema name."), parser_errposition(pubobj->location)); foreach(cell, pubobjspec_list) diff --git a/src/backend/replication/pgoutput/pgoutput.c b/src/backend/replication/pgoutput/pgoutput.c index 880580ed00a..92bbffbe7cd 100644 --- a/src/backend/replication/pgoutput/pgoutput.c +++ b/src/backend/replication/pgoutput/pgoutput.c @@ -1014,8 +1014,7 @@ pgoutput_column_list_init(PGOutputData *data, List *publications, * need to check all the given publication-table mappings and report an * error if any publications have a different column list. * - * FOR ALL TABLES and FOR ALL TABLES IN SCHEMA implies "don't use column - * list". + * FOR ALL TABLES and FOR TABLES IN SCHEMA imply "don't use column list". */ foreach(lc, publications) { |