MCPcopy Create free account
hub / github.com/apache/cloudberry / DropSubscription

Function DropSubscription

src/backend/commands/subscriptioncmds.c:1108–1389  ·  view source on GitHub ↗

* Drop a subscription */

Source from the content-addressed store, hash-verified

1106 * Drop a subscription
1107 */
1108void
1109DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel)
1110{
1111 Relation rel;
1112 ObjectAddress myself;
1113 HeapTuple tup;
1114 Oid subid;
1115 Datum datum;
1116 bool isnull;
1117 char *subname;
1118 char *conninfo;
1119 char *slotname;
1120 List *subworkers;
1121 ListCell *lc;
1122 char originname[NAMEDATALEN];
1123 char *err = NULL;
1124 WalReceiverConn *wrconn;
1125 Form_pg_subscription form;
1126 List *rstates;
1127
1128 /*
1129 * Lock pg_subscription with AccessExclusiveLock to ensure that the
1130 * launcher doesn't restart new worker during dropping the subscription
1131 */
1132 rel = table_open(SubscriptionRelationId, AccessExclusiveLock);
1133
1134 tup = SearchSysCache2(SUBSCRIPTIONNAME, MyDatabaseId,
1135 CStringGetDatum(stmt->subname));
1136
1137 if (!HeapTupleIsValid(tup))
1138 {
1139 table_close(rel, NoLock);
1140
1141 if (!stmt->missing_ok)
1142 ereport(ERROR,
1143 (errcode(ERRCODE_UNDEFINED_OBJECT),
1144 errmsg("subscription \"%s\" does not exist",
1145 stmt->subname)));
1146 else
1147 ereport(NOTICE,
1148 (errmsg("subscription \"%s\" does not exist, skipping",
1149 stmt->subname)));
1150
1151 return;
1152 }
1153
1154 form = (Form_pg_subscription) GETSTRUCT(tup);
1155 subid = form->oid;
1156
1157 /* must be owner */
1158 if (!pg_subscription_ownercheck(subid, GetUserId()))
1159 aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_SUBSCRIPTION,
1160 stmt->subname);
1161
1162 /* DROP hook for the subscription being removed */
1163 InvokeObjectDropHook(SubscriptionRelationId, subid, 0);
1164
1165 /*

Callers 1

ProcessUtilitySlowFunction · 0.85

Calls 15

table_openFunction · 0.85
SearchSysCache2Function · 0.85
CStringGetDatumFunction · 0.85
table_closeFunction · 0.85
GetUserIdFunction · 0.85
aclcheck_errorFunction · 0.85
LockSharedObjectFunction · 0.85
SysCacheGetAttrFunction · 0.85
DatumGetNameFunction · 0.85

Tested by

no test coverage detected