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

Function ATExecDropInherit

src/backend/commands/tablecmds.c:17438–17480  ·  view source on GitHub ↗

* ALTER TABLE NO INHERIT * * Return value is the address of the relation that is no longer parent. */

Source from the content-addressed store, hash-verified

17436 * Return value is the address of the relation that is no longer parent.
17437 */
17438static ObjectAddress
17439ATExecDropInherit(Relation rel, RangeVar *parent, LOCKMODE lockmode)
17440{
17441 ObjectAddress address;
17442 Relation parent_rel;
17443
17444 if (rel->rd_rel->relispartition)
17445 ereport(ERROR,
17446 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
17447 errmsg("cannot change inheritance of a partition")));
17448
17449 /*
17450 * AccessShareLock on the parent is probably enough, seeing that DROP
17451 * TABLE doesn't lock parent tables at all. We need some lock since we'll
17452 * be inspecting the parent's schema.
17453 */
17454 parent_rel = table_openrv(parent, AccessShareLock);
17455
17456 /*
17457 * We don't bother to check ownership of the parent table --- ownership of
17458 * the child is presumed enough rights.
17459 */
17460
17461 /* Off to RemoveInheritance() where most of the work happens */
17462 RemoveInheritance(rel, parent_rel, false);
17463
17464 ObjectAddressSet(address, RelationRelationId,
17465 RelationGetRelid(parent_rel));
17466
17467 /* keep our lock on the parent relation until commit */
17468 table_close(parent_rel, NoLock);
17469
17470 /* MPP-6929: metadata tracking */
17471 if ((Gp_role == GP_ROLE_DISPATCH)
17472 && MetaTrackValidKindNsp(rel->rd_rel))
17473 MetaTrackUpdObject(RelationRelationId,
17474 RelationGetRelid(rel),
17475 GetUserId(),
17476 "ALTER", "NO INHERIT"
17477 );
17478
17479 return address;
17480}
17481
17482/*
17483 * MarkInheritDetached

Callers 1

ATExecCmdFunction · 0.85

Calls 8

table_openrvFunction · 0.85
RemoveInheritanceFunction · 0.85
table_closeFunction · 0.85
MetaTrackValidKindNspFunction · 0.85
MetaTrackUpdObjectFunction · 0.85
GetUserIdFunction · 0.85
errcodeFunction · 0.50
errmsgFunction · 0.50

Tested by

no test coverage detected