On Fri, 27 Nov 2026 at 11:49, Amit Kapila <[email protected]> wrote: > > Few comments: > ============= > * > --- > 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. > --- > > Why are they dumped even when named explicitly? Do we dump any other > such internally generated table when named explicitly? We probably > need to disallow specifying it explicitly.
Agreed, and no, we don't. Other internally generated tables like toast table can be named either, it fails with "no matching tables were found". Modified dump so that -t query now skips the pg_conflict schema, so naming a conflict log table gives "no matching tables were found" similarly. -n pg_conflict is excluded the same way and gives "no matching schemas were found". > --- > 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. > --- > > I feel the second sentence (So it ..) seems unnecessary. Removed it. > * > + /* > + * 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); > > Shouldn’t this be handled via pg-dump? IIUC, it is done to handle a > case when a user manually runs pg_dump --binary-upgrade > --use-set-session-authorization. We already document that > “-binary-upgrade” is for use by in-place upgrade utilities. Its use > for other purposes is not recommended or supported. So, I feel the > above handling is not required. Agreed. That code was only needed when someone runs pg_dump --binary-upgrade --use-set-session-authorization manually. Since --binary-upgrade is documented as for upgrade utilities only, I've removed this. The attached v2 version patch has the changes for the same. This patch also addresses Kuroda-san's comments from [1]. [1] - https://www.postgresql.org/message-id/OS7PR01MB18317EF3C14DFE439ADFCAE95F5412%40OS7PR01MB18317.jpnprd01.prod.outlook.com Regards, Vignesh
v2-0001-Preserve-subscription-OIDs-across-pg_upgrade.patch
Description: Binary data
v2-0002-Preserve-conflict-log-tables-and-conflict_log_des.patch
Description: Binary data
