pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
REASSIGN OWNED vs. relisshared dep on !relisshared
15+ messages / 6 participants
[nested] [flat]

Commits from this thread:
  2026-07-18 03bcb6a777 e727c6f2ef  Fix REASSIGN OWNED for subscriptions in other databases.
* REASSIGN OWNED vs. relisshared dep on !relisshared
@ 2026-07-10 19:25  Noah Misch <noah@leadboat.com>
  0 siblings, 1 reply; 15+ messages in thread

From: Noah Misch @ 2026-07-10 19:25 UTC (permalink / raw)
  To: pgsql@j-davis.com; +Cc: akapila@postgresql.org; dilipbalaut@gmail.com; nisha.moond412@gmail.com; pgsql-hackers

v19 commit 8185bb5 added field pg_subscription.subserver, and v20 commit
a5918fd added field pg_subscription.subconflictlogrelid.  Each involves a
dependency link from the relisshared pg_subscription to a !relisshared
catalog.  REASSIGN OWNED, if run in a database other than
pg_subscription.subdbid, wrongly interprets those fields relative to the
current database.  This causes an error or opens an unrelated object.

Perhaps one could fix this by having REASSIGN OWNED process only
pg_subscription rows where subdbid is the current database.  Already, one must
run REASSIGN OWNED in each database for ordinary db-local objects like tables.
From a user's perspective, REASSIGN OWNED would reach subscriptions like it
reaches tables.

I'm nervous that we'll have other reasons to regret letting a shared object
depend on a non-shared object, but I've not come up with anything else
concrete.

Ops 4.8 wrote the attached test cases.  (The subserver test patch has tests
for some other behaviors, which I'll post about elsewhere.)

Attachments: download all (2 files, .tar.gz)

test-subscription-server-v0.patch (text/plain, 12.1K) download commit ada4f72 (subscription-server-defect-tests) Author: Noah Misch <nm@cqla.c.codeql-202606a.internal> AuthorDate: Wed Jul 8 03:26:04 2026 +0000 Commit: Noah Misch <nm@cqla.c.codeql-202606a.internal> CommitDate: Wed Jul 8 03:26:04 2026 +0000 Add TAP tests demonstrating CREATE SUBSCRIPTION ... SERVER defects These tests reproduce three user-visible defects introduced by commit 8185bb5 (CREATE SUBSCRIPTION ... SERVER) and still present in the tree. Each check asserts the current, buggy behavior and documents the expected correct behavior, so a future fix flips the relevant assertion. - pg_dump/restore of a server-based subscription fails because CreateSubscription() resolves the user mapping for the restoring role rather than the subscription owner, even with connect = false. - Restoring such a subscription leaves it owned by the restoring superuser, because ALTER SUBSCRIPTION ... OWNER TO is restored in the main pass while the owner's GRANT USAGE on the foreign server is deferred to the ACL pass. - REASSIGN OWNED BY, run from a database other than the one holding the subscription's foreign server, fails with "cache lookup failed for foreign server", breaking multi-database role removal. The scenarios use connect = false, so no publisher is required. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TePr48d48d89GukfGsNw9b --- contrib/postgres_fdw/meson.build | 1 + contrib/postgres_fdw/t/011_subscription_defects.pl | 233 +++++++++++++++++++++ 2 files changed, 234 insertions(+) diff --git a/contrib/postgres_fdw/meson.build b/contrib/postgres_fdw/meson.build index 3e2ed06..6cb204b 100644 --- a/contrib/postgres_fdw/meson.build +++ b/contrib/postgres_fdw/meson.build @@ -52,6 +52,7 @@ tests += { 'tests': [ 't/001_auth_scram.pl', 't/010_subscription.pl', + 't/011_subscription_defects.pl', ], }, } diff --git a/contrib/postgres_fdw/t/011_subscription_defects.pl b/contrib/postgres_fdw/t/011_subscription_defects.pl new file mode 100644 index 0000000..34ea757 --- /dev/null +++ b/contrib/postgres_fdw/t/011_subscription_defects.pl @@ -0,0 +1,233 @@ +# Copyright (c) 2021-2026, PostgreSQL Global Development Group + +# Demonstrations of user-visible defects in CREATE SUBSCRIPTION ... SERVER +# (commit 8185bb5) that are still present in the tree. +# +# IMPORTANT: each block below asserts the *current, buggy* behavior so the +# test passes and serves as an executable reproduction. Every block also +# states, in comments, what the correct behavior should be. When a defect +# is fixed, the corresponding assertion will start to fail and must be +# flipped to the "correct behavior" noted alongside it. +# +# All scenarios use connect => false, so no publisher is required: the +# defects are in the local CREATE/ALTER/REASSIGN and dump/restore paths, +# not in replication itself. +# +# pg_subscription is a shared catalog, so a distinct subscription-owner role +# is used per finding (and every cross-database catalog query is filtered by +# subdbid) to keep the scenarios isolated from one another. + +use strict; +use warnings FATAL => 'all'; +use PostgreSQL::Test::Cluster; +use PostgreSQL::Test::Utils; +use Test::More; + +my $node = PostgreSQL::Test::Cluster->new('node'); +$node->init; +$node->start; + +my $tempdir = PostgreSQL::Test::Utils::tempdir; + +# The cluster superuser is the OS user under TAP, not necessarily "postgres"; +# capture it so the assertions below are independent of that name. +my $super = $node->safe_psql('postgres', 'SELECT current_user'); + +# One subscription-owner role per finding, plus a REASSIGN OWNED target. +$node->safe_psql( + 'postgres', q{ + CREATE ROLE owner1 LOGIN; + CREATE ROLE owner2 LOGIN; + CREATE ROLE owner4 LOGIN; + CREATE ROLE bob LOGIN; + GRANT pg_create_subscription TO owner1, owner2, owner4; +}); + +# Common foreign-server options. postgres_fdw's connection function builds a +# libpq conninfo from these; with connect => false it is validated but never +# used to connect, so the host/port need not be reachable. +my $srv_opts = "OPTIONS (host 'localhost', port '1', dbname 'nx')"; + +############################################################################# +# Finding 1: pg_dump/pg_restore (and hence pg_upgrade) of a SERVER-based +# subscription fails, because CreateSubscription() resolves the user mapping +# for the role *executing the restore* (GetUserId()), not the subscription's +# eventual owner -- even with connect => false. +# +# The dump is emitted "CREATE SUBSCRIPTION ... SERVER ... WITH (connect = +# false ...)" followed later by "ALTER SUBSCRIPTION ... OWNER TO owner1", so +# the CREATE runs as the restoring superuser. If that superuser has no user +# mapping (and there is no PUBLIC mapping) on the server, the restore of a +# perfectly valid dump fails. +# +# CORRECT BEHAVIOR: the dump should restore cleanly (a connect=false restore +# should not require the restoring role to have a user mapping on the +# server). +############################################################################# +{ + $node->safe_psql('postgres', 'CREATE DATABASE defect1_src'); + $node->safe_psql( + 'defect1_src', qq{ + CREATE EXTENSION postgres_fdw; + CREATE SERVER s FOREIGN DATA WRAPPER postgres_fdw $srv_opts; + -- Only owner1 has a mapping; the restoring superuser will not. + CREATE USER MAPPING FOR owner1 SERVER s OPTIONS (user 'repl', password 'secret'); + GRANT USAGE ON FOREIGN SERVER s TO owner1; + GRANT CREATE ON DATABASE defect1_src TO owner1; + }); + $node->safe_psql( + 'defect1_src', q{ + SET SESSION AUTHORIZATION owner1; + CREATE SUBSCRIPTION defect1_sub SERVER s PUBLICATION p + WITH (connect = false, slot_name = NONE); + }); + + my $dump = "$tempdir/defect1.sql"; + command_ok( + [ 'pg_dump', '-f', $dump, $node->connstr('defect1_src') ], + 'finding 1: pg_dump of a SERVER-based subscription succeeds'); + + $node->safe_psql('postgres', 'CREATE DATABASE defect1_dst'); + + # BUG: restoring as the superuser (which has no mapping) fails at the + # CREATE SUBSCRIPTION step. When fixed, this should become command_ok(). + command_fails_like( + [ + 'psql', '--no-psqlrc', '-v', 'ON_ERROR_STOP=1', + '-f', $dump, '-d', $node->connstr('defect1_dst') + ], + qr/user mapping not found for user "\Q$super\E", server "s"/, + 'finding 1: restore fails - CREATE resolves the restorer\'s mapping, not the owner\'s' + ); + + # The subscription was therefore not restored into defect1_dst at all. + my $got = $node->safe_psql( + 'defect1_dst', q{ + SELECT count(*) FROM pg_subscription + WHERE subname = 'defect1_sub' + AND subdbid = (SELECT oid FROM pg_database WHERE datname = 'defect1_dst') + }); + is($got, '0', 'finding 1: subscription is missing after the failed restore'); +} + +############################################################################# +# Finding 2: restoring a SERVER-based subscription whose owner derives its +# foreign-server USAGE from a GRANT (rather than ownership) leaves the +# subscription owned by the wrong role. AlterSubscriptionOwner_internal() +# requires the new owner to hold USAGE on the server, but pg_dump emits +# "ALTER SUBSCRIPTION ... OWNER TO owner2" in the main restore pass while +# "GRANT USAGE ON FOREIGN SERVER" is deferred to the later ACL pass -- so at +# the moment of the OWNER TO, owner2 does not yet have USAGE. +# +# CORRECT BEHAVIOR: the OWNER TO should succeed during restore and the +# subscription should end up owned by owner2. +############################################################################# +{ + $node->safe_psql('postgres', 'CREATE DATABASE defect2_src'); + $node->safe_psql( + 'defect2_src', qq{ + CREATE EXTENSION postgres_fdw; + CREATE SERVER s FOREIGN DATA WRAPPER postgres_fdw $srv_opts; + -- PUBLIC mapping, so finding 1 does not mask this one: the + -- restoring superuser can resolve a connection. + CREATE USER MAPPING FOR PUBLIC SERVER s OPTIONS (user 'repl', password 'secret'); + -- owner2's USAGE comes from a GRANT, not from owning the server. + GRANT USAGE ON FOREIGN SERVER s TO owner2; + GRANT CREATE ON DATABASE defect2_src TO owner2; + }); + $node->safe_psql( + 'defect2_src', q{ + SET SESSION AUTHORIZATION owner2; + CREATE SUBSCRIPTION defect2_sub SERVER s PUBLICATION p + WITH (connect = false, slot_name = NONE); + }); + + my $dump = "$tempdir/defect2.sql"; + command_ok( + [ 'pg_dump', '-f', $dump, $node->connstr('defect2_src') ], + 'finding 2: pg_dump succeeds'); + + $node->safe_psql('postgres', 'CREATE DATABASE defect2_dst'); + + # BUG: the CREATE SUBSCRIPTION succeeds (PUBLIC mapping), but the + # subsequent ALTER SUBSCRIPTION ... OWNER TO owner2 fails because the + # GRANT USAGE has not been restored yet. When fixed: command_ok(). + command_fails_like( + [ + 'psql', '--no-psqlrc', '-v', 'ON_ERROR_STOP=1', + '-f', $dump, '-d', $node->connstr('defect2_dst') + ], + qr/new subscription owner "owner2" does not have permission on foreign server "s"/, + 'finding 2: restore fails at OWNER TO because GRANT USAGE is in a later pass' + ); + + # BUG: the subscription is left owned by the restoring superuser instead + # of owner2. When fixed, the expected value is 'owner2'. + my $owner = $node->safe_psql( + 'defect2_dst', q{ + SELECT subowner::regrole FROM pg_subscription + WHERE subname = 'defect2_sub' + AND subdbid = (SELECT oid FROM pg_database WHERE datname = 'defect2_dst') + }); + is($owner, $super, + 'finding 2: subscription is left owned by the restoring superuser, not owner2' + ); +} + +############################################################################# +# Finding 4: REASSIGN OWNED BY, run from any database other than the one +# holding the subscription's foreign server, fails with an internal error. +# pg_subscription is a shared catalog, so shdepReassignOwned() processes the +# subscription from every database; AlterSubscriptionOwner_internal() then +# looks the server up in the *current* database's (per-database) +# pg_foreign_server and raises "cache lookup failed for foreign server". +# This breaks the documented multi-database role-removal workflow (REASSIGN +# OWNED / DROP OWNED in each database, then DROP ROLE). +# +# CORRECT BEHAVIOR: REASSIGN OWNED from another database should reassign the +# subscription without an internal error (either succeeding, or failing with +# a clean, user-facing permission error like the in-database case below). +############################################################################# +{ + $node->safe_psql('postgres', 'CREATE DATABASE defect4_src'); + $node->safe_psql( + 'defect4_src', qq{ + CREATE EXTENSION postgres_fdw; + CREATE SERVER s FOREIGN DATA WRAPPER postgres_fdw $srv_opts; + CREATE USER MAPPING FOR owner4 SERVER s OPTIONS (user 'repl', password 'secret'); + GRANT USAGE ON FOREIGN SERVER s TO owner4; + GRANT CREATE ON DATABASE defect4_src TO owner4; + }); + $node->safe_psql( + 'defect4_src', q{ + SET SESSION AUTHORIZATION owner4; + CREATE SUBSCRIPTION defect4_sub SERVER s PUBLICATION p + WITH (connect = false, slot_name = NONE); + }); + + # BUG: from the "postgres" database (which has no such foreign server), + # REASSIGN OWNED aborts with an internal (XX000) cache-lookup error. + my ($ret, $out, $err) = + $node->psql('postgres', 'REASSIGN OWNED BY owner4 TO bob'); + isnt($ret, 0, 'finding 4: cross-database REASSIGN OWNED fails'); + like( + $err, + qr/cache lookup failed for foreign server \d+/, + 'finding 4: cross-database REASSIGN OWNED raises an internal cache-lookup error' + ); + + # Contrast: run from the subscription's own database, the same command + # fails with a clean, user-facing permission error (bob lacks USAGE on + # the server) -- showing the cross-database internal error is the defect, + # not the reassignment being disallowed. + ($ret, $out, $err) = + $node->psql('defect4_src', 'REASSIGN OWNED BY owner4 TO bob'); + isnt($ret, 0, 'finding 4 (contrast): in-database REASSIGN OWNED also fails here'); + like( + $err, + qr/new subscription owner "bob" does not have permission on foreign server "s"/, + 'finding 4 (contrast): in-database REASSIGN OWNED gives a clean permission error' + ); +} + +done_testing();
test-subconflictlogrelid-REASSIGN-OWNED-v0.patch (text/plain, 5.7K) download commit 26ac659 (HEAD -> subscription-conflictlog-reassign-defect) Author: Noah Misch <nm@cqla.c.codeql-202606a.internal> AuthorDate: Fri Jul 10 17:37:45 2026 +0000 Commit: Noah Misch <nm@cqla.c.codeql-202606a.internal> CommitDate: Fri Jul 10 17:37:45 2026 +0000 Add test for cross-database REASSIGN OWNED of a conflict-log subscription pg_subscription is a shared catalog, so REASSIGN OWNED processes a subscription's ownership from every database (shdepReassignOwned). AlterSubscriptionOwner_internal() then calls ATExecChangeOwner() on the subscription's conflict log table (pg_subscription.subconflictlogrelid), which is a per-database relation. Run from any other database, that OID is not valid, so relation_open() raises "could not open relation with OID N". Worse, if that OID happens to be reused by an unrelated relation in the current database, ATExecChangeOwner() silently changes that relation's owner instead -- a latent silent-corruption hazard. This breaks the documented multi-database role-removal workflow (REASSIGN OWNED / DROP OWNED in each database, then DROP ROLE). No foreign server is involved; a plain CONNECTION subscription with conflict_log_destination = 'table' is enough to reach it. It is the same bug class as the subserver case, via a different per-database OID stored in the shared pg_subscription catalog. The new test asserts the current, buggy behavior so it serves as an executable reproduction; comments note the expected correct behavior for when the defect is fixed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TePr48d48d89GukfGsNw9b --- src/test/subscription/t/100_bugs.pl | 75 +++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/src/test/subscription/t/100_bugs.pl b/src/test/subscription/t/100_bugs.pl index 075c52f..05a7f99 100644 --- a/src/test/subscription/t/100_bugs.pl +++ b/src/test/subscription/t/100_bugs.pl @@ -652,4 +652,79 @@ $node_publisher->safe_psql('postgres', "DROP TABLE tab_upsert"); $node_publisher->stop('fast'); +# REASSIGN OWNED BY of a subscription that has a conflict log table, run from +# a database other than the subscription's own, fails with an internal error. +# +# pg_subscription is a shared catalog, so REASSIGN OWNED (via +# shdepReassignOwned) processes a subscription from every database. +# AlterSubscriptionOwner_internal() then calls ATExecChangeOwner() on the +# subscription's conflict log table (pg_subscription.subconflictlogrelid), +# which is a per-database relation. From any other database that OID is not +# valid, so relation_open() raises "could not open relation with OID N" (and, +# worse, would silently change the owner of an unrelated relation that happens +# to reuse the OID). This breaks the documented multi-database role-removal +# workflow (REASSIGN OWNED / DROP OWNED in each database, then DROP ROLE). +# No foreign server is involved: a plain CONNECTION subscription with +# conflict_log_destination = 'table' is enough to reach this. +# +# This asserts the current, buggy behavior. CORRECT BEHAVIOR: the +# cross-database REASSIGN OWNED should reassign the subscription without an +# internal error (as the in-database case below already does); when fixed, +# the isnt()/like() checks must be flipped to the expected behavior. +{ + my $node = PostgreSQL::Test::Cluster->new('conflict_log_reassign'); + $node->init; + $node->start; + + $node->safe_psql('postgres', 'CREATE ROLE regress_clog_owner'); + $node->safe_psql('postgres', 'CREATE ROLE regress_clog_newowner'); + $node->safe_psql('postgres', 'CREATE DATABASE regress_clog_db'); + + # A plain CONNECTION subscription (no foreign server) that logs conflicts + # to a table. connect => false means no publisher is needed. The + # conflict log table is created in regress_clog_db; hand the subscription + # (and hence the table) to a droppable non-superuser role. + $node->safe_psql( + 'regress_clog_db', q{ + CREATE SUBSCRIPTION regress_clog_sub + CONNECTION 'dbname=regress_nonexistent' PUBLICATION pub + WITH (connect = false, conflict_log_destination = 'table'); + ALTER SUBSCRIPTION regress_clog_sub OWNER TO regress_clog_owner; + }); + + # The subscription uses no server, but does have a conflict log table (a + # per-database relation), which is the ingredient that triggers the bug. + is( $node->safe_psql( + 'regress_clog_db', + q{SELECT subserver = 0 AND subconflictlogrelid <> 0 + FROM pg_subscription WHERE subname = 'regress_clog_sub'}), + 't', + 'conflict-log subscription has no server but a conflict log table'); + + # BUG: from another database ("postgres"), REASSIGN OWNED aborts with an + # internal error because the conflict log table's OID is not valid here. + my ($ret, $stdout, $stderr) = $node->psql('postgres', + 'REASSIGN OWNED BY regress_clog_owner TO regress_clog_newowner'); + isnt($ret, 0, + 'cross-database REASSIGN OWNED of a conflict-log subscription fails'); + like( + $stderr, + qr/could not open relation with OID \d+/, + 'cross-database REASSIGN OWNED raises an internal relation-open error'); + + # Contrast: from the subscription's own database the same command + # succeeds, reassigning both the subscription and its conflict log table. + # The operation is legitimate; only the cross-database path is broken. + $node->safe_psql('regress_clog_db', + 'REASSIGN OWNED BY regress_clog_owner TO regress_clog_newowner'); + is( $node->safe_psql( + 'regress_clog_db', + q{SELECT subowner::regrole::text FROM pg_subscription + WHERE subname = 'regress_clog_sub'}), + 'regress_clog_newowner', + 'in-database REASSIGN OWNED reassigns the conflict-log subscription'); + + $node->stop; +} + done_testing();
^ permalink raw reply [nested|flat] 15+ messages in thread

* Re: REASSIGN OWNED vs. relisshared dep on !relisshared
@ 2026-07-10 22:11  Jeff Davis <pgsql@j-davis.com>
  parent: Noah Misch <noah@leadboat.com>
  0 siblings, 2 replies; 15+ messages in thread

From: Jeff Davis @ 2026-07-10 22:11 UTC (permalink / raw)
  To: Noah Misch <noah@leadboat.com>; +Cc: akapila@postgresql.org; dilipbalaut@gmail.com; nisha.moond412@gmail.com; pgsql-hackers

On Fri, 2026-07-10 at 12:25 -0700, Noah Misch wrote:
> Perhaps one could fix this by having REASSIGN OWNED process only
> pg_subscription rows where subdbid is the current database.

That was my first thought, as well. I will look into it.

> I'm nervous that we'll have other reasons to regret letting a shared
> object
> depend on a non-shared object, but I've not come up with anything
> else
> concrete.

That's a reasonable concern. We discussed it here:

https://www.postgresql.org/message-id/CAA4eK1LyHvRoNzZPpPQqo7a%3D5Wov8F-7%2BKDduy-9ymcRm%3DBatg%40ma...

Though the root of the problem might be that pg_subscription is shared
in the first place.

Perhaps we should just not record the dependency on the foreign server
at all, and if someone drops it, then the drop succeeds and the
connection fails later. That would be more like what would happen if
you revoke privileges, which also isn't tracked by the dependency
mechanism but has a similar result.

Regards,
	Jeff Davis






^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* Re: REASSIGN OWNED vs. relisshared dep on !relisshared
@ 2026-07-10 22:17  Jeff Davis <pgsql@j-davis.com>
  parent: Jeff Davis <pgsql@j-davis.com>
  1 sibling, 0 replies; 15+ messages in thread

From: Jeff Davis @ 2026-07-10 22:17 UTC (permalink / raw)
  To: Noah Misch <noah@leadboat.com>; +Cc: akapila@postgresql.org; dilipbalaut@gmail.com; nisha.moond412@gmail.com; pgsql-hackers

On Fri, 2026-07-10 at 15:11 -0700, Jeff Davis wrote:
> Perhaps we should just not record the dependency on the foreign
> server
> at all

Of course we have to be careful not to leave a dangling reference. That
should be read more as an idea than a proposal.

Regards,
	Jeff Davis






^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* Re: REASSIGN OWNED vs. relisshared dep on !relisshared
@ 2026-07-11 04:00  Amit Kapila <amit.kapila16@gmail.com>
  parent: Jeff Davis <pgsql@j-davis.com>
  1 sibling, 1 reply; 15+ messages in thread

From: Amit Kapila @ 2026-07-11 04:00 UTC (permalink / raw)
  To: Jeff Davis <pgsql@j-davis.com>; +Cc: Noah Misch <noah@leadboat.com>; akapila@postgresql.org; dilipbalaut@gmail.com; nisha.moond412@gmail.com; pgsql-hackers

On Sat, Jul 11, 2026 at 3:41 AM Jeff Davis <pgsql@j-davis.com> wrote:
>
> On Fri, 2026-07-10 at 12:25 -0700, Noah Misch wrote:
> > Perhaps one could fix this by having REASSIGN OWNED process only
> > pg_subscription rows where subdbid is the current database.
>
> That was my first thought, as well. I will look into it.
>
> > I'm nervous that we'll have other reasons to regret letting a shared
> > object
> > depend on a non-shared object, but I've not come up with anything
> > else
> > concrete.
>
> That's a reasonable concern. We discussed it here:
>
> https://www.postgresql.org/message-id/CAA4eK1LyHvRoNzZPpPQqo7a%3D5Wov8F-7%2BKDduy-9ymcRm%3DBatg%40ma...
>
> Though the root of the problem might be that pg_subscription is shared
> in the first place.
>

Yeah, but actually a subscription is really tied to a specific
database; the catalog is shared only because the replication launcher
must see all subscriptions to start their workers, as the header
comment notes: "Technically, the subscriptions live inside the
database, so a shared catalog seems weird, but the replication
launcher process needs to access all of them to be able to start the
workers, so we have to put them in a shared, nailed catalog."

Note that the subscription commands already behave per-database in
code: CREATE SUBSCRIPTION stores subdbid = MyDatabaseId, and
ALTER/DROP SUBSCRIPTION and ALTER SUBSCRIPTION ... OWNER all look the
subscription  up by (MyDatabaseId, subname) via the unique index on
(subdbid, subname), so they only ever act on subscriptions in the
current database.

Given that, and that REASSIGN OWNED is already documented as a
per-database operation "Because REASSIGN OWNED does not affect objects
within other databases, it is usually necessary to execute this
command in each database that contains objects owned by a role that is
to be removed.", processing only the pg_subscription rows whose
subdbid is the current database sounds like a fix (which is consistent
with other commands operating on a subscription) for this as mentioned
by both you and Noah.

-- 
With Regards,
Amit Kapila.





^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* Re: REASSIGN OWNED vs. relisshared dep on !relisshared
@ 2026-07-13 11:34  Dilip Kumar <dilipbalaut@gmail.com>
  parent: Amit Kapila <amit.kapila16@gmail.com>
  0 siblings, 2 replies; 15+ messages in thread

From: Dilip Kumar @ 2026-07-13 11:34 UTC (permalink / raw)
  To: Amit Kapila <amit.kapila16@gmail.com>; +Cc: Jeff Davis <pgsql@j-davis.com>; Noah Misch <noah@leadboat.com>; akapila@postgresql.org; nisha.moond412@gmail.com; pgsql-hackers

On Sat, Jul 11, 2026 at 9:31 AM Amit Kapila <amit.kapila16@gmail.com> wrote:
>
> On Sat, Jul 11, 2026 at 3:41 AM Jeff Davis <pgsql@j-davis.com> wrote:
> >
> > On Fri, 2026-07-10 at 12:25 -0700, Noah Misch wrote:
> > > Perhaps one could fix this by having REASSIGN OWNED process only
> > > pg_subscription rows where subdbid is the current database.
> >
> > That was my first thought, as well. I will look into it.
> >
> > > I'm nervous that we'll have other reasons to regret letting a shared
> > > object
> > > depend on a non-shared object, but I've not come up with anything
> > > else
> > > concrete.
> >
> > That's a reasonable concern. We discussed it here:
> >
> > https://www.postgresql.org/message-id/CAA4eK1LyHvRoNzZPpPQqo7a%3D5Wov8F-7%2BKDduy-9ymcRm%3DBatg%40ma...
> >
> > Though the root of the problem might be that pg_subscription is shared
> > in the first place.
> >
>
> Yeah, but actually a subscription is really tied to a specific
> database; the catalog is shared only because the replication launcher
> must see all subscriptions to start their workers, as the header
> comment notes: "Technically, the subscriptions live inside the
> database, so a shared catalog seems weird, but the replication
> launcher process needs to access all of them to be able to start the
> workers, so we have to put them in a shared, nailed catalog."
>
> Note that the subscription commands already behave per-database in
> code: CREATE SUBSCRIPTION stores subdbid = MyDatabaseId, and
> ALTER/DROP SUBSCRIPTION and ALTER SUBSCRIPTION ... OWNER all look the
> subscription  up by (MyDatabaseId, subname) via the unique index on
> (subdbid, subname), so they only ever act on subscriptions in the
> current database.
>
> Given that, and that REASSIGN OWNED is already documented as a
> per-database operation "Because REASSIGN OWNED does not affect objects
> within other databases, it is usually necessary to execute this
> command in each database that contains objects owned by a role that is
> to be removed.", processing only the pg_subscription rows whose
> subdbid is the current database sounds like a fix (which is consistent
> with other commands operating on a subscription) for this as mentioned
> by both you and Noah.


PFA a patch for skipping subscriptions belonging to different databases.

-- 
Regards,
Dilip Kumar
Google

Attachments:

v1-0001-Do-not-reassign-subscriptions-belonging-to-other-.patch (application/octet-stream, 4.2K) download From b82f60ca9cc79b4f6d0b0c059d1885f23b636ca9 Mon Sep 17 00:00:00 2001 From: Dilip Kumar <dilipkumarb@google.com> Date: Mon, 13 Jul 2026 16:19:00 +0530 Subject: [PATCH v1] Do not reassign subscriptions belonging to other databases in REASSIGN OWNED. Subscription objects are fundamentally database-local in scope. Subscription DDL commands already operate on a per-database basis: CREATE SUBSCRIPTION stores subdbid = MyDatabaseId, and ALTER/DROP SUBSCRIPTION commands (including ALTER SUBSCRIPTION ... OWNER TO) look subscriptions up by (MyDatabaseId, subname) via the unique index on (subdbid, subname), acting strictly on subscriptions in the current database. Furthermore, subscription fields like subserver (commit 8185bb5) and subconflictlogrelid (commit a5918fd) reference database-local objects (!relisshared) in that database. However, because pg_subscription is stored as a shared catalog table (relisshared == true), shared dependency entries for subscriptions in pg_shdepend have dbid = InvalidOid. As a result, REASSIGN OWNED attempted to reassign subscriptions belonging to any database in the cluster. When executed in a database other than subdbid, this caused AlterSubscriptionOwner_internal() to resolve database-local references (such as subserver and subconflictlogrelid) against the current database (MyDatabaseId), resulting in errors or wrongly altering unrelated objects. Fix this by skipping subscription ownership reassignment in AlterSubscriptionOwner_internal() if form->subdbid != MyDatabaseId. Like other database-local objects, subscriptions will now be reassigned when REASSIGN OWNED is executed in the database to which they belong. --- doc/src/sgml/ref/reassign_owned.sgml | 5 ++++- doc/src/sgml/user-manag.sgml | 4 +++- src/backend/commands/subscriptioncmds.c | 9 +++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/doc/src/sgml/ref/reassign_owned.sgml b/doc/src/sgml/ref/reassign_owned.sgml index ab692bd0690..5fca2329de2 100644 --- a/doc/src/sgml/ref/reassign_owned.sgml +++ b/doc/src/sgml/ref/reassign_owned.sgml @@ -48,7 +48,10 @@ REASSIGN OWNED BY { <replaceable class="parameter">old_role</replaceable> | CURR The name of a role. The ownership of all the objects within the current database, and of all shared objects (databases, tablespaces), owned by this role will be reassigned to - <replaceable class="parameter">new_role</replaceable>. + <replaceable class="parameter">new_role</replaceable>. Subscriptions, + although stored in a shared catalog, belong to a specific database + and are reassigned only when <command>REASSIGN OWNED</command> is executed + in that database. </para> </listitem> </varlistentry> diff --git a/doc/src/sgml/user-manag.sgml b/doc/src/sgml/user-manag.sgml index 0ec32700bd4..c7e0b11706e 100644 --- a/doc/src/sgml/user-manag.sgml +++ b/doc/src/sgml/user-manag.sgml @@ -530,7 +530,9 @@ ALTER TABLE bobs_table OWNER TO alice; that contains objects owned by the role. (Note that the first such <command>REASSIGN OWNED</command> will change the ownership of any shared-across-databases objects, that is databases or tablespaces, that - are owned by the role-to-be-dropped.) + are owned by the role-to-be-dropped. Subscriptions, while stored in a + shared catalog, belong to a specific database and are reassigned when + <command>REASSIGN OWNED</command> is executed in that database.) </para> <para> diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c index 4292e7fb8f4..cd37885222a 100644 --- a/src/backend/commands/subscriptioncmds.c +++ b/src/backend/commands/subscriptioncmds.c @@ -2868,6 +2868,15 @@ AlterSubscriptionOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId) form = (Form_pg_subscription) GETSTRUCT(tup); + /* + * Don't process subscriptions belonging to other databases. While + * pg_subscription is a shared catalog, subscriptions refer to db-local + * objects like subserver and subconflictlogrelid which exist only in the + * database identified by subdbid. + */ + if (form->subdbid != MyDatabaseId) + return; + if (form->subowner == newOwnerId) return; -- 2.49.0
^ permalink raw reply [nested|flat] 15+ messages in thread

* Re: REASSIGN OWNED vs. relisshared dep on !relisshared
@ 2026-07-14 06:17  shveta malik <shveta.malik@gmail.com>
  parent: Dilip Kumar <dilipbalaut@gmail.com>
  1 sibling, 0 replies; 15+ messages in thread

From: shveta malik @ 2026-07-14 06:17 UTC (permalink / raw)
  To: Dilip Kumar <dilipbalaut@gmail.com>; +Cc: Amit Kapila <amit.kapila16@gmail.com>; Jeff Davis <pgsql@j-davis.com>; Noah Misch <noah@leadboat.com>; akapila@postgresql.org, nisha.moond412@gmail.com, pgsql-hackers@postgresql.org, shveta malik <shveta.malik@gmail.com>

On Mon, Jul 13, 2026 at 5:04 PM Dilip Kumar <dilipbalaut@gmail.com> wrote:
>
> On Sat, Jul 11, 2026 at 9:31 AM Amit Kapila <amit.kapila16@gmail.com> wrote:
> >
> > On Sat, Jul 11, 2026 at 3:41 AM Jeff Davis <pgsql@j-davis.com> wrote:
> > >
> > > On Fri, 2026-07-10 at 12:25 -0700, Noah Misch wrote:
> > > > Perhaps one could fix this by having REASSIGN OWNED process only
> > > > pg_subscription rows where subdbid is the current database.
> > >
> > > That was my first thought, as well. I will look into it.
> > >
> > > > I'm nervous that we'll have other reasons to regret letting a shared
> > > > object
> > > > depend on a non-shared object, but I've not come up with anything
> > > > else
> > > > concrete.
> > >
> > > That's a reasonable concern. We discussed it here:
> > >
> > > https://www.postgresql.org/message-id/CAA4eK1LyHvRoNzZPpPQqo7a%3D5Wov8F-7%2BKDduy-9ymcRm%3DBatg%40ma...
> > >
> > > Though the root of the problem might be that pg_subscription is shared
> > > in the first place.
> > >
> >
> > Yeah, but actually a subscription is really tied to a specific
> > database; the catalog is shared only because the replication launcher
> > must see all subscriptions to start their workers, as the header
> > comment notes: "Technically, the subscriptions live inside the
> > database, so a shared catalog seems weird, but the replication
> > launcher process needs to access all of them to be able to start the
> > workers, so we have to put them in a shared, nailed catalog."
> >
> > Note that the subscription commands already behave per-database in
> > code: CREATE SUBSCRIPTION stores subdbid = MyDatabaseId, and
> > ALTER/DROP SUBSCRIPTION and ALTER SUBSCRIPTION ... OWNER all look the
> > subscription  up by (MyDatabaseId, subname) via the unique index on
> > (subdbid, subname), so they only ever act on subscriptions in the
> > current database.
> >
> > Given that, and that REASSIGN OWNED is already documented as a
> > per-database operation "Because REASSIGN OWNED does not affect objects
> > within other databases, it is usually necessary to execute this
> > command in each database that contains objects owned by a role that is
> > to be removed.", processing only the pg_subscription rows whose
> > subdbid is the current database sounds like a fix (which is consistent
> > with other commands operating on a subscription) for this as mentioned
> > by both you and Noah.
>
>
> PFA a patch for skipping subscriptions belonging to different databases.
>

The fix idea and the patch LGTM. One minor comment in the doc:

'and are reassigned when REASSIGN OWNED is executed in that database.'

when --> only when  (to make it more clear)

thanks
Shveta






^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* Re: REASSIGN OWNED vs. relisshared dep on !relisshared
@ 2026-07-14 20:50  Jeff Davis <pgsql@j-davis.com>
  parent: Dilip Kumar <dilipbalaut@gmail.com>
  1 sibling, 1 reply; 15+ messages in thread

From: Jeff Davis @ 2026-07-14 20:50 UTC (permalink / raw)
  To: Dilip Kumar <dilipbalaut@gmail.com>; Amit Kapila <amit.kapila16@gmail.com>; +Cc: Noah Misch <noah@leadboat.com>; akapila@postgresql.org; nisha.moond412@gmail.com; pgsql-hackers

On Mon, 2026-07-13 at 17:04 +0530, Dilip Kumar wrote:
> PFA a patch for skipping subscriptions belonging to different
> databases.

I suggest we add a few checks (or asserts) that subdbid==MyDatabaseId
when reading pg_subscription from anywhere other than the launcher.

Also, the REASSIGN OWNED path goes through
AlterSubscriptionOwner_oid(), whereas both the REASSIGN OWNED and ALTER
SUBSCRIPTION ... OWNER TO paths go through
AlterSubscriptionOwner_internal(). It would be more clear to add the
skipping logic in the former and an assert in the latter.

Other than that, LGTM.

We can also reconsider how we handle dependencies to address Noah's
concern, but this patch is good regardless.

Regards,
	Jeff Davis







^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* Re: REASSIGN OWNED vs. relisshared dep on !relisshared
@ 2026-07-15 15:23  Dilip Kumar <dilipbalaut@gmail.com>
  parent: Jeff Davis <pgsql@j-davis.com>
  0 siblings, 1 reply; 15+ messages in thread

From: Dilip Kumar @ 2026-07-15 15:23 UTC (permalink / raw)
  To: Jeff Davis <pgsql@j-davis.com>; +Cc: Amit Kapila <amit.kapila16@gmail.com>; Noah Misch <noah@leadboat.com>; akapila@postgresql.org; nisha.moond412@gmail.com; pgsql-hackers

On Wed, Jul 15, 2026 at 2:20 AM Jeff Davis <pgsql@j-davis.com> wrote:
>
> On Mon, 2026-07-13 at 17:04 +0530, Dilip Kumar wrote:
> > PFA a patch for skipping subscriptions belonging to different
> > databases.
>
> I suggest we add a few checks (or asserts) that subdbid==MyDatabaseId
> when reading pg_subscription from anywhere other than the launcher.

Yeah, I've done that

> Also, the REASSIGN OWNED path goes through
> AlterSubscriptionOwner_oid(), whereas both the REASSIGN OWNED and ALTER
> SUBSCRIPTION ... OWNER TO paths go through
> AlterSubscriptionOwner_internal(). It would be more clear to add the
> skipping logic in the former and an assert in the latter.

That makes sense; I've made the change.

> Other than that, LGTM.

Thanks for the review


-- 
Regards,
Dilip Kumar
Google

Attachments:

v2-0001-Do-not-reassign-subscriptions-belonging-to-other-.patch (application/octet-stream, 6.5K) download From 446c5e0d8c09dffb4b1090f0d205ffcb9c0f29a5 Mon Sep 17 00:00:00 2001 From: Dilip Kumar <dilipkumarb@google.com> Date: Mon, 13 Jul 2026 16:19:00 +0530 Subject: [PATCH v2] Do not reassign subscriptions belonging to other databases in REASSIGN OWNED. Subscription objects are fundamentally database-local in scope. Subscription DDL commands already operate on a per-database basis: CREATE SUBSCRIPTION stores subdbid = MyDatabaseId, and ALTER/DROP SUBSCRIPTION commands (including ALTER SUBSCRIPTION ... OWNER TO) look subscriptions up by (MyDatabaseId, subname) via the unique index on (subdbid, subname), acting strictly on subscriptions in the current database. Furthermore, subscription fields like subserver (commit 8185bb5) and subconflictlogrelid (commit a5918fd) reference database-local objects (!relisshared) in that database. However, because pg_subscription is stored as a shared catalog table (relisshared == true), shared dependency entries for subscriptions in pg_shdepend have dbid = InvalidOid. As a result, REASSIGN OWNED attempted to reassign subscriptions belonging to any database in the cluster. When executed in a database other than subdbid, this caused AlterSubscriptionOwner_internal() to resolve database-local references (such as subserver and subconflictlogrelid) against the current database (MyDatabaseId), resulting in errors or wrongly altering unrelated objects. Fix this by skipping subscription ownership reassignment in AlterSubscriptionOwner_internal() if form->subdbid != MyDatabaseId. Like other database-local objects, subscriptions will now be reassigned when REASSIGN OWNED is executed in the database to which they belong. --- doc/src/sgml/ref/reassign_owned.sgml | 5 ++++- doc/src/sgml/user-manag.sgml | 4 +++- src/backend/catalog/pg_subscription.c | 13 +++++++++++++ src/backend/commands/subscriptioncmds.c | 15 ++++++++++++++- 4 files changed, 34 insertions(+), 3 deletions(-) diff --git a/doc/src/sgml/ref/reassign_owned.sgml b/doc/src/sgml/ref/reassign_owned.sgml index ab692bd0690..5fca2329de2 100644 --- a/doc/src/sgml/ref/reassign_owned.sgml +++ b/doc/src/sgml/ref/reassign_owned.sgml @@ -48,7 +48,10 @@ REASSIGN OWNED BY { <replaceable class="parameter">old_role</replaceable> | CURR The name of a role. The ownership of all the objects within the current database, and of all shared objects (databases, tablespaces), owned by this role will be reassigned to - <replaceable class="parameter">new_role</replaceable>. + <replaceable class="parameter">new_role</replaceable>. Subscriptions, + although stored in a shared catalog, belong to a specific database + and are reassigned only when <command>REASSIGN OWNED</command> is executed + in that database. </para> </listitem> </varlistentry> diff --git a/doc/src/sgml/user-manag.sgml b/doc/src/sgml/user-manag.sgml index 0ec32700bd4..f0b4ca069ec 100644 --- a/doc/src/sgml/user-manag.sgml +++ b/doc/src/sgml/user-manag.sgml @@ -530,7 +530,9 @@ ALTER TABLE bobs_table OWNER TO alice; that contains objects owned by the role. (Note that the first such <command>REASSIGN OWNED</command> will change the ownership of any shared-across-databases objects, that is databases or tablespaces, that - are owned by the role-to-be-dropped.) + are owned by the role-to-be-dropped. Subscriptions, while stored in a + shared catalog, belong to a specific database and are reassigned only when + <command>REASSIGN OWNED</command> is executed in that database.) </para> <para> diff --git a/src/backend/catalog/pg_subscription.c b/src/backend/catalog/pg_subscription.c index 2068e03c571..387365f7ee4 100644 --- a/src/backend/catalog/pg_subscription.c +++ b/src/backend/catalog/pg_subscription.c @@ -25,6 +25,7 @@ #include "catalog/pg_type.h" #include "foreign/foreign.h" #include "miscadmin.h" +#include "replication/logicallauncher.h" #include "storage/lmgr.h" #include "storage/lock.h" #include "utils/acl.h" @@ -114,6 +115,12 @@ GetSubscription(Oid subid, bool missing_ok, bool conninfo_needed, subform = (Form_pg_subscription) GETSTRUCT(tup); + /* + * Outside the launcher process, subscription lookups must only access + * subscriptions belonging to the current database. + */ + Assert(IsLogicalLauncher() || subform->subdbid == MyDatabaseId); + sub = palloc0_object(Subscription); sub->cxt = cxt; sub->oid = subid; @@ -272,6 +279,9 @@ DisableSubscription(Oid subid) if (!HeapTupleIsValid(tup)) elog(ERROR, "cache lookup failed for subscription %u", subid); + /* Must only modify subscriptions belonging to the current database. */ + Assert(((Form_pg_subscription) GETSTRUCT(tup))->subdbid == MyDatabaseId); + LockSharedObject(SubscriptionRelationId, subid, 0, AccessShareLock); /* Form a new tuple. */ @@ -714,6 +724,9 @@ UpdateDeadTupleRetentionStatus(Oid subid, bool active) if (!HeapTupleIsValid(tup)) elog(ERROR, "cache lookup failed for subscription %u", subid); + /* Must only modify subscriptions belonging to the current database. */ + Assert(((Form_pg_subscription) GETSTRUCT(tup))->subdbid == MyDatabaseId); + LockSharedObject(SubscriptionRelationId, subid, 0, AccessShareLock); /* Form a new tuple. */ diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c index 4292e7fb8f4..c40c5def1a3 100644 --- a/src/backend/commands/subscriptioncmds.c +++ b/src/backend/commands/subscriptioncmds.c @@ -2868,6 +2868,9 @@ AlterSubscriptionOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId) form = (Form_pg_subscription) GETSTRUCT(tup); + /* Must only alter subscriptions belonging to the current database. */ + Assert(form->subdbid == MyDatabaseId); + if (form->subowner == newOwnerId) return; @@ -2987,6 +2990,7 @@ AlterSubscriptionOwner_oid(Oid subid, Oid newOwnerId) { HeapTuple tup; Relation rel; + Form_pg_subscription form; rel = table_open(SubscriptionRelationId, RowExclusiveLock); @@ -2997,7 +3001,16 @@ AlterSubscriptionOwner_oid(Oid subid, Oid newOwnerId) (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("subscription with OID %u does not exist", subid))); - AlterSubscriptionOwner_internal(rel, tup, newOwnerId); + form = (Form_pg_subscription) GETSTRUCT(tup); + + /* + * Don't process subscriptions belonging to other databases. While + * pg_subscription is a shared catalog, subscriptions refer to db-local + * objects like subserver and subconflictlogrelid which exist only in the + * database identified by subdbid. + */ + if (form->subdbid == MyDatabaseId) + AlterSubscriptionOwner_internal(rel, tup, newOwnerId); heap_freetuple(tup); -- 2.49.0
^ permalink raw reply [nested|flat] 15+ messages in thread

* Re: REASSIGN OWNED vs. relisshared dep on !relisshared
@ 2026-07-15 18:36  Jeff Davis <pgsql@j-davis.com>
  parent: Dilip Kumar <dilipbalaut@gmail.com>
  0 siblings, 1 reply; 15+ messages in thread

From: Jeff Davis @ 2026-07-15 18:36 UTC (permalink / raw)
  To: Dilip Kumar <dilipbalaut@gmail.com>; +Cc: Amit Kapila <amit.kapila16@gmail.com>; Noah Misch <noah@leadboat.com>; akapila@postgresql.org; nisha.moond412@gmail.com; pgsql-hackers

On Wed, 2026-07-15 at 20:53 +0530, Dilip Kumar wrote:
> Thanks for the review

Looks good to me, thank you for the patch. I will commit this soon.

To address Noah's concern: is the concern about the dependency link, or
about having a database-specific oid in a shared catalog at all?

If the former, then we could do the same work manually outside of the
pg_depend mechanism.

If the latter, we could decompose pg_subscription into the columns
necessary for the launcher (shared catalog) and the database-specific
columns (unshared catalog). But that's more invasive so it might not be
v19 material.

Thoughts?

Regards,
	Jeff Davis







^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* Re: REASSIGN OWNED vs. relisshared dep on !relisshared
@ 2026-07-18 06:40  Amit Kapila <amit.kapila16@gmail.com>
  parent: Jeff Davis <pgsql@j-davis.com>
  0 siblings, 1 reply; 15+ messages in thread

From: Amit Kapila @ 2026-07-18 06:40 UTC (permalink / raw)
  To: Jeff Davis <pgsql@j-davis.com>; +Cc: Dilip Kumar <dilipbalaut@gmail.com>; Noah Misch <noah@leadboat.com>; akapila@postgresql.org; nisha.moond412@gmail.com; pgsql-hackers

On Thu, Jul 16, 2026 at 12:06 AM Jeff Davis <pgsql@j-davis.com> wrote:
>
> On Wed, 2026-07-15 at 20:53 +0530, Dilip Kumar wrote:
> > Thanks for the review
>
> Looks good to me, thank you for the patch. I will commit this soon.
>

Thanks.

> To address Noah's concern: is the concern about the dependency link, or
> about having a database-specific oid in a shared catalog at all?
>
> If the former, then we could do the same work manually outside of the
> pg_depend mechanism.
>
> If the latter, we could decompose pg_subscription into the columns
> necessary for the launcher (shared catalog) and the database-specific
> columns (unshared catalog). But that's more invasive so it might not be
> v19 material.
>

I feel it is the latter as the former doesn't scale well, since each
new db-specific column would need its own bespoke handling instead of
the dependency machinery handling it uniformly. I agree with your
judgement that it is not a good idea to tackle this in v19, especially
because splitting a shared, user-visible catalog is too
invasive to land safely this late in the cycle, whereas the
subdbid-scoping fix already resolves the actual bug at low risk,
leaving the decomposition as a structural cleanup better suited to
v20.

-- 
With Regards,
Amit Kapila.






^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* Re: REASSIGN OWNED vs. relisshared dep on !relisshared
@ 2026-07-18 16:41  Jeff Davis <pgsql@j-davis.com>
  parent: Amit Kapila <amit.kapila16@gmail.com>
  0 siblings, 1 reply; 15+ messages in thread

From: Jeff Davis @ 2026-07-18 16:41 UTC (permalink / raw)
  To: Amit Kapila <amit.kapila16@gmail.com>; +Cc: Dilip Kumar <dilipbalaut@gmail.com>; Noah Misch <noah@leadboat.com>; akapila@postgresql.org; nisha.moond412@gmail.com; pgsql-hackers

On Sat, 2026-07-18 at 12:10 +0530, Amit Kapila wrote:
> On Thu, Jul 16, 2026 at 12:06 AM Jeff Davis <pgsql@j-davis.com> 
> > Looks good to me, thank you for the patch. I will commit this soon.

Committed with a smaller test. Thank you.

> > To address Noah's concern: is the concern about the dependency
> > link, or
> > about having a database-specific oid in a shared catalog at all?
...
> I feel it is the latter as the former doesn't scale well, since each
> new db-specific column would need its own bespoke handling instead of
> the dependency machinery handling it uniformly. I agree with your
> judgement that it is not a good idea to tackle this in v19,
> especially
> because splitting a shared, user-visible catalog is too
> invasive to land safely this late in the cycle, whereas the
> subdbid-scoping fix already resolves the actual bug at low risk,
> leaving the decomposition as a structural cleanup better suited to
> v20.

OK, should we go ahead and split the pg_subscription catalog for v20
then? Maybe pg_subscription (shared) and pg_subscription_db (per-
database)?

Regards,
	Jeff Davis







^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* Re: REASSIGN OWNED vs. relisshared dep on !relisshared
@ 2026-07-19 01:39  Amit Kapila <amit.kapila16@gmail.com>
  parent: Jeff Davis <pgsql@j-davis.com>
  0 siblings, 2 replies; 15+ messages in thread

From: Amit Kapila @ 2026-07-19 01:39 UTC (permalink / raw)
  To: Jeff Davis <pgsql@j-davis.com>; +Cc: Dilip Kumar <dilipbalaut@gmail.com>; Noah Misch <noah@leadboat.com>; akapila@postgresql.org; nisha.moond412@gmail.com; pgsql-hackers

On Sat, Jul 18, 2026 at 10:11 PM Jeff Davis <pgsql@j-davis.com> wrote:
>
> On Sat, 2026-07-18 at 12:10 +0530, Amit Kapila wrote:
> > On Thu, Jul 16, 2026 at 12:06 AM Jeff Davis <pgsql@j-davis.com>
> > > Looks good to me, thank you for the patch. I will commit this soon.
>
> Committed with a smaller test. Thank you.
>
> > > To address Noah's concern: is the concern about the dependency
> > > link, or
> > > about having a database-specific oid in a shared catalog at all?
> ...
> > I feel it is the latter as the former doesn't scale well, since each
> > new db-specific column would need its own bespoke handling instead of
> > the dependency machinery handling it uniformly. I agree with your
> > judgement that it is not a good idea to tackle this in v19,
> > especially
> > because splitting a shared, user-visible catalog is too
> > invasive to land safely this late in the cycle, whereas the
> > subdbid-scoping fix already resolves the actual bug at low risk,
> > leaving the decomposition as a structural cleanup better suited to
> > v20.
>
> OK, should we go ahead and split the pg_subscription catalog for v20
> then? Maybe pg_subscription (shared) and pg_subscription_db (per-
> database)?
>

+1, though I am not sure of catalog names. We can brainstorm those
during development.

-- 
With Regards,
Amit Kapila.






^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* RE: REASSIGN OWNED vs. relisshared dep on !relisshared
@ 2026-07-19 06:34  Hayato Kuroda (Fujitsu) <kuroda.hayato@fujitsu.com>
  parent: Amit Kapila <amit.kapila16@gmail.com>
  1 sibling, 0 replies; 15+ messages in thread

From: Hayato Kuroda (Fujitsu) @ 2026-07-19 06:34 UTC (permalink / raw)
  To: Amit Kapila <amit.kapila16@gmail.com>; Jeff Davis <pgsql@j-davis.com>; +Cc: Dilip Kumar <dilipbalaut@gmail.com>; Noah Misch <noah@leadboat.com>; akapila@postgresql.org <akapila@postgresql.org>; nisha.moond412@gmail.com <nisha.moond412@gmail.com>; pgsql-hackers

Dear Hackers,

> > OK, should we go ahead and split the pg_subscription catalog for v20
> > then? Maybe pg_subscription (shared) and pg_subscription_db (per-
> > database)?
> >
> 
> +1, though I am not sure of catalog names. We can brainstorm those
> during development.

+1. I cannot come up with better idea to resolve the entanglement. I briefly
checked the launcher code and it read 7 attributes [1] at least. Not verified,
all of them (or except name) can be retained on the shared catalog.

If it's ok I can start a separated thread after analyzing bit more with the PoC.

[1]:
```
oid
dbid
name
owner
retaindeadtuples
retentionactive
enabled
```

Best regards,
Hayato Kuroda
FUJITSU LIMITED



^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* Re: REASSIGN OWNED vs. relisshared dep on !relisshared
@ 2026-08-28 23:11  Noah Misch <noah@leadboat.com>
  parent: Amit Kapila <amit.kapila16@gmail.com>
  1 sibling, 1 reply; 15+ messages in thread

From: Noah Misch @ 2026-08-28 23:11 UTC (permalink / raw)
  To: Jeff Davis <pgsql@j-davis.com>; Amit Kapila <amit.kapila16@gmail.com>; +Cc: Dilip Kumar <dilipbalaut@gmail.com>; akapila@postgresql.org; nisha.moond412@gmail.com; pgsql-hackers

On Sun, Jul 19, 2026 at 07:09:13AM +0530, Amit Kapila wrote:
> On Sat, Jul 18, 2026 at 10:11 PM Jeff Davis <pgsql@j-davis.com> wrote:
> > On Sat, 2026-07-18 at 12:10 +0530, Amit Kapila wrote:
> > > On Thu, Jul 16, 2026 at 12:06 AM Jeff Davis <pgsql@j-davis.com>
> > > > To address Noah's concern: is the concern about the dependency
> > > > link, or
> > > > about having a database-specific oid in a shared catalog at all?
> > ...
> > > I feel it is the latter as the former doesn't scale well, since each
> > > new db-specific column would need its own bespoke handling instead of
> > > the dependency machinery handling it uniformly. I agree with your
> > > judgement that it is not a good idea to tackle this in v19,
> > > especially
> > > because splitting a shared, user-visible catalog is too
> > > invasive to land safely this late in the cycle, whereas the
> > > subdbid-scoping fix already resolves the actual bug at low risk,
> > > leaving the decomposition as a structural cleanup better suited to
> > > v20.
> >
> > OK, should we go ahead and split the pg_subscription catalog for v20
> > then? Maybe pg_subscription (shared) and pg_subscription_db (per-
> > database)?
> >
> 
> +1, though I am not sure of catalog names. We can brainstorm those
> during development.

That works for me.  I agree an untracked dependency would be worse than the
status quo and worse than splitting the catalog.  I don't have a strong
objection to the status quo.






^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* RE: REASSIGN OWNED vs. relisshared dep on !relisshared
@ 2026-08-29 11:16  Hayato Kuroda (Fujitsu) <kuroda.hayato@fujitsu.com>
  parent: Noah Misch <noah@leadboat.com>
  0 siblings, 0 replies; 15+ messages in thread

From: Hayato Kuroda (Fujitsu) @ 2026-08-29 11:16 UTC (permalink / raw)
  To: Noah Misch <noah@leadboat.com>; Jeff Davis <pgsql@j-davis.com>; Amit Kapila <amit.kapila16@gmail.com>; +Cc: Dilip Kumar <dilipbalaut@gmail.com>; akapila@postgresql.org <akapila@postgresql.org>; nisha.moond412@gmail.com <nisha.moond412@gmail.com>; pgsql-hackers

Dear Noah,

> That works for me.  I agree an untracked dependency would be worse than the
> status quo and worse than splitting the catalog.  I don't have a strong
> objection to the status quo.

Thanks for the agreement. The implementation has already been done locally,
but I'm planning to start a new thread after the PG19 is stabilized once.

Best regards,
Hayato Kuroda
FUJITSU LIMITED



^ permalink  raw  reply  [nested|flat] 15+ messages in thread


end of thread, other threads:[~2026-08-29 11:16 UTC | newest]

Thread overview: 15+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-07-10 19:25 REASSIGN OWNED vs. relisshared dep on !relisshared Noah Misch <noah@leadboat.com>
2026-07-10 22:11 ` Jeff Davis <pgsql@j-davis.com>
2026-07-10 22:17   ` Jeff Davis <pgsql@j-davis.com>
2026-07-11 04:00   ` Amit Kapila <amit.kapila16@gmail.com>
2026-07-13 11:34     ` Dilip Kumar <dilipbalaut@gmail.com>
2026-07-14 06:17       ` shveta malik <shveta.malik@gmail.com>
2026-07-14 20:50       ` Jeff Davis <pgsql@j-davis.com>
2026-07-15 15:23         ` Dilip Kumar <dilipbalaut@gmail.com>
2026-07-15 18:36           ` Jeff Davis <pgsql@j-davis.com>
2026-07-18 06:40             ` Amit Kapila <amit.kapila16@gmail.com>
2026-07-18 16:41               ` Jeff Davis <pgsql@j-davis.com>
2026-07-19 01:39                 ` Amit Kapila <amit.kapila16@gmail.com>
2026-07-19 06:34                   ` Hayato Kuroda (Fujitsu) <kuroda.hayato@fujitsu.com>
2026-08-28 23:11                   ` Noah Misch <noah@leadboat.com>
2026-08-29 11:16                     ` Hayato Kuroda (Fujitsu) <kuroda.hayato@fujitsu.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox