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

Function ATCheckPartitionsNotInUse

src/backend/commands/tablecmds.c:7994–8015  ·  view source on GitHub ↗

* Obtain list of partitions of the given table, locking them all at the given * lockmode and ensuring that they all pass CheckTableNotInUse. * * This function is a no-op if the given relation is not a partitioned table; * in particular, nothing is done if it's a legacy inheritance parent. */

Source from the content-addressed store, hash-verified

7992 * in particular, nothing is done if it's a legacy inheritance parent.
7993 */
7994static void
7995ATCheckPartitionsNotInUse(Relation rel, LOCKMODE lockmode)
7996{
7997 if (rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
7998 {
7999 List *inh;
8000 ListCell *cell;
8001
8002 inh = find_all_inheritors(RelationGetRelid(rel), lockmode, NULL);
8003 /* first element is the parent rel; must ignore it */
8004 for_each_from(cell, inh, 1)
8005 {
8006 Relation childrel;
8007
8008 /* find_all_inheritors already got lock */
8009 childrel = table_open(lfirst_oid(cell), NoLock);
8010 CheckTableNotInUse(childrel, "ALTER TABLE");
8011 table_close(childrel, NoLock);
8012 }
8013 list_free(inh);
8014 }
8015}
8016
8017/*
8018 * ATTypedTableRecursion

Callers 1

ATPrepCmdFunction · 0.85

Calls 5

find_all_inheritorsFunction · 0.85
table_openFunction · 0.85
CheckTableNotInUseFunction · 0.85
table_closeFunction · 0.85
list_freeFunction · 0.50

Tested by

no test coverage detected