Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 50cf1c8

Browse files
committed
Record dependencies on owners for logical replication objects
This was forgotten in 665d1fa and caused the whole buildfarm to become red for a little while. Author: Petr Jelínek Also fix a typo in a nearby error message.
1 parent a600ee9 commit 50cf1c8

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/backend/commands/publicationcmds.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ CreatePublication(CreatePublicationStmt *stmt)
218218
CatalogUpdateIndexes(rel, tup);
219219
heap_freetuple(tup);
220220

221+
recordDependencyOnOwner(PublicationRelationId, puboid, GetUserId());
222+
221223
ObjectAddressSet(myself, PublicationRelationId, puboid);
222224

223225
/* Make the changes visible. */

src/backend/commands/subscriptioncmds.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ CreateSubscription(CreateSubscriptionStmt *stmt)
210210
Oid subid;
211211
bool nulls[Natts_pg_subscription];
212212
Datum values[Natts_pg_subscription];
213+
Oid owner = GetUserId();
213214
HeapTuple tup;
214215
bool enabled_given;
215216
bool enabled;
@@ -263,7 +264,7 @@ CreateSubscription(CreateSubscriptionStmt *stmt)
263264
values[Anum_pg_subscription_subdbid - 1] = ObjectIdGetDatum(MyDatabaseId);
264265
values[Anum_pg_subscription_subname - 1] =
265266
DirectFunctionCall1(namein, CStringGetDatum(stmt->subname));
266-
values[Anum_pg_subscription_subowner - 1] = ObjectIdGetDatum(GetUserId());
267+
values[Anum_pg_subscription_subowner - 1] = ObjectIdGetDatum(owner);
267268
values[Anum_pg_subscription_subenabled - 1] = BoolGetDatum(enabled);
268269
values[Anum_pg_subscription_subconninfo - 1] =
269270
CStringGetTextDatum(conninfo);
@@ -279,6 +280,8 @@ CreateSubscription(CreateSubscriptionStmt *stmt)
279280
CatalogUpdateIndexes(rel, tup);
280281
heap_freetuple(tup);
281282

283+
recordDependencyOnOwner(SubscriptionRelationId, subid, owner);
284+
282285
snprintf(originname, sizeof(originname), "pg_%u", subid);
283286
replorigin_create(originname);
284287

@@ -493,6 +496,9 @@ DropSubscription(DropSubscriptionStmt *stmt)
493496

494497
ReleaseSysCache(tup);
495498

499+
/* Clean up dependencies */
500+
deleteSharedDependencyRecordsFor(SubscriptionRelationId, subid, 0);
501+
496502
/* Protect against launcher restarting the worker. */
497503
LWLockAcquire(LogicalRepLauncherLock, LW_EXCLUSIVE);
498504

@@ -530,7 +536,7 @@ DropSubscription(DropSubscriptionStmt *stmt)
530536

531537
if (!walrcv_command(wrconn, cmd.data, &err))
532538
ereport(ERROR,
533-
(errmsg("count not drop the replication slot \"%s\" on publisher",
539+
(errmsg("could not drop the replication slot \"%s\" on publisher",
534540
slotname),
535541
errdetail("The error was: %s", err)));
536542
else

0 commit comments

Comments
 (0)