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

Function EventTriggerSQLDropAddObject

src/backend/commands/event_trigger.c:1200–1311  ·  view source on GitHub ↗

* Register one object as being dropped by the current command. */

Source from the content-addressed store, hash-verified

1198 * Register one object as being dropped by the current command.
1199 */
1200void
1201EventTriggerSQLDropAddObject(const ObjectAddress *object, bool original, bool normal)
1202{
1203 SQLDropObject *obj;
1204 MemoryContext oldcxt;
1205
1206 if (!currentEventTriggerState)
1207 return;
1208
1209 Assert(EventTriggerSupportsObjectClass(getObjectClass(object)));
1210
1211 /* don't report temp schemas except my own */
1212 if (object->classId == NamespaceRelationId &&
1213 (isAnyTempNamespace(object->objectId) &&
1214 !isTempNamespace(object->objectId)))
1215 return;
1216
1217 oldcxt = MemoryContextSwitchTo(currentEventTriggerState->cxt);
1218
1219 obj = palloc0(sizeof(SQLDropObject));
1220 obj->address = *object;
1221 obj->original = original;
1222 obj->normal = normal;
1223
1224 /*
1225 * Obtain schema names from the object's catalog tuple, if one exists;
1226 * this lets us skip objects in temp schemas. We trust that
1227 * ObjectProperty contains all object classes that can be
1228 * schema-qualified.
1229 */
1230 if (is_objectclass_supported(object->classId))
1231 {
1232 Relation catalog;
1233 HeapTuple tuple;
1234
1235 catalog = table_open(obj->address.classId, AccessShareLock);
1236 tuple = get_catalog_object_by_oid(catalog,
1237 get_object_attnum_oid(object->classId),
1238 obj->address.objectId);
1239
1240 if (tuple)
1241 {
1242 AttrNumber attnum;
1243 Datum datum;
1244 bool isnull;
1245
1246 attnum = get_object_attnum_namespace(obj->address.classId);
1247 if (attnum != InvalidAttrNumber)
1248 {
1249 datum = heap_getattr(tuple, attnum,
1250 RelationGetDescr(catalog), &isnull);
1251 if (!isnull)
1252 {
1253 Oid namespaceId;
1254
1255 namespaceId = DatumGetObjectId(datum);
1256 /* temp objects are only reported if they are my own */
1257 if (isTempNamespace(namespaceId))

Callers 2

DropSubscriptionFunction · 0.85
deleteObjectsInListFunction · 0.85

Calls 15

getObjectClassFunction · 0.85
isAnyTempNamespaceFunction · 0.85
isTempNamespaceFunction · 0.85
MemoryContextSwitchToFunction · 0.85
is_objectclass_supportedFunction · 0.85
table_openFunction · 0.85
get_object_attnum_oidFunction · 0.85
heap_getattrFunction · 0.85
DatumGetObjectIdFunction · 0.85

Tested by

no test coverage detected