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

Function ATSimpleRecursion

src/backend/commands/tablecmds.c:7949–7985  ·  view source on GitHub ↗

* ATSimpleRecursion * * Simple table recursion sufficient for most ALTER TABLE operations. * All direct and indirect children are processed in an unspecified order. * Note that if a child inherits from the original table via multiple * inheritance paths, it will be visited just once. */

Source from the content-addressed store, hash-verified

7947 * inheritance paths, it will be visited just once.
7948 */
7949static void
7950ATSimpleRecursion(List **wqueue, Relation rel,
7951 AlterTableCmd *cmd, bool recurse, LOCKMODE lockmode,
7952 AlterTableUtilityContext *context)
7953{
7954 /*
7955 * Propagate to children, if desired and if there are (or might be) any
7956 * children.
7957 */
7958 if (recurse && rel->rd_rel->relhassubclass)
7959 {
7960 Oid relid = RelationGetRelid(rel);
7961 ListCell *child;
7962 List *children;
7963
7964 children = find_all_inheritors(relid, lockmode, NULL);
7965
7966 /*
7967 * find_all_inheritors does the recursive search of the inheritance
7968 * hierarchy, so all we have to do is process all of the relids in the
7969 * list that it returns.
7970 */
7971 foreach(child, children)
7972 {
7973 Oid childrelid = lfirst_oid(child);
7974 Relation childrel;
7975
7976 if (childrelid == relid)
7977 continue;
7978 /* find_all_inheritors already got lock */
7979 childrel = relation_open(childrelid, NoLock);
7980 CheckTableNotInUse(childrel, "ALTER TABLE");
7981 ATPrepCmd(wqueue, childrel, cmd, false, true, lockmode, context);
7982 relation_close(childrel, NoLock);
7983 }
7984 }
7985}
7986
7987/*
7988 * Obtain list of partitions of the given table, locking them all at the given

Callers 2

ATPrepCmdFunction · 0.85
ATPrepSetNotNullFunction · 0.85

Calls 6

find_all_inheritorsFunction · 0.85
relation_openFunction · 0.85
CheckTableNotInUseFunction · 0.85
ATPrepCmdFunction · 0.85
relation_closeFunction · 0.85
foreachFunction · 0.50

Tested by

no test coverage detected