diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml index 9a87b5784b8..626d2001b30 100644 --- a/doc/src/sgml/ref/pg_dump.sgml +++ b/doc/src/sgml/ref/pg_dump.sgml @@ -1741,10 +1741,14 @@ CREATE DATABASE foo WITH TEMPLATE template0; conflict_log_destination option set to table or all, pg_dump does not dump its conflict log table - or its contents. Restoring the subscription creates a new, empty - conflict log table. 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. + or its contents, and neither the table nor the pg_conflict + schema can be selected with or . The + table is managed by the system together with the subscription, and its name + is derived from the subscription's OID, which is different after a restore. + Restoring the subscription creates a new, empty conflict log table + instead. 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. diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index b79cb5ec753..2f99f1e037a 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -1669,7 +1669,7 @@ expand_schema_name_patterns(Archive *fout, /* * The pg_conflict schema, which holds the conflict log tables, is not - * selectable. The tables are dumped only by pg_upgrade, along with + * selectable. The tables are dumped only by pg_upgrade, along with * the subscriptions. */ appendPQExpBufferStr(query, @@ -2013,26 +2013,17 @@ selectDumpableNamespace(NamespaceInfo *nsinfo, Archive *fout) else if (strcmp(nsinfo->dobj.name, "pg_conflict") == 0) { /* - * The pg_conflict schema is created by initdb and holds the - * subscriptions' conflict log tables. They are dumped only in - * binary-upgrade mode, which only pg_upgrade uses. There, the tables - * are restored so that CREATE SUBSCRIPTION can reuse them, so dump - * the ACLs of the schema, as for pg_catalog, and everything about the - * tables, including their privileges, comments, and security labels. - * For example, privileges may allow non-superusers to delete - * conflicts. The rows are not dumped, as pg_upgrade runs pg_dump - * with --no-data and carries them over with the table files. - * - * In other modes, CREATE SUBSCRIPTION creates the tables again, so - * nothing is dumped. + * The pg_conflict schema holds the conflict log tables of the + * subscriptions. As for pg_catalog, dump any ACLs of the schema + * itself, if they are interesting. In binary-upgrade mode, which + * only pg_upgrade uses, also dump the tables with their privileges, + * comments, and security labels so that CREATE SUBSCRIPTION can link + * to them. In other modes, CREATE SUBSCRIPTION creates the tables + * again, so dump nothing for them. */ - if (fout->dopt->binary_upgrade) - { - nsinfo->dobj.dump = DUMP_COMPONENT_ACL; - nsinfo->dobj.dump_contains = DUMP_COMPONENT_ALL; - } - else - nsinfo->dobj.dump_contains = nsinfo->dobj.dump = DUMP_COMPONENT_NONE; + nsinfo->dobj.dump = DUMP_COMPONENT_ACL; + nsinfo->dobj.dump_contains = fout->dopt->binary_upgrade ? + DUMP_COMPONENT_ALL : DUMP_COMPONENT_NONE; } else if (strncmp(nsinfo->dobj.name, "pg_", 3) == 0 || strcmp(nsinfo->dobj.name, "information_schema") == 0) @@ -2084,17 +2075,6 @@ 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; -} - /* * selectDumpableTable: policy-setting subroutine * Mark a table as to be dumped or not @@ -17217,14 +17197,6 @@ dumpTableSchema(Archive *fout, const TableInfo *tbinfo) int j, k; - /* - * Do not emit "ALTER TABLE ... OWNER TO ..." for a conflict log table: - * changing its owner is not allowed. Its owner follows the owner of the - * subscription, and is set when the ALTER SUBSCRIPTION ... OWNER TO of - * the dump is restored. - */ - bool conflict_log_table = is_conflict_log_table(tbinfo); - /* We had better have loaded per-column details about this table */ Assert(tbinfo->interesting); @@ -18116,6 +18088,16 @@ dumpTableSchema(Archive *fout, const TableInfo *tbinfo) char *tablespace = NULL; char *tableam = NULL; + /* + * Do not emit "ALTER TABLE ... OWNER TO ..." for a conflict log + * table, which is a table of the pg_conflict schema. Changing its + * owner is not allowed. Its owner follows the owner of the + * subscription, and is set when the ALTER SUBSCRIPTION ... OWNER TO + * of the dump is restored. + */ + bool conflict_log_table = + strcmp(tbinfo->dobj.namespace->dobj.name, "pg_conflict") == 0; + /* * _selectTablespace() relies on tablespace-enabled objects in the * default tablespace to have a tablespace of "" (empty string) versus