@@ -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)
42764275break;
42774276
42784277case AT_AddConstraint:
4279- case AT_AddConstraintRecurse:/* becomes AT_AddConstraint */
42804278case AT_ReAddConstraint:/* becomes AT_AddConstraint */
42814279case AT_ReAddDomainConstraint:/* becomes AT_AddConstraint */
42824280if (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 */
46304628if (recurse)
4631- cmd->subtype =AT_AddConstraintRecurse ;
4629+ cmd->recurse =true ;
46324630pass = AT_PASS_ADD_CONSTR;
46334631break;
46344632case 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 */
46454643if (recurse)
4646- cmd->subtype =AT_DropConstraintRecurse ;
4644+ cmd->recurse =true ;
46474645pass = AT_PASS_DROP;
46484646break;
46494647case 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 */
47674765if (recurse)
4768- cmd->subtype =AT_ValidateConstraintRecurse ;
4766+ cmd->recurse =true ;
47694767pass = AT_PASS_MISC;
47704768break;
47714769case AT_ReplicaIdentity:/* REPLICA IDENTITY ... */
@@ -4930,12 +4928,7 @@ ATExecCmd(List **wqueue, AlteredTableInfo *tab,
49304928case AT_AddColumn:/* ADD COLUMN */
49314929case AT_AddColumnToView:/* add column via CREATE OR REPLACE VIEW */
49324930address = 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);
49404933break;
49414934case AT_ColumnDefault:/* ALTER COLUMN DEFAULT */
@@ -4989,13 +4982,7 @@ ATExecCmd(List **wqueue, AlteredTableInfo *tab,
49894982break;
49904983case AT_DropColumn:/* DROP COLUMN */
49914984address = 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);
50014988break;
@@ -5015,27 +5002,14 @@ ATExecCmd(List **wqueue, AlteredTableInfo *tab,
50155002/* Transform the command only during initial examination */
50165003if (cur_pass == AT_PASS_ADD_CONSTR)
50175004cmd = 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 */
50215008if (cmd != NULL)
50225009address =
50235010ATExecAddConstraint(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);
50395013break;
50405014case AT_ReAddConstraint:/* Re-add pre-existing check constraint */
50415015address =
@@ -5060,22 +5034,12 @@ ATExecCmd(List **wqueue, AlteredTableInfo *tab,
50605034address = ATExecAlterConstraint(rel, cmd, false, false, lockmode);
50615035break;
50625036case 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);
50705039break;
50715040case AT_DropConstraint: /* DROP CONSTRAINT */
50725041ATExecDropConstraint(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);
50805044break;
50815045case AT_AlterColumnType:/* ALTER COLUMN TYPE */
@@ -5351,7 +5315,7 @@ ATParseTransformCmd(List **wqueue, AlteredTableInfo *tab, Relation rel,
53515315case AT_AddConstraint:
53525316/* Recursion occurs during execution phase */
53535317if (recurse)
5354- cmd2->subtype =AT_AddConstraintRecurse ;
5318+ cmd2->recurse =true ;
53555319switch (castNode(Constraint, cmd2->def)->contype)
53565320{
53575321case CONSTR_PRIMARY:
@@ -6110,7 +6074,6 @@ alter_table_type_to_string(AlterTableType cmdtype)
61106074switch (cmdtype)
61116075{
61126076case AT_AddColumn:
6113- case AT_AddColumnRecurse:
61146077case AT_AddColumnToView:
61156078return "ADD COLUMN";
61166079case AT_ColumnDefault:
@@ -6135,24 +6098,20 @@ alter_table_type_to_string(AlterTableType cmdtype)
61356098case AT_SetCompression:
61366099return "ALTER COLUMN ... SET COMPRESSION";
61376100case AT_DropColumn:
6138- case AT_DropColumnRecurse:
61396101return "DROP COLUMN";
61406102case AT_AddIndex:
61416103case AT_ReAddIndex:
61426104return NULL;/* not real grammar */
61436105case AT_AddConstraint:
6144- case AT_AddConstraintRecurse:
61456106case AT_ReAddConstraint:
61466107case AT_ReAddDomainConstraint:
61476108case AT_AddIndexConstraint:
61486109return "ADD CONSTRAINT";
61496110case AT_AlterConstraint:
61506111return "ALTER CONSTRAINT";
61516112case AT_ValidateConstraint:
6152- case AT_ValidateConstraintRecurse:
61536113return "VALIDATE CONSTRAINT";
61546114case AT_DropConstraint:
6155- case AT_DropConstraintRecurse:
61566115return "DROP CONSTRAINT";
61576116case AT_ReAddComment:
61586117return NULL;/* not real grammar */
@@ -6671,7 +6630,7 @@ ATPrepAddColumn(List **wqueue, Relation rel, bool recurse, bool recursing,
66716630ATTypedTableRecursion(wqueue, rel, cmd, lockmode, context);
66726631
66736632if (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,
83768335ATTypedTableRecursion(wqueue, rel, cmd, lockmode, context);
83778336
83788337if (recurse)
8379- cmd->subtype =AT_DropColumnRecurse ;
8338+ cmd->recurse =true ;
83808339}
83818340
83828341/*