diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c index a480d7924d9..fdd193c66ab 100644 --- a/src/backend/catalog/pg_publication.c +++ b/src/backend/catalog/pg_publication.c @@ -62,7 +62,13 @@ check_publication_add_relation(PublicationRelInfo *pri) if (pri->except) { - relname = RelationGetQualifiedRelationName(targetrel); + /* + * The name parts must not be quoted here, because the message already + * encloses the whole name in double quotes. + */ + relname = psprintf("%s.%s", + get_namespace_name(RelationGetNamespace(targetrel)), + RelationGetRelationName(targetrel)); errormsg = gettext_noop("cannot specify relation \"%s\" in the publication EXCEPT clause"); } else diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c index 55d5ec94e0a..ef5202091fb 100644 --- a/src/backend/utils/cache/relcache.c +++ b/src/backend/utils/cache/relcache.c @@ -2139,16 +2139,6 @@ RelationIdGetRelation(Oid relationId) return rd; } -/* - * Returns a schema-qualified name of the relation. - */ -char * -RelationGetQualifiedRelationName(Relation rel) -{ - return get_qualified_objname(RelationGetNamespace(rel), - RelationGetRelationName(rel)); -} - /* ---------------------------------------------------------------- * cache invalidation support routines * ---------------------------------------------------------------- diff --git a/src/include/utils/relcache.h b/src/include/utils/relcache.h index 89c27aa1529..2700224939a 100644 --- a/src/include/utils/relcache.h +++ b/src/include/utils/relcache.h @@ -46,7 +46,6 @@ AssertCouldGetRelation(void) } #endif extern Relation RelationIdGetRelation(Oid relationId); -extern char *RelationGetQualifiedRelationName(Relation rel); extern void RelationClose(Relation relation); /* diff --git a/src/test/regress/expected/publication.out b/src/test/regress/expected/publication.out index 81b767cae11..1abd8d99f1c 100644 --- a/src/test/regress/expected/publication.out +++ b/src/test/regress/expected/publication.out @@ -505,6 +505,11 @@ Number of partitions: 1 (Use \d+ to list them.) CREATE PUBLICATION testpub9 FOR ALL TABLES EXCEPT (TABLE testpub_part1); ERROR: cannot specify relation "public.testpub_part1" in the publication EXCEPT clause DETAIL: This operation is not supported for individual partitions. +-- A name that needs quoting must not be quoted twice in the message. +CREATE TABLE "testpub Part2" PARTITION OF testpub_root FOR VALUES FROM (100) TO (200); +CREATE PUBLICATION testpub9 FOR ALL TABLES EXCEPT (TABLE "testpub Part2"); +ERROR: cannot specify relation "public.testpub Part2" in the publication EXCEPT clause +DETAIL: This operation is not supported for individual partitions. CREATE TABLE tab_main (a int) PARTITION BY RANGE(a); -- Attaching a partition is not allowed if the partitioned table appears in a -- publication's EXCEPT clause. @@ -513,7 +518,7 @@ ERROR: cannot attach table "testpub_root" as partition because it is referenced DETAIL: The publication EXCEPT clause cannot contain tables that are partitions. HINT: Change the publication's EXCEPT clause using ALTER PUBLICATION ... SET ALL TABLES. RESET client_min_messages; -DROP TABLE testpub_root, testpub_part1, tab_main; +DROP TABLE testpub_root, testpub_part1, "testpub Part2", tab_main; DROP PUBLICATION testpub8; --- Tests for publications with SEQUENCES CREATE SEQUENCE regress_pub_seq0; diff --git a/src/test/regress/sql/publication.sql b/src/test/regress/sql/publication.sql index 507ba2255b0..8fcf374b597 100644 --- a/src/test/regress/sql/publication.sql +++ b/src/test/regress/sql/publication.sql @@ -247,6 +247,9 @@ CREATE PUBLICATION testpub8 FOR ALL TABLES EXCEPT (TABLE testpub_root); \d testpub_part1 \d testpub_root CREATE PUBLICATION testpub9 FOR ALL TABLES EXCEPT (TABLE testpub_part1); +-- A name that needs quoting must not be quoted twice in the message. +CREATE TABLE "testpub Part2" PARTITION OF testpub_root FOR VALUES FROM (100) TO (200); +CREATE PUBLICATION testpub9 FOR ALL TABLES EXCEPT (TABLE "testpub Part2"); CREATE TABLE tab_main (a int) PARTITION BY RANGE(a); -- Attaching a partition is not allowed if the partitioned table appears in a @@ -254,7 +257,7 @@ CREATE TABLE tab_main (a int) PARTITION BY RANGE(a); ALTER TABLE tab_main ATTACH PARTITION testpub_root FOR VALUES FROM (0) TO (200); RESET client_min_messages; -DROP TABLE testpub_root, testpub_part1, tab_main; +DROP TABLE testpub_root, testpub_part1, "testpub Part2", tab_main; DROP PUBLICATION testpub8; --- Tests for publications with SEQUENCES