Re: tablecmds: clarify recurse vs recusing - Mailing list pgsql-hackers

From Tom Lane
Subject Re: tablecmds: clarify recurse vs recusing
Date
Msg-id 1734390.1768939652@sss.pgh.pa.us
Whole thread Raw
In response to Re: tablecmds: clarify recurse vs recusing  (Chao Li <li.evan.chao@gmail.com>)
Responses Re: tablecmds: clarify recurse vs recusing
List pgsql-hackers
Chao Li <li.evan.chao@gmail.com> writes:
> Enhancing the header comments also helps here.
> PSA v2:

I had something more like the attached in mind.  I'm not generally
a fan of documenting only some of the arguments of a function, so
I don't care for the way you handled the issue for other functions
in tablecmds.c either.  We can either assume that people read
ATPrepCmd's comment and can extrapolate to the other functions,
or we can do something similar to this for all of them.

I do agree with your 0002, but I see no point in pushing that
separately.

            regards, tom lane

diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index f976c0e5c7e..fcdb81dd4ea 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -4901,8 +4901,22 @@ ATController(AlterTableStmt *parsetree,
  * Traffic cop for ALTER TABLE Phase 1 operations, including simple
  * recursion and permission checks.
  *
- * Caller must have acquired appropriate lock type on relation already.
+ * *wqueue: resulting AlteredTableInfo structs are added to this list
+ * rel: the relation we are currently considering
+ * cmd: the ALTER TABLE subcommand we are currently considering
+ * recurse: true to recurse to child tables of rel (including partitions)
+ * recursing: true if already recursing (rel is a descendant of original table)
+ * lockmode: lock level held on rel, and to be acquired on children
+ * context: context passed down from ProcessUtility, or NULL if none
+ *
+ * At top level, recurse is true unless the command specified ONLY.
+ * Internally, it can be true if we are descending the inheritance tree
+ * on-the-fly, or false if we already expanded the tree at an outer level
+ * (see ATSimpleRecursion).
+ *
+ * Caller must have acquired lockmode on rel already.
  * This lock should be held until commit.
+ * If we recurse, the same lockmode will be acquired on child tables.
  */
 static void
 ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,

pgsql-hackers by date:

Previous
From: "David G. Johnston"
Date:
Subject: Can we remove support for standard_conforming_strings = off yet?
Next
From: Ilia Evdokimov
Date:
Subject: Re: Optional skipping of unchanged relations during ANALYZE?