* Drop an object by OID. Works for most catalogs, if no special processing * is needed. */
| 1295 | * is needed. |
| 1296 | */ |
| 1297 | static void |
| 1298 | DropObjectById(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 | } |
no test coverage detected