@@ -4070,8 +4070,7 @@ AlterTableLookupRelation(AlterTableStmt *stmt, LOCKMODE lockmode)
40704070 * For most subcommand types, phases 2 and 3 do no explicit recursion,
40714071 * since phase 1 already does it. However, for certain subcommand types
40724072 * it is only possible to determine how to recurse at phase 2 time; for
4073- * those cases, phase 1 sets the cmd->recurse flag (or, in some older coding,
4074- * changes the command subtype of a "Recurse" variant XXX to be cleaned up.)
4073+ * those cases, phase 1 sets the cmd->recurse flag.
40754074 *
40764075 * Thanks to the magic of MVCC, an error anywhere along the way rolls back
40774076 * the whole operation; we don't have to do anything special to clean up.
@@ -4276,7 +4275,6 @@ AlterTableGetLockLevel(List *cmds)
42764275 break;
42774276
42784277 case AT_AddConstraint:
4279- case AT_AddConstraintRecurse: /* becomes AT_AddConstraint */
42804278 case AT_ReAddConstraint: /* becomes AT_AddConstraint */
42814279 case AT_ReAddDomainConstraint: /* becomes AT_AddConstraint */
42824280 if (IsA(cmd->def, Constraint))
@@ -4628,7 +4626,7 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
46284626 /* Recursion occurs during execution phase */
46294627 /* No command-specific prep needed except saving recurse flag */
46304628 if (recurse)
4631- cmd->subtype = AT_AddConstraintRecurse ;
4629+ cmd->recurse = true ;
46324630 pass = AT_PASS_ADD_CONSTR;
46334631 break;
46344632 case AT_AddIndexConstraint: /* ADD CONSTRAINT USING INDEX */
@@ -4643,7 +4641,7 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
46434641 /* Other recursion occurs during execution phase */
46444642 /* No command-specific prep needed except saving recurse flag */
46454643 if (recurse)
4646- cmd->subtype = AT_DropConstraintRecurse ;
4644+ cmd->recurse = true ;
46474645 pass = AT_PASS_DROP;
46484646 break;
46494647 case AT_AlterColumnType: /* ALTER COLUMN TYPE */
@@ -4765,7 +4763,7 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
47654763 /* Recursion occurs during execution phase */
47664764 /* No command-specific prep needed except saving recurse flag */
47674765 if (recurse)
4768- cmd->subtype = AT_ValidateConstraintRecurse ;
4766+ cmd->recurse = true ;
47694767 pass = AT_PASS_MISC;
47704768 break;
47714769 case AT_ReplicaIdentity: /* REPLICA IDENTITY ... */
@@ -4930,12 +4928,7 @@ ATExecCmd(List **wqueue, AlteredTableInfo *tab,
49304928 case AT_AddColumn: /* ADD COLUMN */
49314929 case AT_AddColumnToView: /* add column via CREATE OR REPLACE VIEW */
49324930 address = ATExecAddColumn(wqueue, tab, rel, &cmd,
4933- false, false,
4934- lockmode, cur_pass, context);
4935- break;
4936- case AT_AddColumnRecurse:
4937- address = ATExecAddColumn(wqueue, tab, rel, &cmd,
4938- true, false,
4931+ cmd->recurse, false,
49394932 lockmode, cur_pass, context);
49404933 break;
49414934 case AT_ColumnDefault: /* ALTER COLUMN DEFAULT */
@@ -4989,13 +4982,7 @@ ATExecCmd(List **wqueue, AlteredTableInfo *tab,
49894982 break;
49904983 case AT_DropColumn: /* DROP COLUMN */
49914984 address = ATExecDropColumn(wqueue, rel, cmd->name,
4992- cmd->behavior, false, false,
4993- cmd->missing_ok, lockmode,
4994- NULL);
4995- break;
4996- case AT_DropColumnRecurse: /* DROP COLUMN with recursion */
4997- address = ATExecDropColumn(wqueue, rel, cmd->name,
4998- cmd->behavior, true, false,
4985+ cmd->behavior, cmd->recurse, false,
49994986 cmd->missing_ok, lockmode,
50004987 NULL);
50014988 break;
@@ -5015,27 +5002,14 @@ ATExecCmd(List **wqueue, AlteredTableInfo *tab,
50155002 /* Transform the command only during initial examination */
50165003 if (cur_pass == AT_PASS_ADD_CONSTR)
50175004 cmd = ATParseTransformCmd(wqueue, tab, rel, cmd,
5018- false , lockmode,
5005+ cmd->recurse , lockmode,
50195006 cur_pass, context);
50205007 /* Depending on constraint type, might be no more work to do now */
50215008 if (cmd != NULL)
50225009 address =
50235010 ATExecAddConstraint(wqueue, tab, rel,
50245011 (Constraint *) cmd->def,
5025- false, false, lockmode);
5026- break;
5027- case AT_AddConstraintRecurse: /* ADD CONSTRAINT with recursion */
5028- /* Transform the command only during initial examination */
5029- if (cur_pass == AT_PASS_ADD_CONSTR)
5030- cmd = ATParseTransformCmd(wqueue, tab, rel, cmd,
5031- true, lockmode,
5032- cur_pass, context);
5033- /* Depending on constraint type, might be no more work to do now */
5034- if (cmd != NULL)
5035- address =
5036- ATExecAddConstraint(wqueue, tab, rel,
5037- (Constraint *) cmd->def,
5038- true, false, lockmode);
5012+ cmd->recurse, false, lockmode);
50395013 break;
50405014 case AT_ReAddConstraint: /* Re-add pre-existing check constraint */
50415015 address =
@@ -5060,22 +5034,12 @@ ATExecCmd(List **wqueue, AlteredTableInfo *tab,
50605034 address = ATExecAlterConstraint(rel, cmd, false, false, lockmode);
50615035 break;
50625036 case AT_ValidateConstraint: /* VALIDATE CONSTRAINT */
5063- address = ATExecValidateConstraint(wqueue, rel, cmd->name, false,
5064- false, lockmode);
5065- break;
5066- case AT_ValidateConstraintRecurse: /* VALIDATE CONSTRAINT with
5067- * recursion */
5068- address = ATExecValidateConstraint(wqueue, rel, cmd->name, true,
5037+ address = ATExecValidateConstraint(wqueue, rel, cmd->name, cmd->recurse,
50695038 false, lockmode);
50705039 break;
50715040 case AT_DropConstraint: /* DROP CONSTRAINT */
50725041 ATExecDropConstraint(rel, cmd->name, cmd->behavior,
5073- false, false,
5074- cmd->missing_ok, lockmode);
5075- break;
5076- case AT_DropConstraintRecurse: /* DROP CONSTRAINT with recursion */
5077- ATExecDropConstraint(rel, cmd->name, cmd->behavior,
5078- true, false,
5042+ cmd->recurse, false,
50795043 cmd->missing_ok, lockmode);
50805044 break;
50815045 case AT_AlterColumnType: /* ALTER COLUMN TYPE */
@@ -5351,7 +5315,7 @@ ATParseTransformCmd(List **wqueue, AlteredTableInfo *tab, Relation rel,
53515315 case AT_AddConstraint:
53525316 /* Recursion occurs during execution phase */
53535317 if (recurse)
5354- cmd2->subtype = AT_AddConstraintRecurse ;
5318+ cmd2->recurse = true ;
53555319 switch (castNode(Constraint, cmd2->def)->contype)
53565320 {
53575321 case CONSTR_PRIMARY:
@@ -6110,7 +6074,6 @@ alter_table_type_to_string(AlterTableType cmdtype)
61106074 switch (cmdtype)
61116075 {
61126076 case AT_AddColumn:
6113- case AT_AddColumnRecurse:
61146077 case AT_AddColumnToView:
61156078 return "ADD COLUMN";
61166079 case AT_ColumnDefault:
@@ -6135,24 +6098,20 @@ alter_table_type_to_string(AlterTableType cmdtype)
61356098 case AT_SetCompression:
61366099 return "ALTER COLUMN ... SET COMPRESSION";
61376100 case AT_DropColumn:
6138- case AT_DropColumnRecurse:
61396101 return "DROP COLUMN";
61406102 case AT_AddIndex:
61416103 case AT_ReAddIndex:
61426104 return NULL; /* not real grammar */
61436105 case AT_AddConstraint:
6144- case AT_AddConstraintRecurse:
61456106 case AT_ReAddConstraint:
61466107 case AT_ReAddDomainConstraint:
61476108 case AT_AddIndexConstraint:
61486109 return "ADD CONSTRAINT";
61496110 case AT_AlterConstraint:
61506111 return "ALTER CONSTRAINT";
61516112 case AT_ValidateConstraint:
6152- case AT_ValidateConstraintRecurse:
61536113 return "VALIDATE CONSTRAINT";
61546114 case AT_DropConstraint:
6155- case AT_DropConstraintRecurse:
61566115 return "DROP CONSTRAINT";
61576116 case AT_ReAddComment:
61586117 return NULL; /* not real grammar */
@@ -6671,7 +6630,7 @@ ATPrepAddColumn(List **wqueue, Relation rel, bool recurse, bool recursing,
66716630 ATTypedTableRecursion(wqueue, rel, cmd, lockmode, context);
66726631
66736632 if (recurse && !is_view)
6674- cmd->subtype = AT_AddColumnRecurse ;
6633+ cmd->recurse = true ;
66756634}
66766635
66776636/*
@@ -8376,7 +8335,7 @@ ATPrepDropColumn(List **wqueue, Relation rel, bool recurse, bool recursing,
83768335 ATTypedTableRecursion(wqueue, rel, cmd, lockmode, context);
83778336
83788337 if (recurse)
8379- cmd->subtype = AT_DropColumnRecurse ;
8338+ cmd->recurse = true ;
83808339}
83818340
83828341/*
0 commit comments