Re: tablecmds: clarify recurse vs recusing

From: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Eisentraut <peter(at)eisentraut(dot)org>, Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: tablecmds: clarify recurse vs recusing
Date: 2026-01-20 03:45:50
Message-ID: CAEoWx2=QnOBUCuTg4rt7n0FjyvhBfztWMffSdObGCbGrz2tg6w@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Jan 20, 2026, at 00:14, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

Peter Eisentraut <peter(at)eisentraut(dot)org> writes:

On 19.01.26 08:14, Chao Li wrote:

Many ALTER TABLE-related functions take two boolean parameters,
"recurse" and "recursing", whose names are easy to confuse.

I'm not bothered by this.

To reduce this confusion, I’m proposing to rename "recurse" to
"no_only", which more directly reflects its meaning.

This seems worse. Especially since no_only is almost a double negative.

Yeah, I don't find this change an improvement either. I think the
actual problem here is lack of documentation: unlike many other
places, there is next to zero commentary in tablecmds.c about what
all the function parameters are. It would probably help to define
these, along the lines of

* recurse: true if we should recurse to children of this table
* recursing: true if we are already recursing from some parent table

If we fleshed out the header comment for ATPrepCmd and maybe a few
other key functions along these lines, that would make the logic
a good deal more intelligible, I think.

regards, tom lane

Enhancing the header comments also helps here.

PSA v2:

0001 - Adds detailed descriptions in the header comments of ATController()
and ATPrepCmd(). For the other 16 functions that take both “recurse” and
“recursing”, I only added brief references to those header comments.

0002 - While working on 0001, I noticed that the header comment of
addFkConstraint() explains all parameters except “is_internal”. I added a
line for “is_internal”, so that the comment fully reflects the function
signature. This change is really trivial and can be squashed into 0001 if
preferred.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/

Attachment Content-Type Size
v2-0001-tablecmds-clarify-recurse-recursing-semantics-in-.patch application/octet-stream 9.5 KB
v2-0002-tablecmds-complete-parameter-documentation-for-ad.patch application/octet-stream 1.2 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Rob Moore 2026-01-20 03:46:23 Re: Proposal: Add backup start time to pg_stat_progress_basebackup
Previous Message Henson Choi 2026-01-20 03:29:14 Re: Row pattern recognition