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

Function DropObjectById

src/backend/catalog/dependency.c:1297–1354  ·  view source on GitHub ↗

* Drop an object by OID. Works for most catalogs, if no special processing * is needed. */

Source from the content-addressed store, hash-verified

1295 * is needed.
1296 */
1297static void
1298DropObjectById(const ObjectAddress *object)
1299{
1300 int cacheId;
1301 Relation rel;
1302 HeapTuple tup;
1303
1304 /*
1305 * GPDB_14_MERGE_FIXME: specific for GPDB's pg_stat_last_* tables.
1306 * TODO: check more objects as api changed.
1307 */
1308 if ((Gp_role == GP_ROLE_DISPATCH) && (OCLASS_TRANSFORM == getObjectClass(object)))
1309 MetaTrackDropObject(TransformRelationId, object->objectId);
1310
1311 cacheId = get_object_catcache_oid(object->classId);
1312
1313 rel = table_open(object->classId, RowExclusiveLock);
1314
1315 /*
1316 * Use the system cache for the oid column, if one exists.
1317 */
1318 if (cacheId >= 0)
1319 {
1320 tup = SearchSysCache1(cacheId, ObjectIdGetDatum(object->objectId));
1321 if (!HeapTupleIsValid(tup))
1322 elog(ERROR, "cache lookup failed for %s %u",
1323 get_object_class_descr(object->classId), object->objectId);
1324
1325 CatalogTupleDelete(rel, &tup->t_self);
1326
1327 ReleaseSysCache(tup);
1328 }
1329 else
1330 {
1331 ScanKeyData skey[1];
1332 SysScanDesc scan;
1333
1334 ScanKeyInit(&skey[0],
1335 get_object_attnum_oid(object->classId),
1336 BTEqualStrategyNumber, F_OIDEQ,
1337 ObjectIdGetDatum(object->objectId));
1338
1339 scan = systable_beginscan(rel, get_object_oid_index(object->classId), true,
1340 NULL, 1, skey);
1341
1342 /* we expect exactly one match */
1343 tup = systable_getnext(scan);
1344 if (!HeapTupleIsValid(tup))
1345 elog(ERROR, "could not find tuple for %s %u",
1346 get_object_class_descr(object->classId), object->objectId);
1347
1348 CatalogTupleDelete(rel, &tup->t_self);
1349
1350 systable_endscan(scan);
1351 }
1352
1353 table_close(rel, RowExclusiveLock);
1354}

Callers 1

doDeletionFunction · 0.85

Calls 15

getObjectClassFunction · 0.85
MetaTrackDropObjectFunction · 0.85
get_object_catcache_oidFunction · 0.85
table_openFunction · 0.85
SearchSysCache1Function · 0.85
ObjectIdGetDatumFunction · 0.85
get_object_class_descrFunction · 0.85
CatalogTupleDeleteFunction · 0.85
ReleaseSysCacheFunction · 0.85
ScanKeyInitFunction · 0.85
get_object_attnum_oidFunction · 0.85
systable_beginscanFunction · 0.85

Tested by

no test coverage detected