From b7fd4019eecd50eb1e07a5a26b2c5878cc37c945 Mon Sep 17 00:00:00 2001 From: Vignesh C Date: Fri, 27 Nov 2026 07:07:18 +0530 Subject: [PATCH 2/2] Preserve conflict log tables and conflict_log_destination across pg_upgrade. A subscription's conflict log table name is derived from its OID, and the table is linked through pg_subscription.subconflictlogrelid. Neither was preserved across pg_upgrade. In binary-upgrade mode, pg_dump now dumps conflict log tables with their original OIDs, together with their privileges, comments and security labels. It also preserves conflict_log_destination, omitting the default value ('log'). A conflict log table is dumped only along with its subscription. So it is not dumped with --no-subscriptions, with -n, -t or -e, by a non-superuser, or when the post-data section is not dumped, unless the table is named explicitly with -t or -n. The pg_conflict schema's own ACLs are dumped as for pg_catalog. During restore, CreateSubscription() links the subscription to the already restored conflict log table, raising an error if the table is missing rather than creating a new one. Outside binary-upgrade mode, conflict log tables are recreated when the subscription is restored, and nothing about them is dumped, unless they are named explicitly. --- doc/src/sgml/logical-replication.sgml | 6 +- doc/src/sgml/ref/pg_dump.sgml | 17 +++ src/backend/commands/subscriptioncmds.c | 47 +++++++- src/backend/replication/logical/conflict.c | 2 +- src/bin/pg_dump/pg_dump.c | 128 +++++++++++++++++++-- src/bin/pg_dump/pg_dump.h | 1 + src/bin/pg_dump/t/002_pg_dump.pl | 35 +++++- src/bin/pg_upgrade/pg_upgrade.c | 4 +- src/bin/pg_upgrade/t/004_subscription.pl | 57 ++++++++- src/include/catalog/pg_subscription.h | 3 + 10 files changed, 279 insertions(+), 21 deletions(-) diff --git a/doc/src/sgml/logical-replication.sgml b/doc/src/sgml/logical-replication.sgml index 728348f3a72..5e665fad57c 100644 --- a/doc/src/sgml/logical-replication.sgml +++ b/doc/src/sgml/logical-replication.sgml @@ -3159,7 +3159,11 @@ CONTEXT: processing remote data for replication origin "pg_16395" during "INSER pg_upgrade also preserves the OID of every - subscription. + subscription. If + conflict_log_destination + is set to table or all, the subscription's + conflict log table + is preserved as well. diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml index 951de54e77f..4f6bbf44c65 100644 --- a/doc/src/sgml/ref/pg_dump.sgml +++ b/doc/src/sgml/ref/pg_dump.sgml @@ -1736,6 +1736,23 @@ CREATE DATABASE foo WITH TEMPLATE template0; had been originally created with two_phase = true option. + + If a subscription has been created with the + conflict_log_destination + option set to table or all, + pg_dump does not dump that conflict log table + or its contents, unless the table is named explicitly with + or . Restoring the subscription + creates a new, empty conflict log table, whose name is derived from the OID + of the new subscription. + Privileges, comments and security labels that had been set on the old + conflict log table are not restored, and must be set again on the new + table if needed. In binary-upgrade mode, which + pg_upgrade uses, the subscription OID and its + conflict log table are preserved instead, with its contents, privileges, + comments and security labels. + + It is generally recommended to use the () option when restoring a database from a diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c index e0ad5baefb2..c5b791776d4 100644 --- a/src/backend/commands/subscriptioncmds.c +++ b/src/backend/commands/subscriptioncmds.c @@ -27,6 +27,7 @@ #include "catalog/objectaccess.h" #include "catalog/objectaddress.h" #include "catalog/pg_authid_d.h" +#include "catalog/pg_class.h" #include "catalog/pg_database_d.h" #include "catalog/pg_foreign_server.h" #include "catalog/pg_namespace.h" @@ -923,12 +924,50 @@ CreateSubscription(ParseState *pstate, CreateSubscriptionStmt *stmt, CStringGetTextDatum(ConflictLogDestNames[opts.conflictlogdest]); /* - * We create the conflict log table here, if required, so that its - * relation OID can be stored when inserting the pg_subscription tuple - * below. + * Create the conflict log table here, if required, so that its relation + * OID can be stored when inserting the pg_subscription tuple below. In + * binary-upgrade mode, the table was already restored earlier in the dump + * with its original OID and filenode, so look it up and reuse it. */ if (CONFLICTS_LOGGED_TO_TABLE(opts.conflictlogdest)) - logrelid = create_conflict_log_table(subid, stmt->subname, owner); + { + if (IsBinaryUpgrade) + { + char relname[NAMEDATALEN]; + HeapTuple reltup; + Oid relowner; + + snprintf(relname, NAMEDATALEN, CONFLICT_LOG_RELATION_NAME_FMT, + subid); + logrelid = get_relname_relid(relname, PG_CONFLICT_NAMESPACE); + if (!OidIsValid(logrelid)) + ereport(ERROR, + (errcode(ERRCODE_UNDEFINED_TABLE), + errmsg("could not find conflict log table \"%s\" when in binary upgrade mode", + get_qualified_objname(PG_CONFLICT_NAMESPACE, + relname)))); + + /* + * The table was restored by the user running the restore, but it + * must belong to the owner of the subscription. Usually the + * subscription is created by the same user, and the owner of both + * is then set later by ALTER SUBSCRIPTION ... OWNER TO. But when + * the dump uses SET SESSION AUTHORIZATION to set owners, the + * subscription is created by its owner and no ALTER SUBSCRIPTION + * follows, so set the owner of the table here. + */ + reltup = SearchSysCache1(RELOID, ObjectIdGetDatum(logrelid)); + if (!HeapTupleIsValid(reltup)) + elog(ERROR, "cache lookup failed for relation %u", logrelid); + relowner = ((Form_pg_class) GETSTRUCT(reltup))->relowner; + ReleaseSysCache(reltup); + + if (relowner != owner) + ATExecChangeOwner(logrelid, owner, true, AccessExclusiveLock); + } + else + logrelid = create_conflict_log_table(subid, stmt->subname, owner); + } /* Store table OID in the catalog. */ values[Anum_pg_subscription_subconflictlogrelid - 1] = diff --git a/src/backend/replication/logical/conflict.c b/src/backend/replication/logical/conflict.c index 73c4077d05a..819f32cf7c0 100644 --- a/src/backend/replication/logical/conflict.c +++ b/src/backend/replication/logical/conflict.c @@ -207,7 +207,7 @@ create_conflict_log_table(Oid subid, char *subname, Oid subowner) Oid relid; char relname[NAMEDATALEN]; - snprintf(relname, NAMEDATALEN, "pg_conflict_log_%u", subid); + snprintf(relname, NAMEDATALEN, CONFLICT_LOG_RELATION_NAME_FMT, subid); /* Build the tuple descriptor for the new table. */ tupdesc = create_conflict_log_table_tupdesc(); diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 24517805b00..b9859d68f4c 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -380,6 +380,8 @@ static void dumpPublication(Archive *fout, const PublicationInfo *pubinfo); static void dumpPublicationTable(Archive *fout, const PublicationRelInfo *pubrinfo); static void dumpSubscription(Archive *fout, const SubscriptionInfo *subinfo); static void dumpSubscriptionTable(Archive *fout, const SubRelInfo *subrinfo); +static bool is_superuser(Archive *fout); +static bool subscriptions_are_dumped(Archive *fout); static void dumpDatabase(Archive *fout); static void dumpDatabaseConfig(Archive *AH, PQExpBuffer outbuf, const char *dbname, Oid dboid); @@ -1999,6 +2001,41 @@ selectDumpableNamespace(NamespaceInfo *nsinfo, Archive *fout) */ nsinfo->dobj.dump_contains = nsinfo->dobj.dump = DUMP_COMPONENT_ACL; } + else if (strcmp(nsinfo->dobj.name, "pg_conflict") == 0) + { + /* + * The pg_conflict schema is created by initdb and holds the + * subscriptions' conflict log tables. Dump the ACLs of the schema, + * as for pg_catalog. + */ + nsinfo->dobj.dump = DUMP_COMPONENT_ACL; + + /* + * Unless named explicitly with -t or -n, which override this + * selection, conflict log tables are dumped only in binary-upgrade + * mode, and only when their subscriptions are dumped, since the + * subscription is what uses the table. In binary-upgrade mode, the + * tables are restored so that CREATE SUBSCRIPTION can reuse them. In + * other modes, CREATE SUBSCRIPTION creates them again, so nothing + * about them is dumped, not even their ACLs, as that would refer to a + * table that no longer exists. + * + * Also dump the privileges, comments, and security labels of the + * tables. For example, privileges may allow non-superusers to delete + * conflicts. + * + * This selection leaves out the data of the tables. pg_upgrade + * carries the rows over with the table files, and the server rejects + * inserting rows into a conflict log table, so a dump of the rows + * could not be restored. + */ + if (fout->dopt->binary_upgrade && subscriptions_are_dumped(fout)) + nsinfo->dobj.dump_contains = DUMP_COMPONENT_DEFINITION | + DUMP_COMPONENT_ACL | DUMP_COMPONENT_COMMENT | + DUMP_COMPONENT_SECLABEL; + else + nsinfo->dobj.dump_contains = DUMP_COMPONENT_NONE; + } else if (strncmp(nsinfo->dobj.name, "pg_", 3) == 0 || strcmp(nsinfo->dobj.name, "information_schema") == 0) { @@ -2049,6 +2086,50 @@ selectDumpableNamespace(NamespaceInfo *nsinfo, Archive *fout) (void) checkExtensionMembership(&nsinfo->dobj, fout); } +/* + * is_conflict_log_table: is this a subscription's conflict log table? + * + * Conflict log tables are the tables of the pg_conflict schema. + */ +static bool +is_conflict_log_table(const TableInfo *tbinfo) +{ + return strcmp(tbinfo->dobj.namespace->dobj.name, "pg_conflict") == 0; +} + +/* + * table_entry_owner: the owner to record in the archive entries of a table + * + * A conflict log table has none. Changing its owner is not allowed, so no + * "ALTER TABLE ... OWNER TO ..." is emitted for it. With + * --use-set-session-authorization, their archive entries must + * not be restored as the subscription owner, who does not own the table + * at that point. The table is initially created by the restore user, and + * CREATE SUBSCRIPTION assigns ownership to the subscription owner. + */ +static const char * +table_entry_owner(const TableInfo *tbinfo) +{ + return is_conflict_log_table(tbinfo) ? NULL : tbinfo->rolname; +} + +/* + * subscriptions_are_dumped: Are subscriptions included in the dump? + * + * This reflects the conditions used by getSubscriptions() and + * selectDumpableObject() to determine whether a subscription is + * dumpable. Subscriptions are dumped in the post-data section. + */ +static bool +subscriptions_are_dumped(Archive *fout) +{ + DumpOptions *dopt = fout->dopt; + + return dopt->include_everything && !dopt->no_subscriptions && + is_superuser(fout) && + (dopt->dumpSections & DUMP_POST_DATA); +} + /* * selectDumpableTable: policy-setting subroutine * Mark a table as to be dumped or not @@ -5142,6 +5223,7 @@ getSubscriptions(Archive *fout) int i_subfailover; int i_subretaindeadtuples; int i_submaxretention; + int i_subconflictlogdest; int i, ntups; @@ -5240,9 +5322,16 @@ getSubscriptions(Archive *fout) " '-1' AS subwalrcvtimeout,\n"); if (fout->remoteVersion >= 190000) - appendPQExpBufferStr(query, " fs.srvname AS subservername\n"); + appendPQExpBufferStr(query, " fs.srvname AS subservername,\n"); else - appendPQExpBufferStr(query, " NULL AS subservername\n"); + appendPQExpBufferStr(query, " NULL AS subservername,\n"); + + if (fout->remoteVersion >= 200000) + appendPQExpBufferStr(query, + " s.subconflictlogdest\n"); + else + appendPQExpBufferStr(query, + " NULL AS subconflictlogdest\n"); appendPQExpBufferStr(query, "FROM pg_subscription s\n"); @@ -5291,6 +5380,7 @@ getSubscriptions(Archive *fout) i_subpublications = PQfnumber(res, "subpublications"); i_suborigin = PQfnumber(res, "suborigin"); i_suboriginremotelsn = PQfnumber(res, "suboriginremotelsn"); + i_subconflictlogdest = PQfnumber(res, "subconflictlogdest"); subinfo = pg_malloc_array(SubscriptionInfo, ntups); @@ -5349,6 +5439,12 @@ getSubscriptions(Archive *fout) subinfo[i].suboriginremotelsn = pg_strdup(PQgetvalue(res, i, i_suboriginremotelsn)); + if (PQgetisnull(res, i, i_subconflictlogdest)) + subinfo[i].subconflictlogdest = NULL; + else + subinfo[i].subconflictlogdest = + pg_strdup(PQgetvalue(res, i, i_subconflictlogdest)); + /* Decide whether we want to dump it */ selectDumpableObject(&(subinfo[i].dobj), fout); } @@ -5620,6 +5716,11 @@ dumpSubscription(Archive *fout, const SubscriptionInfo *subinfo) if (pg_strcasecmp(subinfo->suborigin, LOGICALREP_ORIGIN_ANY) != 0) appendPQExpBuffer(query, ", origin = %s", subinfo->suborigin); + if (subinfo->subconflictlogdest && + pg_strcasecmp(subinfo->subconflictlogdest, "log") != 0) + appendPQExpBuffer(query, ", conflict_log_destination = %s", + subinfo->subconflictlogdest); + appendPQExpBufferStr(query, ");\n"); /* @@ -11484,7 +11585,7 @@ dumpTableComment(Archive *fout, const TableInfo *tbinfo, ArchiveEntry(fout, nilCatalogId, createDumpId(), ARCHIVE_OPTS(.tag = tag->data, .namespace = tbinfo->dobj.namespace->dobj.name, - .owner = tbinfo->rolname, + .owner = table_entry_owner(tbinfo), .description = "COMMENT", .section = SECTION_NONE, .createStmt = query->data, @@ -11509,7 +11610,7 @@ dumpTableComment(Archive *fout, const TableInfo *tbinfo, ArchiveEntry(fout, nilCatalogId, createDumpId(), ARCHIVE_OPTS(.tag = tag->data, .namespace = tbinfo->dobj.namespace->dobj.name, - .owner = tbinfo->rolname, + .owner = table_entry_owner(tbinfo), .description = "COMMENT", .section = SECTION_NONE, .createStmt = query->data, @@ -16739,7 +16840,7 @@ dumpTableSecLabel(Archive *fout, const TableInfo *tbinfo, const char *reltypenam ArchiveEntry(fout, nilCatalogId, createDumpId(), ARCHIVE_OPTS(.tag = target->data, .namespace = tbinfo->dobj.namespace->dobj.name, - .owner = tbinfo->rolname, + .owner = table_entry_owner(tbinfo), .description = "SECURITY LABEL", .section = SECTION_NONE, .createStmt = query->data, @@ -17290,6 +17391,11 @@ dumpTableSchema(Archive *fout, const TableInfo *tbinfo) appendPQExpBuffer(delq, "DROP %s %s;\n", reltypename, qualrelname); + /* + * This also keeps the OIDs and filenodes of a conflict log table, so + * that pg_upgrade finds its files and pg_subscription's + * subconflictlogrelid stays the same. + */ if (dopt->binary_upgrade) binary_upgrade_set_pg_class_oids(fout, q, tbinfo->dobj.catId.oid); @@ -18061,7 +18167,7 @@ dumpTableSchema(Archive *fout, const TableInfo *tbinfo) .tablespace = tablespace, .tableam = tableam, .relkind = tbinfo->relkind, - .owner = tbinfo->rolname, + .owner = table_entry_owner(tbinfo), .description = reltypename, .section = tbinfo->postponed_def ? SECTION_POST_DATA : SECTION_PRE_DATA, @@ -20409,12 +20515,16 @@ getDependencies(Archive *fout) * Ordinarily, table rowtypes have implicit dependencies on their * tables. However, for a composite type the implicit dependency goes * the other way in pg_depend; which is the right thing for DROP but - * it doesn't produce the dependency ordering we need. So in that one - * case, we reverse the direction of the dependency. + * it doesn't produce the dependency ordering we need. The same is + * true for a subscription's conflict log table, which has an internal + * dependency on its subscription for DROP, but must be dumped before + * the subscription in binary-upgrade mode. So in those cases, we + * reverse the direction of the dependency. */ if (deptype == 'i' && dobj->objType == DO_TABLE && - refdobj->objType == DO_TYPE) + (refdobj->objType == DO_TYPE || + refdobj->objType == DO_SUBSCRIPTION)) addObjectDependency(refdobj, dobj->dumpId); else /* normal case */ diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h index 41d932f003b..aa6e3e96a54 100644 --- a/src/bin/pg_dump/pg_dump.h +++ b/src/bin/pg_dump/pg_dump.h @@ -730,6 +730,7 @@ typedef struct _SubscriptionInfo char *subpublications; char *suborigin; char *suboriginremotelsn; + char *subconflictlogdest; } SubscriptionInfo; /* diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl index ec73c4d5be9..6fa6b13d522 100644 --- a/src/bin/pg_dump/t/002_pg_dump.pl +++ b/src/bin/pg_dump/t/002_pg_dump.pl @@ -3424,9 +3424,9 @@ my %tests = ( create_order => 50, create_sql => 'CREATE SUBSCRIPTION sub3 CONNECTION \'dbname=doesnotexist\' PUBLICATION pub1 - WITH (connect = false, origin = any, streaming = on);', + WITH (connect = false, origin = any, streaming = on, conflict_log_destination = table);', regexp => qr/^ - \QCREATE SUBSCRIPTION sub3 CONNECTION 'dbname=doesnotexist' PUBLICATION pub1 WITH (connect = false, slot_name = 'sub3', streaming = on);\E + \QCREATE SUBSCRIPTION sub3 CONNECTION 'dbname=doesnotexist' PUBLICATION pub1 WITH (connect = false, slot_name = 'sub3', streaming = on, conflict_log_destination = table);\E /xm, like => { %full_runs, section_post_data => 1, }, unlike => { @@ -3435,6 +3435,37 @@ my %tests = ( }, }, + # In binary-upgrade mode, the subscription OID is preserved and the + # conflict log table is dumped, to be reused by the CREATE SUBSCRIPTION + # above. The conflict log table is dumped before its subscription, and its + # name is derived from the subscription OID, so require that the table is + # the one named after the OID set for sub3, not the one of another + # subscription. + 'binary upgrade: pg_subscription OID and conflict log table of sub3' => { + regexp => qr/^ + \QCREATE TABLE pg_conflict.pg_conflict_log_\E(\d+)\Q (\E + .*? + ^\Q-- For binary upgrade, must preserve pg_subscription.oid\E\n + \QSELECT pg_catalog.binary_upgrade_set_next_pg_subscription_oid('\E\1\Q'::pg_catalog.oid);\E\n+ + \QCREATE SUBSCRIPTION sub3 \E + /xms, + like => { binary_upgrade => 1, }, + }, + + 'CREATE SUBSCRIPTION sub4' => { + create_order => 50, + create_sql => 'CREATE SUBSCRIPTION sub4 + CONNECTION \'dbname=doesnotexist\' PUBLICATION pub1 + WITH (connect = false, conflict_log_destination = all);', + regexp => qr/^ + \QCREATE SUBSCRIPTION sub4 CONNECTION 'dbname=doesnotexist' PUBLICATION pub1 WITH (connect = false, slot_name = 'sub4', streaming = parallel, conflict_log_destination = all);\E + /xm, + like => { %full_runs, section_post_data => 1, }, + unlike => { + no_subscriptions => 1, + no_subscriptions_restore => 1, + }, + }, # Regardless of whether the table or schema is excluded, publications must # still be dumped, as excluded objects do not apply to publications. We diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c index 0ba6965dd86..1233190ff91 100644 --- a/src/bin/pg_upgrade/pg_upgrade.c +++ b/src/bin/pg_upgrade/pg_upgrade.c @@ -37,8 +37,8 @@ * names to match between the old and new cluster. * * We control assignment of pg_subscription.oid because we want the oid to - * match between the old and new cluster, as the names of the subscription's - * replication origin and slots contain it. + * match between the old and new cluster to make use of subscription's + * conflict log table which is named using the subscription oid. */ diff --git a/src/bin/pg_upgrade/t/004_subscription.pl b/src/bin/pg_upgrade/t/004_subscription.pl index 5b148482518..fe22aa185a8 100644 --- a/src/bin/pg_upgrade/t/004_subscription.pl +++ b/src/bin/pg_upgrade/t/004_subscription.pl @@ -290,7 +290,7 @@ $publisher->safe_psql( $old_sub->safe_psql( 'postgres', qq[ CREATE TABLE tab_upgraded2(id int); - CREATE SUBSCRIPTION regress_sub5 CONNECTION '$connstr' PUBLICATION regress_pub5; + CREATE SUBSCRIPTION regress_sub5 CONNECTION '$connstr' PUBLICATION regress_pub5 with (conflict_log_destination = 'table'); ]); # The table tab_upgraded2 will be in the init state as the subscriber's @@ -314,7 +314,33 @@ my $tab_upgraded2_oid = $old_sub->safe_psql('postgres', "SELECT oid FROM pg_class WHERE relname = 'tab_upgraded2'"); my $sub5_oid = $old_sub->safe_psql('postgres', "SELECT oid FROM pg_subscription where subname = 'regress_sub5'"); +my $sub_clt_relid = $old_sub->safe_psql('postgres', + "SELECT subconflictlogrelid FROM pg_subscription WHERE subname = 'regress_sub5'" +); +# A privilege granted on the conflict log table must survive the upgrade. +my $sub_clt_name = $old_sub->safe_psql('postgres', + "SELECT relname FROM pg_class WHERE oid = $sub_clt_relid"); +$old_sub->safe_psql( + 'postgres', qq[ + CREATE ROLE regress_clt_reader; + GRANT DELETE ON pg_conflict.$sub_clt_name TO regress_clt_reader; +]); + +# A comment on the table and on a column must survive the upgrade too. +my $sub_clt_col = $old_sub->safe_psql('postgres', + "SELECT attname FROM pg_attribute WHERE attrelid = $sub_clt_relid AND attnum = 1" +); +$old_sub->safe_psql( + 'postgres', qq[ + COMMENT ON TABLE pg_conflict.$sub_clt_name IS 'clt table comment'; + COMMENT ON COLUMN pg_conflict.$sub_clt_name.$sub_clt_col IS 'clt column comment'; +]); + +# A privilege revoked on the pg_conflict schema must stay revoked after the +# upgrade. +$old_sub->safe_psql('postgres', + 'REVOKE USAGE ON SCHEMA pg_conflict FROM PUBLIC'); $old_sub->stop; # Change configuration so that initial table sync does not get started @@ -396,11 +422,38 @@ $result = $new_sub->safe_psql('postgres', ); is($result, qq(t), "conflict detection slot exists"); -# The subscription oid should be preserved +# The subscription oid and the subscription conflict log table relid should be preserved $result = $new_sub->safe_psql('postgres', "SELECT oid FROM pg_subscription WHERE subname = 'regress_sub5'"); is($result, qq($sub5_oid), "subscription oid should have been preserved"); +$result = $new_sub->safe_psql('postgres', + "SELECT subconflictlogrelid FROM pg_subscription WHERE subname = 'regress_sub5'" +); +is($result, qq($sub_clt_relid), + "subscription conflict log table relid should have been preserved"); + +$result = $new_sub->safe_psql('postgres', + "SELECT has_table_privilege('regress_clt_reader', $sub_clt_relid, 'DELETE'), has_table_privilege('regress_clt_reader', $sub_clt_relid, 'INSERT')" +); +is($result, qq(t|f), + "privileges granted on the subscription conflict log table should have been preserved" +); + +$result = $new_sub->safe_psql('postgres', + "SELECT obj_description($sub_clt_relid, 'pg_class'), col_description($sub_clt_relid, 1)" +); +is( $result, + qq(clt table comment|clt column comment), + "comments on the subscription conflict log table should have been preserved" +); + +$result = $new_sub->safe_psql('postgres', + "SELECT has_schema_privilege('regress_clt_reader', 'pg_conflict', 'USAGE')" +); +is($result, qq(f), + "a privilege revoked on the pg_conflict schema should stay revoked"); + # Resume the initial sync and wait until all tables of subscription # 'regress_sub5' are synchronized $new_sub->append_conf('postgresql.conf', diff --git a/src/include/catalog/pg_subscription.h b/src/include/catalog/pg_subscription.h index b860f02d166..dd8bfd6eb5b 100644 --- a/src/include/catalog/pg_subscription.h +++ b/src/include/catalog/pg_subscription.h @@ -221,6 +221,9 @@ typedef struct Subscription #endif /* EXPOSE_TO_CLIENT_CODE */ +/* Conflict log table name format. %u is replaced with the subscription OID. */ +#define CONFLICT_LOG_RELATION_NAME_FMT "pg_conflict_log_%u" + extern Subscription *GetSubscription(Oid subid, bool missing_ok); extern char *SubscriptionConninfo(Subscription *sub); extern void DisableSubscription(Oid subid); -- 2.55.0