@@ -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