public inbox for [email protected]
help / color / mirror / Atom feed[PATCH v5 1/3] Test for snapshot too old and wal_level=minimal
5+ messages / 4 participants
[nested] [flat]
* [PATCH v5 1/3] Test for snapshot too old and wal_level=minimal
@ 2021-01-20 11:57 Kyotaro Horiguchi <[email protected]>
0 siblings, 0 replies; 5+ messages in thread
From: Kyotaro Horiguchi @ 2021-01-20 11:57 UTC (permalink / raw)
---
src/test/modules/snapshot_too_old/Makefile | 12 ++++-
.../expected/sto_wal_optimized.out | 24 ++++++++++
.../input_sto/sto_wal_optimized.spec | 44 +++++++++++++++++++
src/test/modules/snapshot_too_old/sto.conf | 3 ++
4 files changed, 82 insertions(+), 1 deletion(-)
create mode 100644 src/test/modules/snapshot_too_old/expected/sto_wal_optimized.out
create mode 100644 src/test/modules/snapshot_too_old/input_sto/sto_wal_optimized.spec
diff --git a/src/test/modules/snapshot_too_old/Makefile b/src/test/modules/snapshot_too_old/Makefile
index dfb4537f63..1e0b0b6efc 100644
--- a/src/test/modules/snapshot_too_old/Makefile
+++ b/src/test/modules/snapshot_too_old/Makefile
@@ -4,7 +4,7 @@
# we have to clean those result files explicitly
EXTRA_CLEAN = $(pg_regress_clean_files)
-ISOLATION = sto_using_cursor sto_using_select sto_using_hash_index
+ISOLATION = sto_using_cursor sto_using_select sto_using_hash_index sto_wal_optimized
ISOLATION_OPTS = --temp-config $(top_srcdir)/src/test/modules/snapshot_too_old/sto.conf
# Disabled because these tests require "old_snapshot_threshold" >= 0, which
@@ -22,6 +22,16 @@ include $(top_builddir)/src/Makefile.global
include $(top_srcdir)/contrib/contrib-global.mk
endif
+.PHONY: tablespace-setup specfile-setup
+tablespace-setup:
+ rm -rf ./testtablespace
+ mkdir ./testtablespace
+
+specfile-setup: input_sto/*.spec
+ sed 's!@srcdir@!$(realpath $(top_srcdir))!g' $? > specs/$(notdir $?)
+
+check: tablespace-setup specfile-setup
+
# But it can nonetheless be very helpful to run tests on preexisting
# installation, allow to do so, but only if requested explicitly.
installcheck-force:
diff --git a/src/test/modules/snapshot_too_old/expected/sto_wal_optimized.out b/src/test/modules/snapshot_too_old/expected/sto_wal_optimized.out
new file mode 100644
index 0000000000..4038d0a713
--- /dev/null
+++ b/src/test/modules/snapshot_too_old/expected/sto_wal_optimized.out
@@ -0,0 +1,24 @@
+Parsed test spec with 3 sessions
+
+starting permutation: s1a1 s1a2 s2a1 s2a2 s1b1 a3-0 a3-1 s3-2 s3-3 s3-4 s2b1
+step s1a1: BEGIN;
+step s1a2: DELETE FROM t;
+step s2a1: BEGIN ISOLATION LEVEL REPEATABLE READ;
+step s2a2: SELECT 1;
+?column?
+
+1
+step s1b1: COMMIT;
+step a3-0: SELECT setting, pg_sleep(6) FROM pg_settings WHERE name = 'old_snapshot_threshold';
+setting pg_sleep
+
+0
+step a3-1: BEGIN;
+step s3-2: ALTER TABLE t SET TABLESPACE tsp1;
+step s3-3: SELECT count(*) FROM t;
+count
+
+0
+step s3-4: COMMIT;
+step s2b1: SELECT count(*) FROM t;
+ERROR: snapshot too old
diff --git a/src/test/modules/snapshot_too_old/input_sto/sto_wal_optimized.spec b/src/test/modules/snapshot_too_old/input_sto/sto_wal_optimized.spec
new file mode 100644
index 0000000000..02adb50581
--- /dev/null
+++ b/src/test/modules/snapshot_too_old/input_sto/sto_wal_optimized.spec
@@ -0,0 +1,44 @@
+# This test provokes a "snapshot too old" error
+#
+# The sleep is needed because with a threshold of zero a statement could error
+# on changes it made. With more normal settings no external delay is needed,
+# but we don't want these tests to run long enough to see that, since
+# granularity is in minutes.
+#
+# Since results depend on the value of old_snapshot_threshold, sneak that into
+# the line generated by the sleep, so that a surprising values isn't so hard
+# to identify.
+
+setup
+{
+ CREATE TABLESPACE tsp1 LOCATION '@srcdir@/src/test/modules/snapshot_too_old/testtablespace';
+}
+
+setup
+{
+ CREATE TABLE t AS SELECT a FROM generate_series(0, 9) a;
+}
+
+session "s1"
+step "s1a1" { BEGIN; }
+step "s1a2" { DELETE FROM t; }
+step "s1b1" { COMMIT; }
+
+session "s2"
+# s2a : take snapshot
+step "s2a1" { BEGIN ISOLATION LEVEL REPEATABLE READ; }
+step "s2a2" { SELECT 1; }
+# s2b : wanted "snapshot too old"
+step "s2b1" { SELECT count(*) FROM t; }
+
+session "s3"
+# s3-0 : wait for snapshot is expired
+step "a3-0" { SELECT setting, pg_sleep(6) FROM pg_settings WHERE name = 'old_snapshot_threshold'; }
+step "a3-1" { BEGIN; }
+# s3-2 : start skipping WAL when wal_level=minimal
+step "s3-2" { ALTER TABLE t SET TABLESPACE tsp1; }
+# s3-3 : early pruning. w/o WAL and LSN changes when wal_level=minimal
+step "s3-3" { SELECT count(*) FROM t; }
+step "s3-4" { COMMIT; }
+
+permutation "s1a1" "s1a2" "s2a1" "s2a2" "s1b1" "a3-0" "a3-1" "s3-2" "s3-3" "s3-4" "s2b1"
diff --git a/src/test/modules/snapshot_too_old/sto.conf b/src/test/modules/snapshot_too_old/sto.conf
index 7eeaeeb0dc..09887fc725 100644
--- a/src/test/modules/snapshot_too_old/sto.conf
+++ b/src/test/modules/snapshot_too_old/sto.conf
@@ -1,2 +1,5 @@
autovacuum = off
old_snapshot_threshold = 0
+
+# needed when setting wal_level=minimal
+wal_skip_threshold = 0
--
2.27.0
----Next_Part(Thu_Jan_21_00_28_44_2021_003)--
Content-Type: Text/X-Patch; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="v5-0002-Do-not-use-RelationNeedsWAL-to-identify-relation-.patch"
^ permalink raw reply [nested|flat] 5+ messages in thread
* tablecmds: clarify recurse vs recusing
@ 2026-01-19 07:14 Chao Li <[email protected]>
0 siblings, 1 reply; 5+ messages in thread
From: Chao Li @ 2026-01-19 07:14 UTC (permalink / raw)
To: Postgres hackers <[email protected]>
Hi Hacker,
Many ALTER TABLE-related functions take two boolean parameters, "recurse"
and "recursing", whose names are easy to confuse. For example:
```
/*
* ALTER TABLE ALTER COLUMN DROP IDENTITY
*
* Return the address of the affected column.
*/
static ObjectAddress
ATExecDropIdentity(Relation rel, const char *colName, bool missing_ok,
LOCKMODE lockmode,
bool recurse, bool recursing)
```
The "recurse" parameter actually indicates whether ONLY was *not* specified
in the ALTER TABLE command. It’s supposed to affect both inherited tables
and partitioned tables.
In contrast, "recursing" is an internal indicator that only affects
inherited tables.
To reduce this confusion, I’m proposing to rename "recurse" to "no_only",
which more directly reflects its meaning.
In this patch set:
* 0001 - only renames “recurse” to “no_only” together with minimum comment
updates.
* 0002 - performs a small mechanical refactoring, replacing “if (no_only)
cmd->no_only = true” to “cmd->no_only = no_only”.
Related patches are [1], [2] and [3]:
[1]
https://postgr.es/m/CAEoWx2nJ71hy8R614HQr7vQhkBReO9AANPODPg0aSQs74eOdLQ@mail.gmail.com
[2]
https://postgr.es/m/CAEoWx2=mYhCfsnHaN96Qqwq5b0GVS2YgO3zpVqPPRd_iO52wRw@mail.gmail.com
[3]
https://postgr.es/m/CAEoWx2=SLga-xH09Cq_PAvsHhQHrBK+V0vF821JKgzS=Bm0haA@mail.gmail.com
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/
Attachments:
[application/octet-stream] v1-0002-tablecmds-simplify-propagation-of-no_only-flag.patch (5.0K, ../../CAEoWx2n9E6_zxPbqwMpaPuC1C_p4b3y635SjiDuCPSVm8GBjsA@mail.gmail.com/3-v1-0002-tablecmds-simplify-propagation-of-no_only-flag.patch)
download | inline diff:
From 55b95be987d0969c7346f23afa0d1b7ad290140e Mon Sep 17 00:00:00 2001
From: "Chao Li (Evan)" <[email protected]>
Date: Mon, 19 Jan 2026 14:55:16 +0800
Subject: [PATCH v1 2/2] tablecmds: simplify propagation of no_only flag
Several ALTER TABLE preparation paths conditionally copied the no_only
flag using:
if (no_only)
cmd->no_only = true;
This pattern is redundant and obscures the fact that cmd->no_only is
meant to directly reflect the parsed ONLY semantics.
Assign cmd->no_only unconditionally instead:
cmd->no_only = no_only;
This is a mechanical cleanup with no behavior change.
Author: Chao Li <[email protected]>
---
src/backend/commands/tablecmds.c | 33 +++++++++++---------------------
1 file changed, 11 insertions(+), 22 deletions(-)
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 4000fd0c923..11f292a8c36 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -4990,8 +4990,7 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
ATT_TABLE | ATT_PARTITIONED_TABLE | ATT_VIEW |
ATT_FOREIGN_TABLE);
/* Set up recursion for phase 2; no other prep needed */
- if (no_only)
- cmd->no_only = true;
+ cmd->no_only = no_only;
pass = AT_PASS_ADD_OTHERCONSTR;
break;
case AT_SetIdentity:
@@ -4999,8 +4998,7 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
ATT_TABLE | ATT_PARTITIONED_TABLE | ATT_VIEW |
ATT_FOREIGN_TABLE);
/* Set up recursion for phase 2; no other prep needed */
- if (no_only)
- cmd->no_only = true;
+ cmd->no_only = no_only;
/* This should run after AddIdentity, so do it in MISC pass */
pass = AT_PASS_MISC;
break;
@@ -5009,24 +5007,21 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
ATT_TABLE | ATT_PARTITIONED_TABLE | ATT_VIEW |
ATT_FOREIGN_TABLE);
/* Set up recursion for phase 2; no other prep needed */
- if (no_only)
- cmd->no_only = true;
+ cmd->no_only = no_only;
pass = AT_PASS_DROP;
break;
case AT_DropNotNull: /* ALTER COLUMN DROP NOT NULL */
ATSimplePermissions(cmd->subtype, rel,
ATT_TABLE | ATT_PARTITIONED_TABLE | ATT_FOREIGN_TABLE);
/* Set up recursion for phase 2; no other prep needed */
- if (no_only)
- cmd->no_only = true;
+ cmd->no_only = no_only;
pass = AT_PASS_DROP;
break;
case AT_SetNotNull: /* ALTER COLUMN SET NOT NULL */
ATSimplePermissions(cmd->subtype, rel,
ATT_TABLE | ATT_PARTITIONED_TABLE | ATT_FOREIGN_TABLE);
/* Set up recursion for phase 2; no other prep needed */
- if (no_only)
- cmd->no_only = true;
+ cmd->no_only = no_only;
pass = AT_PASS_COL_ATTRS;
break;
case AT_SetExpression: /* ALTER COLUMN SET EXPRESSION */
@@ -5112,8 +5107,7 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
ATCheckPartitionsNotInUse(rel, lockmode);
/* Other recursion occurs during execution phase */
/* No command-specific prep needed except saving recurse flag */
- if (no_only)
- cmd->no_only = true;
+ cmd->no_only = no_only;
pass = AT_PASS_DROP;
break;
case AT_AlterColumnType: /* ALTER COLUMN TYPE */
@@ -5211,8 +5205,7 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
ATSimplePermissions(cmd->subtype, rel,
ATT_TABLE | ATT_PARTITIONED_TABLE);
/* Recursion occurs during execution phase */
- if (no_only)
- cmd->no_only = true;
+ cmd->no_only = no_only;
pass = AT_PASS_MISC;
break;
case AT_ValidateConstraint: /* VALIDATE CONSTRAINT */
@@ -5220,8 +5213,7 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
ATT_TABLE | ATT_PARTITIONED_TABLE | ATT_FOREIGN_TABLE);
/* Recursion occurs during execution phase */
/* No command-specific prep needed except saving recurse flag */
- if (no_only)
- cmd->no_only = true;
+ cmd->no_only = no_only;
pass = AT_PASS_MISC;
break;
case AT_ReplicaIdentity: /* REPLICA IDENTITY ... */
@@ -5242,8 +5234,7 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
ATSimplePermissions(cmd->subtype, rel,
ATT_TABLE | ATT_PARTITIONED_TABLE | ATT_FOREIGN_TABLE);
/* Set up recursion for phase 2; no other prep needed */
- if (no_only)
- cmd->no_only = true;
+ cmd->no_only = no_only;
pass = AT_PASS_MISC;
break;
case AT_EnableRule: /* ENABLE/DISABLE RULE variants */
@@ -5796,8 +5787,7 @@ ATParseTransformCmd(List **wqueue, AlteredTableInfo *tab, Relation rel,
break;
case AT_AddConstraint:
/* Recursion occurs during execution phase */
- if (no_only)
- cmd2->no_only = true;
+ cmd2->no_only = no_only;
switch (castNode(Constraint, cmd2->def)->contype)
{
case CONSTR_NOTNULL:
@@ -9295,8 +9285,7 @@ ATPrepDropColumn(List **wqueue, Relation rel, bool no_only, bool recursing,
if (rel->rd_rel->relkind == RELKIND_COMPOSITE_TYPE)
ATTypedTableRecursion(wqueue, rel, cmd, lockmode, context);
- if (no_only)
- cmd->no_only = true;
+ cmd->no_only = no_only;
}
/*
--
2.39.5 (Apple Git-154)
[application/octet-stream] v1-0001-tablecmds-rename-recurse-to-no_only.patch (59.8K, ../../CAEoWx2n9E6_zxPbqwMpaPuC1C_p4b3y635SjiDuCPSVm8GBjsA@mail.gmail.com/4-v1-0001-tablecmds-rename-recurse-to-no_only.patch)
download | inline diff:
From c97117fe03024a196b40f051d864b5b9fc57090a Mon Sep 17 00:00:00 2001
From: "Chao Li (Evan)" <[email protected]>
Date: Mon, 19 Jan 2026 08:02:47 +0800
Subject: [PATCH v1 1/2] tablecmds: rename recurse to no_only
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Many ALTER TABLE–related functions take two boolean parameters,
"recurse" and "recursing", whose names are easy to confuse.
The "recurse" flag actually indicates whether ONLY was *not* specified
in the ALTER TABLE command. It affects both inherited tables and
partitioned tables.
In contrast, "recursing" is an internal indicator that only affects
inherited tables.
To reduce this confusion, rename "recurse" to "no_only", which more
directly reflects its meaning.
No behavior change.
Author: Chao Li <[email protected]>
---
src/backend/commands/tablecmds.c | 371 ++++++++++++++++---------------
src/include/nodes/parsenodes.h | 2 +-
2 files changed, 187 insertions(+), 186 deletions(-)
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index f976c0e5c7e..4000fd0c923 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -392,10 +392,10 @@ static void AlterSeqNamespaces(Relation classRel, Relation rel,
LOCKMODE lockmode);
static ObjectAddress ATExecAlterConstraint(List **wqueue, Relation rel,
ATAlterConstraint *cmdcon,
- bool recurse, LOCKMODE lockmode);
+ bool no_only, LOCKMODE lockmode);
static bool ATExecAlterConstraintInternal(List **wqueue, ATAlterConstraint *cmdcon, Relation conrel,
Relation tgrel, Relation rel, HeapTuple contuple,
- bool recurse, LOCKMODE lockmode);
+ bool no_only, LOCKMODE lockmode);
static bool ATExecAlterConstrEnforceability(List **wqueue, ATAlterConstraint *cmdcon,
Relation conrel, Relation tgrel,
Oid fkrelid, Oid pkrelid,
@@ -406,7 +406,7 @@ static bool ATExecAlterConstrEnforceability(List **wqueue, ATAlterConstraint *cm
Oid ReferencingParentUpdTrigger);
static bool ATExecAlterConstrDeferrability(List **wqueue, ATAlterConstraint *cmdcon,
Relation conrel, Relation tgrel, Relation rel,
- HeapTuple contuple, bool recurse,
+ HeapTuple contuple, bool no_only,
List **otherrelids, LOCKMODE lockmode);
static bool ATExecAlterConstrInheritability(List **wqueue, ATAlterConstraint *cmdcon,
Relation conrel, Relation rel,
@@ -424,20 +424,20 @@ static void AlterConstrEnforceabilityRecurse(List **wqueue, ATAlterConstraint *c
Oid ReferencingParentUpdTrigger);
static void AlterConstrDeferrabilityRecurse(List **wqueue, ATAlterConstraint *cmdcon,
Relation conrel, Relation tgrel, Relation rel,
- HeapTuple contuple, bool recurse,
+ HeapTuple contuple, bool no_only,
List **otherrelids, LOCKMODE lockmode);
static void AlterConstrUpdateConstraintEntry(ATAlterConstraint *cmdcon, Relation conrel,
HeapTuple contuple);
static ObjectAddress ATExecValidateConstraint(List **wqueue,
Relation rel, char *constrName,
- bool recurse, bool recursing, LOCKMODE lockmode);
+ bool no_only, bool recursing, LOCKMODE lockmode);
static void QueueFKConstraintValidation(List **wqueue, Relation conrel, Relation fkrel,
Oid pkrelid, HeapTuple contuple, LOCKMODE lockmode);
static void QueueCheckConstraintValidation(List **wqueue, Relation conrel, Relation rel,
char *constrName, HeapTuple contuple,
- bool recurse, bool recursing, LOCKMODE lockmode);
+ bool no_only, bool recursing, LOCKMODE lockmode);
static void QueueNNConstraintValidation(List **wqueue, Relation conrel, Relation rel,
- HeapTuple contuple, bool recurse, bool recursing,
+ HeapTuple contuple, bool no_only, bool recursing,
LOCKMODE lockmode);
static int transformColumnNameList(Oid relId, List *colList,
int16 *attnums, Oid *atttypids, Oid *attcollids);
@@ -457,10 +457,10 @@ static void validateForeignKeyConstraint(char *conname,
Oid pkindOid, Oid constraintOid, bool hasperiod);
static void CheckAlterTableIsSafe(Relation rel);
static void ATController(AlterTableStmt *parsetree,
- Relation rel, List *cmds, bool recurse, LOCKMODE lockmode,
+ Relation rel, List *cmds, bool no_only, LOCKMODE lockmode,
AlterTableUtilityContext *context);
static void ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
- bool recurse, bool recursing, LOCKMODE lockmode,
+ bool no_only, bool recursing, LOCKMODE lockmode,
AlterTableUtilityContext *context);
static void ATRewriteCatalogs(List **wqueue, LOCKMODE lockmode,
AlterTableUtilityContext *context);
@@ -469,7 +469,7 @@ static void ATExecCmd(List **wqueue, AlteredTableInfo *tab,
AlterTableUtilityContext *context);
static AlterTableCmd *ATParseTransformCmd(List **wqueue, AlteredTableInfo *tab,
Relation rel, AlterTableCmd *cmd,
- bool recurse, LOCKMODE lockmode,
+ bool no_only, LOCKMODE lockmode,
AlterTablePass cur_pass,
AlterTableUtilityContext *context);
static void ATRewriteTables(AlterTableStmt *parsetree,
@@ -479,7 +479,7 @@ static void ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap);
static AlteredTableInfo *ATGetQueueEntry(List **wqueue, Relation rel);
static void ATSimplePermissions(AlterTableType cmdtype, Relation rel, int allowed_targets);
static void ATSimpleRecursion(List **wqueue, Relation rel,
- AlterTableCmd *cmd, bool recurse, LOCKMODE lockmode,
+ AlterTableCmd *cmd, bool no_only, LOCKMODE lockmode,
AlterTableUtilityContext *context);
static void ATCheckPartitionsNotInUse(Relation rel, LOCKMODE lockmode);
static void ATTypedTableRecursion(List **wqueue, Relation rel, AlterTableCmd *cmd,
@@ -487,25 +487,25 @@ static void ATTypedTableRecursion(List **wqueue, Relation rel, AlterTableCmd *cm
AlterTableUtilityContext *context);
static List *find_typed_table_dependencies(Oid typeOid, const char *typeName,
DropBehavior behavior);
-static void ATPrepAddColumn(List **wqueue, Relation rel, bool recurse, bool recursing,
+static void ATPrepAddColumn(List **wqueue, Relation rel, bool no_only, bool recursing,
bool is_view, AlterTableCmd *cmd, LOCKMODE lockmode,
AlterTableUtilityContext *context);
static ObjectAddress ATExecAddColumn(List **wqueue, AlteredTableInfo *tab,
Relation rel, AlterTableCmd **cmd,
- bool recurse, bool recursing,
+ bool no_only, bool recursing,
LOCKMODE lockmode, AlterTablePass cur_pass,
AlterTableUtilityContext *context);
static bool check_for_column_name_collision(Relation rel, const char *colname,
bool if_not_exists);
static void add_column_datatype_dependency(Oid relid, int32 attnum, Oid typid);
static void add_column_collation_dependency(Oid relid, int32 attnum, Oid collid);
-static ObjectAddress ATExecDropNotNull(Relation rel, const char *colName, bool recurse,
+static ObjectAddress ATExecDropNotNull(Relation rel, const char *colName, bool no_only,
LOCKMODE lockmode);
static void set_attnotnull(List **wqueue, Relation rel, AttrNumber attnum,
bool is_valid, bool queue_validation);
static ObjectAddress ATExecSetNotNull(List **wqueue, Relation rel,
char *conName, char *colName,
- bool recurse, bool recursing,
+ bool no_only, bool recursing,
LOCKMODE lockmode);
static bool NotNullImpliedByRelConstraints(Relation rel, Form_pg_attribute attr);
static bool ConstraintImpliedByRelConstraint(Relation scanrel,
@@ -515,14 +515,14 @@ static ObjectAddress ATExecColumnDefault(Relation rel, const char *colName,
static ObjectAddress ATExecCookedColumnDefault(Relation rel, AttrNumber attnum,
Node *newDefault);
static ObjectAddress ATExecAddIdentity(Relation rel, const char *colName,
- Node *def, LOCKMODE lockmode, bool recurse, bool recursing);
+ Node *def, LOCKMODE lockmode, bool no_only, bool recursing);
static ObjectAddress ATExecSetIdentity(Relation rel, const char *colName,
- Node *def, LOCKMODE lockmode, bool recurse, bool recursing);
+ Node *def, LOCKMODE lockmode, bool no_only, bool recursing);
static ObjectAddress ATExecDropIdentity(Relation rel, const char *colName, bool missing_ok, LOCKMODE lockmode,
- bool recurse, bool recursing);
+ bool no_only, bool recursing);
static ObjectAddress ATExecSetExpression(AlteredTableInfo *tab, Relation rel, const char *colName,
Node *newExpr, LOCKMODE lockmode);
-static void ATPrepDropExpression(Relation rel, AlterTableCmd *cmd, bool recurse, bool recursing, LOCKMODE lockmode);
+static void ATPrepDropExpression(Relation rel, AlterTableCmd *cmd, bool no_only, bool recursing, LOCKMODE lockmode);
static ObjectAddress ATExecDropExpression(Relation rel, const char *colName, bool missing_ok, LOCKMODE lockmode);
static ObjectAddress ATExecSetStatistics(Relation rel, const char *colName, int16 colNum,
Node *newValue, LOCKMODE lockmode);
@@ -530,16 +530,16 @@ static ObjectAddress ATExecSetOptions(Relation rel, const char *colName,
Node *options, bool isReset, LOCKMODE lockmode);
static ObjectAddress ATExecSetStorage(Relation rel, const char *colName,
Node *newValue, LOCKMODE lockmode);
-static void ATPrepDropColumn(List **wqueue, Relation rel, bool recurse, bool recursing,
+static void ATPrepDropColumn(List **wqueue, Relation rel, bool no_only, bool recursing,
AlterTableCmd *cmd, LOCKMODE lockmode,
AlterTableUtilityContext *context);
static ObjectAddress ATExecDropColumn(List **wqueue, Relation rel, const char *colName,
DropBehavior behavior,
- bool recurse, bool recursing,
+ bool no_only, bool recursing,
bool missing_ok, LOCKMODE lockmode,
ObjectAddresses *addrs);
static void ATPrepAddPrimaryKey(List **wqueue, Relation rel, AlterTableCmd *cmd,
- bool recurse, LOCKMODE lockmode,
+ bool no_only, LOCKMODE lockmode,
AlterTableUtilityContext *context);
static void verifyNotNullPKCompatible(HeapTuple tuple, const char *colname);
static ObjectAddress ATExecAddIndex(AlteredTableInfo *tab, Relation rel,
@@ -548,7 +548,7 @@ static ObjectAddress ATExecAddStatistics(AlteredTableInfo *tab, Relation rel,
CreateStatsStmt *stmt, bool is_rebuild, LOCKMODE lockmode);
static ObjectAddress ATExecAddConstraint(List **wqueue,
AlteredTableInfo *tab, Relation rel,
- Constraint *newConstraint, bool recurse, bool is_readd,
+ Constraint *newConstraint, bool no_only, bool is_readd,
LOCKMODE lockmode);
static char *ChooseForeignKeyConstraintNameAddition(List *colnames);
static ObjectAddress ATExecAddIndexConstraint(AlteredTableInfo *tab, Relation rel,
@@ -556,11 +556,11 @@ static ObjectAddress ATExecAddIndexConstraint(AlteredTableInfo *tab, Relation re
static ObjectAddress ATAddCheckNNConstraint(List **wqueue,
AlteredTableInfo *tab, Relation rel,
Constraint *constr,
- bool recurse, bool recursing, bool is_readd,
+ bool no_only, bool recursing, bool is_readd,
LOCKMODE lockmode);
static ObjectAddress ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab,
Relation rel, Constraint *fkconstraint,
- bool recurse, bool recursing,
+ bool no_only, bool recursing,
LOCKMODE lockmode);
static int validateFkOnDeleteSetColumns(int numfks, const int16 *fkattnums,
int numfksetcols, int16 *fksetcolsattnums,
@@ -632,15 +632,15 @@ static void GetForeignKeyCheckTriggers(Relation trigrel,
Oid *insertTriggerOid,
Oid *updateTriggerOid);
static void ATExecDropConstraint(Relation rel, const char *constrName,
- DropBehavior behavior, bool recurse,
+ DropBehavior behavior, bool no_only,
bool missing_ok, LOCKMODE lockmode);
static ObjectAddress dropconstraint_internal(Relation rel,
HeapTuple constraintTup, DropBehavior behavior,
- bool recurse, bool recursing,
+ bool no_only, bool recursing,
bool missing_ok, LOCKMODE lockmode);
static void ATPrepAlterColumnType(List **wqueue,
AlteredTableInfo *tab, Relation rel,
- bool recurse, bool recursing,
+ bool no_only, bool recursing,
AlterTableCmd *cmd, LOCKMODE lockmode,
AlterTableUtilityContext *context);
static bool ATColumnChangeRequiresRewrite(Node *expr, AttrNumber varattno);
@@ -682,7 +682,7 @@ static void ATExecSetRelOptions(Relation rel, List *defList,
AlterTableType operation,
LOCKMODE lockmode);
static void ATExecEnableDisableTrigger(Relation rel, const char *trigname,
- char fires_when, bool skip_system, bool recurse,
+ char fires_when, bool skip_system, bool no_only,
LOCKMODE lockmode);
static void ATExecEnableDisableRule(Relation rel, const char *rulename,
char fires_when, LOCKMODE lockmode);
@@ -1868,7 +1868,7 @@ ExecuteTruncate(TruncateStmt *stmt)
{
RangeVar *rv = lfirst(cell);
Relation rel;
- bool recurse = rv->inh;
+ bool no_only = rv->inh;
Oid myrelid;
LOCKMODE lockmode = AccessExclusiveLock;
@@ -1896,7 +1896,7 @@ ExecuteTruncate(TruncateStmt *stmt)
if (RelationIsLogicallyLogged(rel))
relids_logged = lappend_oid(relids_logged, myrelid);
- if (recurse)
+ if (no_only)
{
ListCell *child;
List *children;
@@ -3842,7 +3842,7 @@ static AttrNumber
renameatt_internal(Oid myrelid,
const char *oldattname,
const char *newattname,
- bool recurse,
+ bool no_only,
bool recursing,
int expected_parents,
DropBehavior behavior)
@@ -3861,14 +3861,14 @@ renameatt_internal(Oid myrelid,
renameatt_check(myrelid, RelationGetForm(targetrelation), recursing);
/*
- * if the 'recurse' flag is set then we are supposed to rename this
+ * if the 'no_only' flag is set then we are supposed to rename this
* attribute in all classes that inherit from 'relname' (as well as in
* 'relname').
*
* any permissions or problems with duplicate attributes will cause the
* whole transaction to abort, which is what we want -- all or nothing.
*/
- if (recurse)
+ if (no_only)
{
List *child_oids,
*child_numparents;
@@ -3902,8 +3902,9 @@ renameatt_internal(Oid myrelid,
else
{
/*
- * If we are told not to recurse, there had better not be any child
- * tables; else the rename would put them out of step.
+ * If we are told not to recurse (ONLY is not set), there had better
+ * not be any child tables; else the rename would put them out of
+ * step.
*
* expected_parents will only be 0 if we are not already recursing.
*/
@@ -4046,7 +4047,7 @@ rename_constraint_internal(Oid myrelid,
Oid mytypid,
const char *oldconname,
const char *newconname,
- bool recurse,
+ bool no_only,
bool recursing,
int expected_parents)
{
@@ -4086,7 +4087,7 @@ rename_constraint_internal(Oid myrelid,
con->contype == CONSTRAINT_NOTNULL) &&
!con->connoinherit)
{
- if (recurse)
+ if (no_only)
{
List *child_oids,
*child_numparents;
@@ -4511,7 +4512,7 @@ AlterTableLookupRelation(AlterTableStmt *stmt, LOCKMODE lockmode)
* For most subcommand types, phases 2 and 3 do no explicit recursion,
* since phase 1 already does it. However, for certain subcommand types
* it is only possible to determine how to recurse at phase 2 time; for
- * those cases, phase 1 sets the cmd->recurse flag.
+ * those cases, phase 1 sets the cmd->no_only flag.
*
* Thanks to the magic of MVCC, an error anywhere along the way rolls back
* the whole operation; we don't have to do anything special to clean up.
@@ -4558,7 +4559,7 @@ AlterTable(AlterTableStmt *stmt, LOCKMODE lockmode,
* could generate subcommands that have to be passed to ProcessUtility.
*/
void
-AlterTableInternal(Oid relid, List *cmds, bool recurse)
+AlterTableInternal(Oid relid, List *cmds, bool no_only)
{
Relation rel;
LOCKMODE lockmode = AlterTableGetLockLevel(cmds);
@@ -4567,7 +4568,7 @@ AlterTableInternal(Oid relid, List *cmds, bool recurse)
EventTriggerAlterTableRelid(relid);
- ATController(NULL, rel, cmds, recurse, lockmode, NULL);
+ ATController(NULL, rel, cmds, no_only, lockmode, NULL);
}
/*
@@ -4871,7 +4872,7 @@ AlterTableGetLockLevel(List *cmds)
*/
static void
ATController(AlterTableStmt *parsetree,
- Relation rel, List *cmds, bool recurse, LOCKMODE lockmode,
+ Relation rel, List *cmds, bool no_only, LOCKMODE lockmode,
AlterTableUtilityContext *context)
{
List *wqueue = NIL;
@@ -4882,7 +4883,7 @@ ATController(AlterTableStmt *parsetree,
{
AlterTableCmd *cmd = (AlterTableCmd *) lfirst(lcmd);
- ATPrepCmd(&wqueue, rel, cmd, recurse, false, lockmode, context);
+ ATPrepCmd(&wqueue, rel, cmd, no_only, false, lockmode, context);
}
/* Close the relation, but keep lock until commit */
@@ -4906,7 +4907,7 @@ ATController(AlterTableStmt *parsetree,
*/
static void
ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
- bool recurse, bool recursing, LOCKMODE lockmode,
+ bool no_only, bool recursing, LOCKMODE lockmode,
AlterTableUtilityContext *context)
{
AlteredTableInfo *tab;
@@ -4949,14 +4950,14 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
ATSimplePermissions(cmd->subtype, rel,
ATT_TABLE | ATT_PARTITIONED_TABLE |
ATT_COMPOSITE_TYPE | ATT_FOREIGN_TABLE);
- ATPrepAddColumn(wqueue, rel, recurse, recursing, false, cmd,
+ ATPrepAddColumn(wqueue, rel, no_only, recursing, false, cmd,
lockmode, context);
/* Recursion occurs during execution phase */
pass = AT_PASS_ADD_COL;
break;
case AT_AddColumnToView: /* add column via CREATE OR REPLACE VIEW */
ATSimplePermissions(cmd->subtype, rel, ATT_VIEW);
- ATPrepAddColumn(wqueue, rel, recurse, recursing, true, cmd,
+ ATPrepAddColumn(wqueue, rel, no_only, recursing, true, cmd,
lockmode, context);
/* Recursion occurs during execution phase */
pass = AT_PASS_ADD_COL;
@@ -4972,7 +4973,7 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
ATSimplePermissions(cmd->subtype, rel,
ATT_TABLE | ATT_PARTITIONED_TABLE | ATT_VIEW |
ATT_FOREIGN_TABLE);
- ATSimpleRecursion(wqueue, rel, cmd, recurse, lockmode, context);
+ ATSimpleRecursion(wqueue, rel, cmd, no_only, lockmode, context);
/* No command-specific prep needed */
pass = cmd->def ? AT_PASS_ADD_OTHERCONSTR : AT_PASS_DROP;
break;
@@ -4989,8 +4990,8 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
ATT_TABLE | ATT_PARTITIONED_TABLE | ATT_VIEW |
ATT_FOREIGN_TABLE);
/* Set up recursion for phase 2; no other prep needed */
- if (recurse)
- cmd->recurse = true;
+ if (no_only)
+ cmd->no_only = true;
pass = AT_PASS_ADD_OTHERCONSTR;
break;
case AT_SetIdentity:
@@ -4998,8 +4999,8 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
ATT_TABLE | ATT_PARTITIONED_TABLE | ATT_VIEW |
ATT_FOREIGN_TABLE);
/* Set up recursion for phase 2; no other prep needed */
- if (recurse)
- cmd->recurse = true;
+ if (no_only)
+ cmd->no_only = true;
/* This should run after AddIdentity, so do it in MISC pass */
pass = AT_PASS_MISC;
break;
@@ -5008,44 +5009,44 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
ATT_TABLE | ATT_PARTITIONED_TABLE | ATT_VIEW |
ATT_FOREIGN_TABLE);
/* Set up recursion for phase 2; no other prep needed */
- if (recurse)
- cmd->recurse = true;
+ if (no_only)
+ cmd->no_only = true;
pass = AT_PASS_DROP;
break;
case AT_DropNotNull: /* ALTER COLUMN DROP NOT NULL */
ATSimplePermissions(cmd->subtype, rel,
ATT_TABLE | ATT_PARTITIONED_TABLE | ATT_FOREIGN_TABLE);
/* Set up recursion for phase 2; no other prep needed */
- if (recurse)
- cmd->recurse = true;
+ if (no_only)
+ cmd->no_only = true;
pass = AT_PASS_DROP;
break;
case AT_SetNotNull: /* ALTER COLUMN SET NOT NULL */
ATSimplePermissions(cmd->subtype, rel,
ATT_TABLE | ATT_PARTITIONED_TABLE | ATT_FOREIGN_TABLE);
/* Set up recursion for phase 2; no other prep needed */
- if (recurse)
- cmd->recurse = true;
+ if (no_only)
+ cmd->no_only = true;
pass = AT_PASS_COL_ATTRS;
break;
case AT_SetExpression: /* ALTER COLUMN SET EXPRESSION */
ATSimplePermissions(cmd->subtype, rel,
ATT_TABLE | ATT_PARTITIONED_TABLE | ATT_FOREIGN_TABLE);
- ATSimpleRecursion(wqueue, rel, cmd, recurse, lockmode, context);
+ ATSimpleRecursion(wqueue, rel, cmd, no_only, lockmode, context);
pass = AT_PASS_SET_EXPRESSION;
break;
case AT_DropExpression: /* ALTER COLUMN DROP EXPRESSION */
ATSimplePermissions(cmd->subtype, rel,
ATT_TABLE | ATT_PARTITIONED_TABLE | ATT_FOREIGN_TABLE);
- ATSimpleRecursion(wqueue, rel, cmd, recurse, lockmode, context);
- ATPrepDropExpression(rel, cmd, recurse, recursing, lockmode);
+ ATSimpleRecursion(wqueue, rel, cmd, no_only, lockmode, context);
+ ATPrepDropExpression(rel, cmd, no_only, recursing, lockmode);
pass = AT_PASS_DROP;
break;
case AT_SetStatistics: /* ALTER COLUMN SET STATISTICS */
ATSimplePermissions(cmd->subtype, rel,
ATT_TABLE | ATT_PARTITIONED_TABLE | ATT_MATVIEW |
ATT_INDEX | ATT_PARTITIONED_INDEX | ATT_FOREIGN_TABLE);
- ATSimpleRecursion(wqueue, rel, cmd, recurse, lockmode, context);
+ ATSimpleRecursion(wqueue, rel, cmd, no_only, lockmode, context);
/* No command-specific prep needed */
pass = AT_PASS_MISC;
break;
@@ -5061,7 +5062,7 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
ATSimplePermissions(cmd->subtype, rel,
ATT_TABLE | ATT_PARTITIONED_TABLE |
ATT_MATVIEW | ATT_FOREIGN_TABLE);
- ATSimpleRecursion(wqueue, rel, cmd, recurse, lockmode, context);
+ ATSimpleRecursion(wqueue, rel, cmd, no_only, lockmode, context);
/* No command-specific prep needed */
pass = AT_PASS_MISC;
break;
@@ -5076,7 +5077,7 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
ATSimplePermissions(cmd->subtype, rel,
ATT_TABLE | ATT_PARTITIONED_TABLE |
ATT_COMPOSITE_TYPE | ATT_FOREIGN_TABLE);
- ATPrepDropColumn(wqueue, rel, recurse, recursing, cmd,
+ ATPrepDropColumn(wqueue, rel, no_only, recursing, cmd,
lockmode, context);
/* Recursion occurs during execution phase */
pass = AT_PASS_DROP;
@@ -5090,12 +5091,12 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
case AT_AddConstraint: /* ADD CONSTRAINT */
ATSimplePermissions(cmd->subtype, rel,
ATT_TABLE | ATT_PARTITIONED_TABLE | ATT_FOREIGN_TABLE);
- ATPrepAddPrimaryKey(wqueue, rel, cmd, recurse, lockmode, context);
- if (recurse)
+ ATPrepAddPrimaryKey(wqueue, rel, cmd, no_only, lockmode, context);
+ if (no_only)
{
/* recurses at exec time; lock descendants and set flag */
(void) find_all_inheritors(RelationGetRelid(rel), lockmode, NULL);
- cmd->recurse = true;
+ cmd->no_only = true;
}
pass = AT_PASS_ADD_CONSTR;
break;
@@ -5111,8 +5112,8 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
ATCheckPartitionsNotInUse(rel, lockmode);
/* Other recursion occurs during execution phase */
/* No command-specific prep needed except saving recurse flag */
- if (recurse)
- cmd->recurse = true;
+ if (no_only)
+ cmd->no_only = true;
pass = AT_PASS_DROP;
break;
case AT_AlterColumnType: /* ALTER COLUMN TYPE */
@@ -5120,11 +5121,11 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
ATT_TABLE | ATT_PARTITIONED_TABLE |
ATT_COMPOSITE_TYPE | ATT_FOREIGN_TABLE);
/* See comments for ATPrepAlterColumnType */
- cmd = ATParseTransformCmd(wqueue, tab, rel, cmd, recurse, lockmode,
+ cmd = ATParseTransformCmd(wqueue, tab, rel, cmd, no_only, lockmode,
AT_PASS_UNSET, context);
Assert(cmd != NULL);
/* Performs own recursion */
- ATPrepAlterColumnType(wqueue, tab, rel, recurse, recursing, cmd,
+ ATPrepAlterColumnType(wqueue, tab, rel, no_only, recursing, cmd,
lockmode, context);
pass = AT_PASS_ALTER_TYPE;
break;
@@ -5210,8 +5211,8 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
ATSimplePermissions(cmd->subtype, rel,
ATT_TABLE | ATT_PARTITIONED_TABLE);
/* Recursion occurs during execution phase */
- if (recurse)
- cmd->recurse = true;
+ if (no_only)
+ cmd->no_only = true;
pass = AT_PASS_MISC;
break;
case AT_ValidateConstraint: /* VALIDATE CONSTRAINT */
@@ -5219,8 +5220,8 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
ATT_TABLE | ATT_PARTITIONED_TABLE | ATT_FOREIGN_TABLE);
/* Recursion occurs during execution phase */
/* No command-specific prep needed except saving recurse flag */
- if (recurse)
- cmd->recurse = true;
+ if (no_only)
+ cmd->no_only = true;
pass = AT_PASS_MISC;
break;
case AT_ReplicaIdentity: /* REPLICA IDENTITY ... */
@@ -5241,8 +5242,8 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
ATSimplePermissions(cmd->subtype, rel,
ATT_TABLE | ATT_PARTITIONED_TABLE | ATT_FOREIGN_TABLE);
/* Set up recursion for phase 2; no other prep needed */
- if (recurse)
- cmd->recurse = true;
+ if (no_only)
+ cmd->no_only = true;
pass = AT_PASS_MISC;
break;
case AT_EnableRule: /* ENABLE/DISABLE RULE variants */
@@ -5394,7 +5395,7 @@ ATExecCmd(List **wqueue, AlteredTableInfo *tab,
case AT_AddColumn: /* ADD COLUMN */
case AT_AddColumnToView: /* add column via CREATE OR REPLACE VIEW */
address = ATExecAddColumn(wqueue, tab, rel, &cmd,
- cmd->recurse, false,
+ cmd->no_only, false,
lockmode, cur_pass, context);
break;
case AT_ColumnDefault: /* ALTER COLUMN DEFAULT */
@@ -5407,23 +5408,23 @@ ATExecCmd(List **wqueue, AlteredTableInfo *tab,
cmd = ATParseTransformCmd(wqueue, tab, rel, cmd, false, lockmode,
cur_pass, context);
Assert(cmd != NULL);
- address = ATExecAddIdentity(rel, cmd->name, cmd->def, lockmode, cmd->recurse, false);
+ address = ATExecAddIdentity(rel, cmd->name, cmd->def, lockmode, cmd->no_only, false);
break;
case AT_SetIdentity:
cmd = ATParseTransformCmd(wqueue, tab, rel, cmd, false, lockmode,
cur_pass, context);
Assert(cmd != NULL);
- address = ATExecSetIdentity(rel, cmd->name, cmd->def, lockmode, cmd->recurse, false);
+ address = ATExecSetIdentity(rel, cmd->name, cmd->def, lockmode, cmd->no_only, false);
break;
case AT_DropIdentity:
- address = ATExecDropIdentity(rel, cmd->name, cmd->missing_ok, lockmode, cmd->recurse, false);
+ address = ATExecDropIdentity(rel, cmd->name, cmd->missing_ok, lockmode, cmd->no_only, false);
break;
case AT_DropNotNull: /* ALTER COLUMN DROP NOT NULL */
- address = ATExecDropNotNull(rel, cmd->name, cmd->recurse, lockmode);
+ address = ATExecDropNotNull(rel, cmd->name, cmd->no_only, lockmode);
break;
case AT_SetNotNull: /* ALTER COLUMN SET NOT NULL */
address = ATExecSetNotNull(wqueue, rel, NULL, cmd->name,
- cmd->recurse, false, lockmode);
+ cmd->no_only, false, lockmode);
break;
case AT_SetExpression:
address = ATExecSetExpression(tab, rel, cmd->name, cmd->def, lockmode);
@@ -5449,7 +5450,7 @@ ATExecCmd(List **wqueue, AlteredTableInfo *tab,
break;
case AT_DropColumn: /* DROP COLUMN */
address = ATExecDropColumn(wqueue, rel, cmd->name,
- cmd->behavior, cmd->recurse, false,
+ cmd->behavior, cmd->no_only, false,
cmd->missing_ok, lockmode,
NULL);
break;
@@ -5469,14 +5470,14 @@ ATExecCmd(List **wqueue, AlteredTableInfo *tab,
/* Transform the command only during initial examination */
if (cur_pass == AT_PASS_ADD_CONSTR)
cmd = ATParseTransformCmd(wqueue, tab, rel, cmd,
- cmd->recurse, lockmode,
+ cmd->no_only, lockmode,
cur_pass, context);
/* Depending on constraint type, might be no more work to do now */
if (cmd != NULL)
address =
ATExecAddConstraint(wqueue, tab, rel,
(Constraint *) cmd->def,
- cmd->recurse, false, lockmode);
+ cmd->no_only, false, lockmode);
break;
case AT_ReAddConstraint: /* Re-add pre-existing check constraint */
address =
@@ -5500,15 +5501,15 @@ ATExecCmd(List **wqueue, AlteredTableInfo *tab,
case AT_AlterConstraint: /* ALTER CONSTRAINT */
address = ATExecAlterConstraint(wqueue, rel,
castNode(ATAlterConstraint, cmd->def),
- cmd->recurse, lockmode);
+ cmd->no_only, lockmode);
break;
case AT_ValidateConstraint: /* VALIDATE CONSTRAINT */
- address = ATExecValidateConstraint(wqueue, rel, cmd->name, cmd->recurse,
+ address = ATExecValidateConstraint(wqueue, rel, cmd->name, cmd->no_only,
false, lockmode);
break;
case AT_DropConstraint: /* DROP CONSTRAINT */
ATExecDropConstraint(rel, cmd->name, cmd->behavior,
- cmd->recurse,
+ cmd->no_only,
cmd->missing_ok, lockmode);
break;
case AT_AlterColumnType: /* ALTER COLUMN TYPE */
@@ -5567,49 +5568,49 @@ ATExecCmd(List **wqueue, AlteredTableInfo *tab,
case AT_EnableTrig: /* ENABLE TRIGGER name */
ATExecEnableDisableTrigger(rel, cmd->name,
TRIGGER_FIRES_ON_ORIGIN, false,
- cmd->recurse,
+ cmd->no_only,
lockmode);
break;
case AT_EnableAlwaysTrig: /* ENABLE ALWAYS TRIGGER name */
ATExecEnableDisableTrigger(rel, cmd->name,
TRIGGER_FIRES_ALWAYS, false,
- cmd->recurse,
+ cmd->no_only,
lockmode);
break;
case AT_EnableReplicaTrig: /* ENABLE REPLICA TRIGGER name */
ATExecEnableDisableTrigger(rel, cmd->name,
TRIGGER_FIRES_ON_REPLICA, false,
- cmd->recurse,
+ cmd->no_only,
lockmode);
break;
case AT_DisableTrig: /* DISABLE TRIGGER name */
ATExecEnableDisableTrigger(rel, cmd->name,
TRIGGER_DISABLED, false,
- cmd->recurse,
+ cmd->no_only,
lockmode);
break;
case AT_EnableTrigAll: /* ENABLE TRIGGER ALL */
ATExecEnableDisableTrigger(rel, NULL,
TRIGGER_FIRES_ON_ORIGIN, false,
- cmd->recurse,
+ cmd->no_only,
lockmode);
break;
case AT_DisableTrigAll: /* DISABLE TRIGGER ALL */
ATExecEnableDisableTrigger(rel, NULL,
TRIGGER_DISABLED, false,
- cmd->recurse,
+ cmd->no_only,
lockmode);
break;
case AT_EnableTrigUser: /* ENABLE TRIGGER USER */
ATExecEnableDisableTrigger(rel, NULL,
TRIGGER_FIRES_ON_ORIGIN, true,
- cmd->recurse,
+ cmd->no_only,
lockmode);
break;
case AT_DisableTrigUser: /* DISABLE TRIGGER USER */
ATExecEnableDisableTrigger(rel, NULL,
TRIGGER_DISABLED, true,
- cmd->recurse,
+ cmd->no_only,
lockmode);
break;
@@ -5734,7 +5735,7 @@ ATExecCmd(List **wqueue, AlteredTableInfo *tab,
*/
static AlterTableCmd *
ATParseTransformCmd(List **wqueue, AlteredTableInfo *tab, Relation rel,
- AlterTableCmd *cmd, bool recurse, LOCKMODE lockmode,
+ AlterTableCmd *cmd, bool no_only, LOCKMODE lockmode,
AlterTablePass cur_pass, AlterTableUtilityContext *context)
{
AlterTableCmd *newcmd = NULL;
@@ -5748,7 +5749,7 @@ ATParseTransformCmd(List **wqueue, AlteredTableInfo *tab, Relation rel,
makeRangeVar(get_namespace_name(RelationGetNamespace(rel)),
pstrdup(RelationGetRelationName(rel)),
-1);
- atstmt->relation->inh = recurse;
+ atstmt->relation->inh = no_only;
atstmt->cmds = list_make1(cmd);
atstmt->objtype = OBJECT_TABLE; /* needn't be picky here */
atstmt->missing_ok = false;
@@ -5795,8 +5796,8 @@ ATParseTransformCmd(List **wqueue, AlteredTableInfo *tab, Relation rel,
break;
case AT_AddConstraint:
/* Recursion occurs during execution phase */
- if (recurse)
- cmd2->recurse = true;
+ if (no_only)
+ cmd2->no_only = true;
switch (castNode(Constraint, cmd2->def)->contype)
{
case CONSTR_NOTNULL:
@@ -6843,14 +6844,14 @@ ATSimplePermissions(AlterTableType cmdtype, Relation rel, int allowed_targets)
*/
static void
ATSimpleRecursion(List **wqueue, Relation rel,
- AlterTableCmd *cmd, bool recurse, LOCKMODE lockmode,
+ AlterTableCmd *cmd, bool no_only, LOCKMODE lockmode,
AlterTableUtilityContext *context)
{
/*
* Propagate to children, if desired and if there are (or might be) any
* children.
*/
- if (recurse && rel->rd_rel->relhassubclass)
+ if (no_only && rel->rd_rel->relhassubclass)
{
Oid relid = RelationGetRelid(rel);
ListCell *child;
@@ -7219,7 +7220,7 @@ check_of_type(HeapTuple typetuple)
* situations correctly.)
*/
static void
-ATPrepAddColumn(List **wqueue, Relation rel, bool recurse, bool recursing,
+ATPrepAddColumn(List **wqueue, Relation rel, bool no_only, bool recursing,
bool is_view, AlterTableCmd *cmd, LOCKMODE lockmode,
AlterTableUtilityContext *context)
{
@@ -7231,8 +7232,8 @@ ATPrepAddColumn(List **wqueue, Relation rel, bool recurse, bool recursing,
if (rel->rd_rel->relkind == RELKIND_COMPOSITE_TYPE)
ATTypedTableRecursion(wqueue, rel, cmd, lockmode, context);
- if (recurse && !is_view)
- cmd->recurse = true;
+ if (no_only && !is_view)
+ cmd->no_only = true;
}
/*
@@ -7244,7 +7245,7 @@ ATPrepAddColumn(List **wqueue, Relation rel, bool recurse, bool recursing,
*/
static ObjectAddress
ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
- AlterTableCmd **cmd, bool recurse, bool recursing,
+ AlterTableCmd **cmd, bool no_only, bool recursing,
LOCKMODE lockmode, AlterTablePass cur_pass,
AlterTableUtilityContext *context)
{
@@ -7361,7 +7362,7 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
*/
if (context != NULL && !recursing)
{
- *cmd = ATParseTransformCmd(wqueue, tab, rel, *cmd, recurse, lockmode,
+ *cmd = ATParseTransformCmd(wqueue, tab, rel, *cmd, no_only, lockmode,
cur_pass, context);
Assert(*cmd != NULL);
colDef = castNode(ColumnDef, (*cmd)->def);
@@ -7377,7 +7378,7 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
* partition hierarchy.
*/
if (colDef->identity &&
- recurse &&
+ no_only &&
rel->rd_rel->relkind != RELKIND_PARTITIONED_TABLE &&
find_inheritance_children(myrelid, NoLock) != NIL)
ereport(ERROR,
@@ -7623,10 +7624,10 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
find_inheritance_children(RelationGetRelid(rel), lockmode);
/*
- * If we are told not to recurse, there had better not be any child
- * tables; else the addition would put them out of step.
+ * If we are told not to recurse (ONLY is not set), there had better not
+ * be any child tables; else the addition would put them out of step.
*/
- if (children && !recurse)
+ if (children && !no_only)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("column must be added to child tables too")));
@@ -7657,7 +7658,7 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
/* Recurse to child; return value is ignored */
ATExecAddColumn(wqueue, childtab, childrel,
- &childcmd, recurse, true,
+ &childcmd, no_only, true,
lockmode, cur_pass, context);
table_close(childrel, NoLock);
@@ -7768,7 +7769,7 @@ add_column_collation_dependency(Oid relid, int32 attnum, Oid collid)
* nullable, InvalidObjectAddress is returned.
*/
static ObjectAddress
-ATExecDropNotNull(Relation rel, const char *colName, bool recurse,
+ATExecDropNotNull(Relation rel, const char *colName, bool no_only,
LOCKMODE lockmode)
{
HeapTuple tuple;
@@ -7843,7 +7844,7 @@ ATExecDropNotNull(Relation rel, const char *colName, bool recurse,
colName, RelationGetRelationName(rel));
/* The normal case: we have a pg_constraint row, remove it */
- dropconstraint_internal(rel, conTup, DROP_RESTRICT, recurse, false,
+ dropconstraint_internal(rel, conTup, DROP_RESTRICT, no_only, false,
false, lockmode);
heap_freetuple(conTup);
@@ -7940,7 +7941,7 @@ set_attnotnull(List **wqueue, Relation rel, AttrNumber attnum,
*/
static ObjectAddress
ATExecSetNotNull(List **wqueue, Relation rel, char *conName, char *colName,
- bool recurse, bool recursing, LOCKMODE lockmode)
+ bool no_only, bool recursing, LOCKMODE lockmode)
{
HeapTuple tuple;
AttrNumber attnum;
@@ -7985,7 +7986,7 @@ ATExecSetNotNull(List **wqueue, Relation rel, char *conName, char *colName,
/*
* Don't let a NO INHERIT constraint be changed into inherit.
*/
- if (conForm->connoinherit && recurse)
+ if (conForm->connoinherit && no_only)
ereport(ERROR,
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot change NO INHERIT status of NOT NULL constraint \"%s\" on relation \"%s\"",
@@ -8018,7 +8019,7 @@ ATExecSetNotNull(List **wqueue, Relation rel, char *conName, char *colName,
* constraint.
*/
return ATExecValidateConstraint(wqueue, rel, NameStr(conForm->conname),
- recurse, recursing, lockmode);
+ no_only, recursing, lockmode);
}
if (changed)
@@ -8039,11 +8040,11 @@ ATExecSetNotNull(List **wqueue, Relation rel, char *conName, char *colName,
}
/*
- * If we're asked not to recurse, and children exist, raise an error for
- * partitioned tables. For inheritance, we act as if NO INHERIT had been
- * specified.
+ * If we're asked not to recurse (ONLY is not set), and children exist,
+ * raise an error for partitioned tables. For inheritance, we act as if
+ * NO INHERIT had been specified.
*/
- if (!recurse &&
+ if (!no_only &&
find_inheritance_children(RelationGetRelid(rel),
NoLock) != NIL)
{
@@ -8088,7 +8089,7 @@ ATExecSetNotNull(List **wqueue, Relation rel, char *conName, char *colName,
/*
* Recurse to propagate the constraint to children that don't have one.
*/
- if (recurse)
+ if (no_only)
{
List *children;
@@ -8102,7 +8103,7 @@ ATExecSetNotNull(List **wqueue, Relation rel, char *conName, char *colName,
CommandCounterIncrement();
ATExecSetNotNull(wqueue, childrel, conName, colName,
- recurse, true, lockmode);
+ no_only, true, lockmode);
table_close(childrel, NoLock);
}
}
@@ -8267,7 +8268,7 @@ ATExecCookedColumnDefault(Relation rel, AttrNumber attnum,
*/
static ObjectAddress
ATExecAddIdentity(Relation rel, const char *colName,
- Node *def, LOCKMODE lockmode, bool recurse, bool recursing)
+ Node *def, LOCKMODE lockmode, bool no_only, bool recursing)
{
Relation attrelation;
HeapTuple tuple;
@@ -8278,7 +8279,7 @@ ATExecAddIdentity(Relation rel, const char *colName,
bool ispartitioned;
ispartitioned = (rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE);
- if (ispartitioned && !recurse)
+ if (ispartitioned && !no_only)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("cannot add identity to a column of only the partitioned table"),
@@ -8371,7 +8372,7 @@ ATExecAddIdentity(Relation rel, const char *colName,
* Recurse to propagate the identity column to partitions. Identity is
* not inherited in regular inheritance children.
*/
- if (recurse && ispartitioned)
+ if (no_only && ispartitioned)
{
List *children;
ListCell *lc;
@@ -8383,7 +8384,7 @@ ATExecAddIdentity(Relation rel, const char *colName,
Relation childrel;
childrel = table_open(lfirst_oid(lc), NoLock);
- ATExecAddIdentity(childrel, colName, def, lockmode, recurse, true);
+ ATExecAddIdentity(childrel, colName, def, lockmode, no_only, true);
table_close(childrel, NoLock);
}
}
@@ -8398,7 +8399,7 @@ ATExecAddIdentity(Relation rel, const char *colName,
*/
static ObjectAddress
ATExecSetIdentity(Relation rel, const char *colName, Node *def,
- LOCKMODE lockmode, bool recurse, bool recursing)
+ LOCKMODE lockmode, bool no_only, bool recursing)
{
ListCell *option;
DefElem *generatedEl = NULL;
@@ -8410,7 +8411,7 @@ ATExecSetIdentity(Relation rel, const char *colName, Node *def,
bool ispartitioned;
ispartitioned = (rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE);
- if (ispartitioned && !recurse)
+ if (ispartitioned && !no_only)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("cannot change identity column of only the partitioned table"),
@@ -8488,7 +8489,7 @@ ATExecSetIdentity(Relation rel, const char *colName, Node *def,
* Recurse to propagate the identity change to partitions. Identity is not
* inherited in regular inheritance children.
*/
- if (generatedEl && recurse && ispartitioned)
+ if (generatedEl && no_only && ispartitioned)
{
List *children;
ListCell *lc;
@@ -8500,7 +8501,7 @@ ATExecSetIdentity(Relation rel, const char *colName, Node *def,
Relation childrel;
childrel = table_open(lfirst_oid(lc), NoLock);
- ATExecSetIdentity(childrel, colName, def, lockmode, recurse, true);
+ ATExecSetIdentity(childrel, colName, def, lockmode, no_only, true);
table_close(childrel, NoLock);
}
}
@@ -8515,7 +8516,7 @@ ATExecSetIdentity(Relation rel, const char *colName, Node *def,
*/
static ObjectAddress
ATExecDropIdentity(Relation rel, const char *colName, bool missing_ok, LOCKMODE lockmode,
- bool recurse, bool recursing)
+ bool no_only, bool recursing)
{
HeapTuple tuple;
Form_pg_attribute attTup;
@@ -8527,7 +8528,7 @@ ATExecDropIdentity(Relation rel, const char *colName, bool missing_ok, LOCKMODE
bool ispartitioned;
ispartitioned = (rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE);
- if (ispartitioned && !recurse)
+ if (ispartitioned && !no_only)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("cannot drop identity from a column of only the partitioned table"),
@@ -8589,7 +8590,7 @@ ATExecDropIdentity(Relation rel, const char *colName, bool missing_ok, LOCKMODE
* Recurse to drop the identity from column in partitions. Identity is
* not inherited in regular inheritance children so ignore them.
*/
- if (recurse && ispartitioned)
+ if (no_only && ispartitioned)
{
List *children;
ListCell *lc;
@@ -8601,7 +8602,7 @@ ATExecDropIdentity(Relation rel, const char *colName, bool missing_ok, LOCKMODE
Relation childrel;
childrel = table_open(lfirst_oid(lc), NoLock);
- ATExecDropIdentity(childrel, colName, false, lockmode, recurse, true);
+ ATExecDropIdentity(childrel, colName, false, lockmode, no_only, true);
table_close(childrel, NoLock);
}
}
@@ -8782,7 +8783,7 @@ ATExecSetExpression(AlteredTableInfo *tab, Relation rel, const char *colName,
* ALTER TABLE ALTER COLUMN DROP EXPRESSION
*/
static void
-ATPrepDropExpression(Relation rel, AlterTableCmd *cmd, bool recurse, bool recursing, LOCKMODE lockmode)
+ATPrepDropExpression(Relation rel, AlterTableCmd *cmd, bool no_only, bool recursing, LOCKMODE lockmode)
{
/*
* Reject ONLY if there are child tables. We could implement this, but it
@@ -8794,7 +8795,7 @@ ATPrepDropExpression(Relation rel, AlterTableCmd *cmd, bool recurse, bool recurs
* tables, somewhat similar to how DROP COLUMN does it, so that the
* resulting state can be properly dumped and restored.
*/
- if (!recurse &&
+ if (!no_only &&
find_inheritance_children(RelationGetRelid(rel), lockmode))
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
@@ -9282,7 +9283,7 @@ ATExecSetStorage(Relation rel, const char *colName, Node *newValue, LOCKMODE loc
* correctly.)
*/
static void
-ATPrepDropColumn(List **wqueue, Relation rel, bool recurse, bool recursing,
+ATPrepDropColumn(List **wqueue, Relation rel, bool no_only, bool recursing,
AlterTableCmd *cmd, LOCKMODE lockmode,
AlterTableUtilityContext *context)
{
@@ -9294,8 +9295,8 @@ ATPrepDropColumn(List **wqueue, Relation rel, bool recurse, bool recursing,
if (rel->rd_rel->relkind == RELKIND_COMPOSITE_TYPE)
ATTypedTableRecursion(wqueue, rel, cmd, lockmode, context);
- if (recurse)
- cmd->recurse = true;
+ if (no_only)
+ cmd->no_only = true;
}
/*
@@ -9312,7 +9313,7 @@ ATPrepDropColumn(List **wqueue, Relation rel, bool recurse, bool recursing,
static ObjectAddress
ATExecDropColumn(List **wqueue, Relation rel, const char *colName,
DropBehavior behavior,
- bool recurse, bool recursing,
+ bool no_only, bool recursing,
bool missing_ok, LOCKMODE lockmode,
ObjectAddresses *addrs)
{
@@ -9411,7 +9412,7 @@ ATExecDropColumn(List **wqueue, Relation rel, const char *colName,
* In case of a partitioned table, the column must be dropped from the
* partitions as well.
*/
- if (rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE && !recurse)
+ if (rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE && !no_only)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("cannot drop column from only the partitioned table when partitions exist"),
@@ -9438,7 +9439,7 @@ ATExecDropColumn(List **wqueue, Relation rel, const char *colName,
elog(ERROR, "relation %u has non-inherited attribute \"%s\"",
childrelid, colName);
- if (recurse)
+ if (no_only)
{
/*
* If the child column has other definition sources, just
@@ -9508,11 +9509,11 @@ ATExecDropColumn(List **wqueue, Relation rel, const char *colName,
*
* The not-null constraints for a primary key must cover the whole inheritance
* hierarchy (failing to ensure that leads to funny corner cases). For the
- * normal case where we're asked to recurse, this routine checks if the
+ * normal case where we're asked to recurse (no ONLY set), this routine checks if the
* not-null constraints exist already, and if not queues a requirement for
* them to be created by phase 2.
*
- * For the case where we're asked not to recurse, we verify that a not-null
+ * For the case where we're asked not to recurse (ONLY is set), we verify that a not-null
* constraint exists on each column of each (direct) child table, throwing an
* error if not. Not throwing an error would also work, because a not-null
* constraint would be created anyway, but it'd cause a silent scan of the
@@ -9526,7 +9527,7 @@ ATExecDropColumn(List **wqueue, Relation rel, const char *colName,
*/
static void
ATPrepAddPrimaryKey(List **wqueue, Relation rel, AlterTableCmd *cmd,
- bool recurse, LOCKMODE lockmode,
+ bool no_only, LOCKMODE lockmode,
AlterTableUtilityContext *context)
{
Constraint *pkconstr;
@@ -9558,7 +9559,7 @@ ATPrepAddPrimaryKey(List **wqueue, Relation rel, AlterTableCmd *cmd,
heap_freetuple(tuple);
continue;
}
- else if (!recurse)
+ else if (!no_only)
{
/*
* No constraint on this column. Asked not to recurse, we won't
@@ -9591,8 +9592,8 @@ ATPrepAddPrimaryKey(List **wqueue, Relation rel, AlterTableCmd *cmd,
newcmd = makeNode(AlterTableCmd);
newcmd->subtype = AT_AddConstraint;
- /* note we force recurse=true here; see above */
- newcmd->recurse = true;
+ /* note we force no_only=true here; see above */
+ newcmd->no_only = true;
newcmd->def = (Node *) nnconstr;
ATPrepCmd(wqueue, rel, newcmd, true, false, lockmode, context);
@@ -9824,7 +9825,7 @@ ATExecAddIndexConstraint(AlteredTableInfo *tab, Relation rel,
*/
static ObjectAddress
ATExecAddConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
- Constraint *newConstraint, bool recurse, bool is_readd,
+ Constraint *newConstraint, bool no_only, bool is_readd,
LOCKMODE lockmode)
{
ObjectAddress address = InvalidObjectAddress;
@@ -9842,7 +9843,7 @@ ATExecAddConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
case CONSTR_NOTNULL:
address =
ATAddCheckNNConstraint(wqueue, tab, rel,
- newConstraint, recurse, false, is_readd,
+ newConstraint, no_only, false, is_readd,
lockmode);
break;
@@ -9872,7 +9873,7 @@ ATExecAddConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
address = ATAddForeignKeyConstraint(wqueue, tab, rel,
newConstraint,
- recurse, false,
+ no_only, false,
lockmode);
break;
@@ -9940,7 +9941,7 @@ ChooseForeignKeyConstraintNameAddition(List *colnames)
*/
static ObjectAddress
ATAddCheckNNConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
- Constraint *constr, bool recurse, bool recursing,
+ Constraint *constr, bool no_only, bool recursing,
bool is_readd, LOCKMODE lockmode)
{
List *newcons;
@@ -10047,7 +10048,7 @@ ATAddCheckNNConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
* constraint creation only if there are no children currently. Error out
* otherwise.
*/
- if (!recurse && children != NIL)
+ if (!no_only && children != NIL)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("constraint must be added to child tables too")));
@@ -10070,7 +10071,7 @@ ATAddCheckNNConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
/* Recurse to this child */
ATAddCheckNNConstraint(wqueue, childtab, childrel,
- constr, recurse, true, is_readd, lockmode);
+ constr, no_only, true, is_readd, lockmode);
table_close(childrel, NoLock);
}
@@ -10096,7 +10097,7 @@ ATAddCheckNNConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
static ObjectAddress
ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
Constraint *fkconstraint,
- bool recurse, bool recursing, LOCKMODE lockmode)
+ bool no_only, bool recursing, LOCKMODE lockmode)
{
Relation pkrel;
int16 pkattnum[INDEX_MAX_KEYS] = {0};
@@ -10134,7 +10135,7 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
* Validity checks (permission checks wait till we have the column
* numbers)
*/
- if (!recurse && rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
+ if (!no_only && rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
ereport(ERROR,
errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("cannot use ONLY for foreign key on partitioned table \"%s\" referencing relation \"%s\"",
@@ -12226,7 +12227,7 @@ GetForeignKeyCheckTriggers(Relation trigrel,
*/
static ObjectAddress
ATExecAlterConstraint(List **wqueue, Relation rel, ATAlterConstraint *cmdcon,
- bool recurse, LOCKMODE lockmode)
+ bool no_only, LOCKMODE lockmode)
{
Relation conrel;
Relation tgrel;
@@ -12240,7 +12241,7 @@ ATExecAlterConstraint(List **wqueue, Relation rel, ATAlterConstraint *cmdcon,
* Disallow altering ONLY a partitioned table, as it would make no sense.
* This is okay for legacy inheritance.
*/
- if (rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE && !recurse)
+ if (rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE && !no_only)
ereport(ERROR,
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("constraint must be altered in child tables too"),
@@ -12352,7 +12353,7 @@ ATExecAlterConstraint(List **wqueue, Relation rel, ATAlterConstraint *cmdcon,
* Do the actual catalog work, and recurse if necessary.
*/
if (ATExecAlterConstraintInternal(wqueue, cmdcon, conrel, tgrel, rel,
- contuple, recurse, lockmode))
+ contuple, no_only, lockmode))
ObjectAddressSet(address, ConstraintRelationId, currcon->oid);
systable_endscan(scan);
@@ -12370,7 +12371,7 @@ ATExecAlterConstraint(List **wqueue, Relation rel, ATAlterConstraint *cmdcon,
static bool
ATExecAlterConstraintInternal(List **wqueue, ATAlterConstraint *cmdcon,
Relation conrel, Relation tgrel, Relation rel,
- HeapTuple contuple, bool recurse,
+ HeapTuple contuple, bool no_only,
LOCKMODE lockmode)
{
Form_pg_constraint currcon;
@@ -12400,7 +12401,7 @@ ATExecAlterConstraintInternal(List **wqueue, ATAlterConstraint *cmdcon,
else if (cmdcon->alterDeferrability &&
ATExecAlterConstrDeferrability(wqueue, cmdcon, conrel, tgrel, rel,
- contuple, recurse, &otherrelids,
+ contuple, no_only, &otherrelids,
lockmode))
{
/*
@@ -12587,7 +12588,7 @@ ATExecAlterConstrEnforceability(List **wqueue, ATAlterConstraint *cmdcon,
static bool
ATExecAlterConstrDeferrability(List **wqueue, ATAlterConstraint *cmdcon,
Relation conrel, Relation tgrel, Relation rel,
- HeapTuple contuple, bool recurse,
+ HeapTuple contuple, bool no_only,
List **otherrelids, LOCKMODE lockmode)
{
Form_pg_constraint currcon;
@@ -12628,11 +12629,11 @@ ATExecAlterConstrDeferrability(List **wqueue, ATAlterConstraint *cmdcon,
* If the table at either end of the constraint is partitioned, we need to
* handle every constraint that is a child of this one.
*/
- if (recurse && changed &&
+ if (no_only && changed &&
(rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE ||
get_rel_relkind(refrelid) == RELKIND_PARTITIONED_TABLE))
AlterConstrDeferrabilityRecurse(wqueue, cmdcon, conrel, tgrel, rel,
- contuple, recurse, otherrelids,
+ contuple, no_only, otherrelids,
lockmode);
return changed;
@@ -12841,7 +12842,7 @@ AlterConstrEnforceabilityRecurse(List **wqueue, ATAlterConstraint *cmdcon,
static void
AlterConstrDeferrabilityRecurse(List **wqueue, ATAlterConstraint *cmdcon,
Relation conrel, Relation tgrel, Relation rel,
- HeapTuple contuple, bool recurse,
+ HeapTuple contuple, bool no_only,
List **otherrelids, LOCKMODE lockmode)
{
Form_pg_constraint currcon;
@@ -12869,7 +12870,7 @@ AlterConstrDeferrabilityRecurse(List **wqueue, ATAlterConstraint *cmdcon,
childrel = table_open(childcon->conrelid, lockmode);
ATExecAlterConstrDeferrability(wqueue, cmdcon, conrel, tgrel, childrel,
- childtup, recurse, otherrelids, lockmode);
+ childtup, no_only, otherrelids, lockmode);
table_close(childrel, NoLock);
}
@@ -12936,7 +12937,7 @@ AlterConstrUpdateConstraintEntry(ATAlterConstraint *cmdcon, Relation conrel,
*/
static ObjectAddress
ATExecValidateConstraint(List **wqueue, Relation rel, char *constrName,
- bool recurse, bool recursing, LOCKMODE lockmode)
+ bool no_only, bool recursing, LOCKMODE lockmode)
{
Relation conrel;
SysScanDesc scan;
@@ -12997,12 +12998,12 @@ ATExecValidateConstraint(List **wqueue, Relation rel, char *constrName,
else if (con->contype == CONSTRAINT_CHECK)
{
QueueCheckConstraintValidation(wqueue, conrel, rel, constrName,
- tuple, recurse, recursing, lockmode);
+ tuple, no_only, recursing, lockmode);
}
else if (con->contype == CONSTRAINT_NOTNULL)
{
QueueNNConstraintValidation(wqueue, conrel, rel,
- tuple, recurse, recursing, lockmode);
+ tuple, no_only, recursing, lockmode);
}
ObjectAddressSet(address, ConstraintRelationId, con->oid);
@@ -13146,7 +13147,7 @@ QueueFKConstraintValidation(List **wqueue, Relation conrel, Relation fkrel,
static void
QueueCheckConstraintValidation(List **wqueue, Relation conrel, Relation rel,
char *constrName, HeapTuple contuple,
- bool recurse, bool recursing, LOCKMODE lockmode)
+ bool no_only, bool recursing, LOCKMODE lockmode)
{
Form_pg_constraint con;
AlteredTableInfo *tab;
@@ -13191,7 +13192,7 @@ QueueCheckConstraintValidation(List **wqueue, Relation conrel, Relation rel,
* tables, because we can't mark the constraint on the parent valid
* unless it is valid for all child tables.
*/
- if (!recurse)
+ if (!no_only)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("constraint must be validated on child tables too")));
@@ -13248,7 +13249,7 @@ QueueCheckConstraintValidation(List **wqueue, Relation conrel, Relation rel,
*/
static void
QueueNNConstraintValidation(List **wqueue, Relation conrel, Relation rel,
- HeapTuple contuple, bool recurse, bool recursing,
+ HeapTuple contuple, bool no_only, bool recursing,
LOCKMODE lockmode)
{
Form_pg_constraint con;
@@ -13291,7 +13292,7 @@ QueueNNConstraintValidation(List **wqueue, Relation conrel, Relation rel,
* tables, because we can't mark the constraint on the parent valid
* unless it is valid for all child tables.
*/
- if (!recurse)
+ if (!no_only)
ereport(ERROR,
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("constraint must be validated on child tables too"));
@@ -14040,7 +14041,7 @@ createForeignKeyCheckTriggers(Oid myRelOid, Oid refRelOid,
*/
static void
ATExecDropConstraint(Relation rel, const char *constrName,
- DropBehavior behavior, bool recurse,
+ DropBehavior behavior, bool no_only,
bool missing_ok, LOCKMODE lockmode)
{
Relation conrel;
@@ -14072,7 +14073,7 @@ ATExecDropConstraint(Relation rel, const char *constrName,
/* There can be at most one matching row */
if (HeapTupleIsValid(tuple = systable_getnext(scan)))
{
- dropconstraint_internal(rel, tuple, behavior, recurse, false,
+ dropconstraint_internal(rel, tuple, behavior, no_only, false,
missing_ok, lockmode);
found = true;
}
@@ -14105,7 +14106,7 @@ ATExecDropConstraint(Relation rel, const char *constrName,
*/
static ObjectAddress
dropconstraint_internal(Relation rel, HeapTuple constraintTup, DropBehavior behavior,
- bool recurse, bool recursing, bool missing_ok,
+ bool no_only, bool recursing, bool missing_ok,
LOCKMODE lockmode)
{
Relation conrel;
@@ -14331,7 +14332,7 @@ dropconstraint_internal(Relation rel, HeapTuple constraintTup, DropBehavior beha
elog(ERROR, "relation %u has non-inherited constraint \"%s\"",
childrelid, NameStr(childcon->conname));
- if (recurse)
+ if (no_only)
{
/*
* If the child constraint has other definition sources, just
@@ -14341,7 +14342,7 @@ dropconstraint_internal(Relation rel, HeapTuple constraintTup, DropBehavior beha
{
/* Time to delete this child constraint, too */
dropconstraint_internal(childrel, tuple, behavior,
- recurse, true, missing_ok,
+ no_only, true, missing_ok,
lockmode);
}
else
@@ -14402,7 +14403,7 @@ dropconstraint_internal(Relation rel, HeapTuple constraintTup, DropBehavior beha
static void
ATPrepAlterColumnType(List **wqueue,
AlteredTableInfo *tab, Relation rel,
- bool recurse, bool recursing,
+ bool no_only, bool recursing,
AlterTableCmd *cmd, LOCKMODE lockmode,
AlterTableUtilityContext *context)
{
@@ -14592,10 +14593,10 @@ ATPrepAlterColumnType(List **wqueue,
* necessary. We cannot apply ATSimpleRecursion here because we need to
* remap attribute numbers in the USING expression, if any.
*
- * If we are told not to recurse, there had better not be any child
- * tables; else the alter would put them out of step.
+ * If we are told not to recurse (ONLY is not set), there had better not
+ * be any child tables; else the alter would put them out of step.
*/
- if (recurse)
+ if (no_only)
{
Oid relid = RelationGetRelid(rel);
List *child_oids,
@@ -17232,11 +17233,11 @@ index_copy_data(Relation rel, RelFileLocator newrlocator)
*/
static void
ATExecEnableDisableTrigger(Relation rel, const char *trigname,
- char fires_when, bool skip_system, bool recurse,
+ char fires_when, bool skip_system, bool no_only,
LOCKMODE lockmode)
{
EnableDisableTrigger(rel, trigname, InvalidOid,
- fires_when, skip_system, recurse,
+ fires_when, skip_system, no_only,
lockmode);
InvokeObjectPostAlterHook(RelationRelationId,
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index 646d6ced763..5fbfa2b6a4a 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -2524,7 +2524,7 @@ typedef struct AlterTableCmd /* one subcommand of an ALTER TABLE */
* constraint, or parent table */
DropBehavior behavior; /* RESTRICT or CASCADE for DROP cases */
bool missing_ok; /* skip error if missing? */
- bool recurse; /* exec-time recursion */
+ bool no_only; /* ONLY not set, meaning exec-time recursion */
} AlterTableCmd;
/* Ad-hoc node for AT_AlterConstraint */
--
2.39.5 (Apple Git-154)
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: tablecmds: clarify recurse vs recusing
@ 2026-01-19 15:50 Peter Eisentraut <[email protected]>
parent: Chao Li <[email protected]>
0 siblings, 1 reply; 5+ messages in thread
From: Peter Eisentraut @ 2026-01-19 15:50 UTC (permalink / raw)
To: Chao Li <[email protected]>; Postgres hackers <[email protected]>
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.
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: tablecmds: clarify recurse vs recusing
@ 2026-01-19 16:14 Tom Lane <[email protected]>
parent: Peter Eisentraut <[email protected]>
0 siblings, 1 reply; 5+ messages in thread
From: Tom Lane @ 2026-01-19 16:14 UTC (permalink / raw)
To: Peter Eisentraut <[email protected]>; +Cc: Chao Li <[email protected]>; Postgres hackers <[email protected]>
Peter Eisentraut <[email protected]> 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
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: tablecmds: clarify recurse vs recusing
@ 2026-01-20 03:45 Chao Li <[email protected]>
parent: Tom Lane <[email protected]>
0 siblings, 0 replies; 5+ messages in thread
From: Chao Li @ 2026-01-20 03:45 UTC (permalink / raw)
To: Tom Lane <[email protected]>; +Cc: Peter Eisentraut <[email protected]>; Postgres hackers <[email protected]>
On Jan 20, 2026, at 00:14, Tom Lane <[email protected]> wrote:
Peter Eisentraut <[email protected]> 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/
Attachments:
[application/octet-stream] v2-0001-tablecmds-clarify-recurse-recursing-semantics-in-.patch (9.5K, ../../CAEoWx2=QnOBUCuTg4rt7n0FjyvhBfztWMffSdObGCbGrz2tg6w@mail.gmail.com/3-v2-0001-tablecmds-clarify-recurse-recursing-semantics-in-.patch)
download | inline diff:
From 06dfb424266230cc04f1cbb5c891817e59ee2153 Mon Sep 17 00:00:00 2001
From: "Chao Li (Evan)" <[email protected]>
Date: Tue, 20 Jan 2026 09:57:24 +0800
Subject: [PATCH v2 1/2] tablecmds: clarify recurse/recursing semantics in
ALTER TABLE code
Add clearer documentation of the recurse and recursing flags used by
ALTER TABLE processing. Centralize the explanation in ATPrepCmd(), add a
brief description in ATController(), and replace repeated local comments
with references to the central explanation.
No functional changes; documentation and comments only.
Author: Chao Li <[email protected]>
---
src/backend/commands/tablecmds.c | 60 +++++++++++++++++++++++++++++---
1 file changed, 55 insertions(+), 5 deletions(-)
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index f976c0e5c7e..5194ffc84bb 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -4518,11 +4518,10 @@ AlterTableLookupRelation(AlterTableStmt *stmt, LOCKMODE lockmode)
*
* The caller must lock the relation, with an appropriate lock level
* for the subcommands requested, using AlterTableGetLockLevel(stmt->cmds)
- * or higher. We pass the lock level down
- * so that we can apply it recursively to inherited tables. Note that the
- * lock level we want as we recurse might well be higher than required for
- * that specific subcommand. So we pass down the overall lock requirement,
- * rather than reassess it at lower levels.
+ * or higher. We pass the lock level down so that we can apply it recursively
+ * to inherited tables. Note that the lock level we want as we recurse might
+ * well be higher than required for that specific subcommand. So we pass down
+ * the overall lock requirement, rather than reassess it at lower levels.
*
* The caller also provides a "context" which is to be passed back to
* utility.c when we need to execute a subcommand such as CREATE INDEX.
@@ -4868,6 +4867,11 @@ AlterTableGetLockLevel(List *cmds)
*
* parsetree is passed in to allow it to be passed to event triggers
* when requested.
+ *
+ * recurse indicates whether the ALTER TABLE command should recurse to
+ * child tables. At the top level this usually corresponds to the absence
+ * of ONLY in the command, as determined in AlterTable(). The value is
+ * passed down to lower-level helpers such as ATPrepCmd().
*/
static void
ATController(AlterTableStmt *parsetree,
@@ -4903,6 +4907,20 @@ ATController(AlterTableStmt *parsetree,
*
* Caller must have acquired appropriate lock type on relation already.
* This lock should be held until commit.
+ *
+ * The recurse argument tells whether we should recurse to child tables
+ * if the command type supports that. The recursing argument tells whether
+ * we are being called as part of such a recursion. At a top-level call,
+ * recurse generally reflects that the user did not specify ONLY in the
+ * command, subject to the command's recursion semantics.
+ *
+ * recurse=false, recursing=false: top-level call, no recursion
+ * recurse=true, recursing=false: top-level call, recurse if supported
+ * recurse=true, recursing=true: recursive call, continue recursion
+ * recurse=false, recursing=true: recursive call, stop recursion
+ *
+ * "Children" or "child tables" mean inheritance children, partitions, or both,
+ * depending on the command type.
*/
static void
ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
@@ -7217,6 +7235,8 @@ check_of_type(HeapTuple typetuple)
* actually add a column or merely merge with an existing column. (We can't
* check this in a static pre-pass because it won't handle multiple inheritance
* situations correctly.)
+ *
+ * recurse / recursing semantics: see ATPrepCmd()
*/
static void
ATPrepAddColumn(List **wqueue, Relation rel, bool recurse, bool recursing,
@@ -7241,6 +7261,8 @@ ATPrepAddColumn(List **wqueue, Relation rel, bool recurse, bool recursing,
*
* cmd is pass-by-ref so that we can replace it with the parse-transformed
* copy (but that happens only after we check for IF NOT EXISTS).
+ *
+ * recurse / recursing semantics: see ATPrepCmd()
*/
static ObjectAddress
ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
@@ -7937,6 +7959,8 @@ set_attnotnull(List **wqueue, Relation rel, AttrNumber attnum,
*
* We must recurse to child tables during execution, rather than using
* ALTER TABLE's normal prep-time recursion.
+ *
+ * recurse / recursing semantics: see ATPrepCmd()
*/
static ObjectAddress
ATExecSetNotNull(List **wqueue, Relation rel, char *conName, char *colName,
@@ -8264,6 +8288,8 @@ ATExecCookedColumnDefault(Relation rel, AttrNumber attnum,
* ALTER TABLE ALTER COLUMN ADD IDENTITY
*
* Return the address of the affected column.
+ *
+ * recurse / recursing semantics: see ATPrepCmd()
*/
static ObjectAddress
ATExecAddIdentity(Relation rel, const char *colName,
@@ -8395,6 +8421,8 @@ ATExecAddIdentity(Relation rel, const char *colName,
* ALTER TABLE ALTER COLUMN SET { GENERATED or sequence options }
*
* Return the address of the affected column.
+ *
+ * recurse / recursing semantics: see ATPrepCmd()
*/
static ObjectAddress
ATExecSetIdentity(Relation rel, const char *colName, Node *def,
@@ -8512,6 +8540,8 @@ ATExecSetIdentity(Relation rel, const char *colName, Node *def,
* ALTER TABLE ALTER COLUMN DROP IDENTITY
*
* Return the address of the affected column.
+ *
+ * recurse / recursing semantics: see ATPrepCmd()
*/
static ObjectAddress
ATExecDropIdentity(Relation rel, const char *colName, bool missing_ok, LOCKMODE lockmode,
@@ -8780,6 +8810,8 @@ ATExecSetExpression(AlteredTableInfo *tab, Relation rel, const char *colName,
/*
* ALTER TABLE ALTER COLUMN DROP EXPRESSION
+ *
+ * recurse / recursing semantics: see ATPrepCmd()
*/
static void
ATPrepDropExpression(Relation rel, AlterTableCmd *cmd, bool recurse, bool recursing, LOCKMODE lockmode)
@@ -9280,6 +9312,8 @@ ATExecSetStorage(Relation rel, const char *colName, Node *newValue, LOCKMODE loc
* on whether attinhcount goes to zero or not. (We can't check this in a
* static pre-pass because it won't handle multiple inheritance situations
* correctly.)
+ *
+ * recurse / recursing semantics: see ATPrepCmd()
*/
static void
ATPrepDropColumn(List **wqueue, Relation rel, bool recurse, bool recursing,
@@ -9308,6 +9342,8 @@ ATPrepDropColumn(List **wqueue, Relation rel, bool recurse, bool recursing,
* is added to 'addrs', which must be non-NULL in such invocations. All
* columns are dropped at the same time after all the children have been
* checked recursively.
+ *
+ * recurse / recursing semantics: see ATPrepCmd()
*/
static ObjectAddress
ATExecDropColumn(List **wqueue, Relation rel, const char *colName,
@@ -9937,6 +9973,8 @@ ChooseForeignKeyConstraintNameAddition(List *colnames)
* AddRelationNewConstraints would normally assign different names to the
* child constraints. To fix that, we must capture the name assigned at
* the parent table and pass that down.
+ *
+ * recurse / recursing semantics: see ATPrepCmd()
*/
static ObjectAddress
ATAddCheckNNConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
@@ -10092,6 +10130,8 @@ ATAddCheckNNConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
* thereof). We also need action triggers on each leaf partition on the
* referenced side, and check triggers on each leaf partition on the
* referencing side.
+ *
+ * recurse / recursing semantics: see ATPrepCmd()
*/
static ObjectAddress
ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
@@ -12933,6 +12973,8 @@ AlterConstrUpdateConstraintEntry(ATAlterConstraint *cmdcon, Relation conrel,
*
* Return value is the address of the validated constraint. If the constraint
* was already validated, InvalidObjectAddress is returned.
+ *
+ * recurse / recursing semantics: see ATPrepCmd()
*/
static ObjectAddress
ATExecValidateConstraint(List **wqueue, Relation rel, char *constrName,
@@ -13142,6 +13184,8 @@ QueueFKConstraintValidation(List **wqueue, Relation conrel, Relation fkrel,
* Add an entry to the wqueue to validate the given check constraint in Phase 3
* and update the convalidated field in the pg_constraint catalog for the
* specified relation and all its inheriting children.
+ *
+ * recurse / recursing semantics: see ATPrepCmd()
*/
static void
QueueCheckConstraintValidation(List **wqueue, Relation conrel, Relation rel,
@@ -13245,6 +13289,8 @@ QueueCheckConstraintValidation(List **wqueue, Relation conrel, Relation rel,
* Add an entry to the wqueue to validate the given not-null constraint in
* Phase 3 and update the convalidated field in the pg_constraint catalog for
* the specified relation and all its inheriting children.
+ *
+ * recurse / recursing semantics: see ATPrepCmd()
*/
static void
QueueNNConstraintValidation(List **wqueue, Relation conrel, Relation rel,
@@ -14102,6 +14148,8 @@ ATExecDropConstraint(Relation rel, const char *constrName,
* DROP NOT NULL.
*
* Returns the address of the constraint being removed.
+ *
+ * recurse / recursing semantics: see ATPrepCmd()
*/
static ObjectAddress
dropconstraint_internal(Relation rel, HeapTuple constraintTup, DropBehavior behavior,
@@ -14398,6 +14446,8 @@ dropconstraint_internal(Relation rel, HeapTuple constraintTup, DropBehavior beha
* the first two execution steps in phase 2; they must not see the effects
* of any other subcommand types, since the USING expressions are parsed
* against the unmodified table's state.
+ *
+ * recurse / recursing semantics: see ATPrepCmd()
*/
static void
ATPrepAlterColumnType(List **wqueue,
--
2.39.5 (Apple Git-154)
[application/octet-stream] v2-0002-tablecmds-complete-parameter-documentation-for-ad.patch (1.2K, ../../CAEoWx2=QnOBUCuTg4rt7n0FjyvhBfztWMffSdObGCbGrz2tg6w@mail.gmail.com/4-v2-0002-tablecmds-complete-parameter-documentation-for-ad.patch)
download | inline diff:
From fd78e3751f964388fec04bf6204ea5bf90664a80 Mon Sep 17 00:00:00 2001
From: "Chao Li (Evan)" <[email protected]>
Date: Tue, 20 Jan 2026 10:26:27 +0800
Subject: [PATCH v2 2/2] tablecmds: complete parameter documentation for
addFkConstraint
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The header comment for addFkConstraint() documents all of
the function’s parameters except is_internal. Add a brief description
of is_internal so that the comment fully reflects the function
signature.
Author: Chao Li <[email protected]>
---
src/backend/commands/tablecmds.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 5194ffc84bb..767488acd0c 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -10786,6 +10786,7 @@ validateFkOnDeleteSetColumns(int numfks, const int16 *fkattnums,
* (...) clause
* fkdelsetcols: the attnum array of the columns in the ON DELETE SET
* NULL/DEFAULT clause
+ * is_internal: true if this is an internally generated constraint
* with_period: true if this is a temporal FK
*/
static ObjectAddress
--
2.39.5 (Apple Git-154)
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2026-01-20 03:45 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-01-20 11:57 [PATCH v5 1/3] Test for snapshot too old and wal_level=minimal Kyotaro Horiguchi <[email protected]>
2026-01-19 07:14 tablecmds: clarify recurse vs recusing Chao Li <[email protected]>
2026-01-19 15:50 ` Re: tablecmds: clarify recurse vs recusing Peter Eisentraut <[email protected]>
2026-01-19 16:14 ` Re: tablecmds: clarify recurse vs recusing Tom Lane <[email protected]>
2026-01-20 03:45 ` Re: tablecmds: clarify recurse vs recusing Chao Li <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox