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

Function sepgsql_relation_drop

contrib/sepgsql/relation.c:415–516  ·  view source on GitHub ↗

* sepgsql_relation_drop * * It checks privileges to drop the supplied relation. */

Source from the content-addressed store, hash-verified

413 * It checks privileges to drop the supplied relation.
414 */
415void
416sepgsql_relation_drop(Oid relOid)
417{
418 ObjectAddress object;
419 char *audit_name;
420 uint16_t tclass = 0;
421 char relkind = get_rel_relkind(relOid);
422
423 switch (relkind)
424 {
425 case RELKIND_RELATION:
426 case RELKIND_PARTITIONED_TABLE:
427 tclass = SEPG_CLASS_DB_TABLE;
428 break;
429 case RELKIND_SEQUENCE:
430 tclass = SEPG_CLASS_DB_SEQUENCE;
431 break;
432 case RELKIND_VIEW:
433 tclass = SEPG_CLASS_DB_VIEW;
434 break;
435 case RELKIND_INDEX:
436 /* ignore indexes on toast tables */
437 if (get_rel_namespace(relOid) == PG_TOAST_NAMESPACE)
438 return;
439 /* other indexes are handled specially below; no need for tclass */
440 break;
441 default:
442 /* ignore other relkinds */
443 return;
444 }
445
446 /*
447 * check db_schema:{remove_name} permission
448 */
449 object.classId = NamespaceRelationId;
450 object.objectId = get_rel_namespace(relOid);
451 object.objectSubId = 0;
452 audit_name = getObjectIdentity(&object, false);
453
454 sepgsql_avc_check_perms(&object,
455 SEPG_CLASS_DB_SCHEMA,
456 SEPG_DB_SCHEMA__REMOVE_NAME,
457 audit_name,
458 true);
459 pfree(audit_name);
460
461 /* deal with indexes specially */
462 if (relkind == RELKIND_INDEX)
463 {
464 sepgsql_index_modify(relOid);
465 return;
466 }
467
468 /*
469 * check db_table/sequence/view:{drop} permission
470 */
471 object.classId = RelationRelationId;
472 object.objectId = relOid;

Callers 1

sepgsql_object_accessFunction · 0.85

Calls 8

get_rel_relkindFunction · 0.85
get_rel_namespaceFunction · 0.85
getObjectIdentityFunction · 0.85
sepgsql_avc_check_permsFunction · 0.85
sepgsql_index_modifyFunction · 0.85
ObjectIdGetDatumFunction · 0.85
ReleaseCatCacheListFunction · 0.85
pfreeFunction · 0.50

Tested by

no test coverage detected