@@ -4070,8 +4070,7 @@ AlterTableLookupRelation(AlterTableStmt *stmt, LOCKMODE lockmode)
4070
4070
* For most subcommand types, phases 2 and 3 do no explicit recursion,
4071
4071
* since phase 1 already does it. However, for certain subcommand types
4072
4072
* 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.
4075
4074
*
4076
4075
* Thanks to the magic of MVCC, an error anywhere along the way rolls back
4077
4076
* the whole operation; we don't have to do anything special to clean up.
@@ -4276,7 +4275,6 @@ AlterTableGetLockLevel(List *cmds)
4276
4275
break;
4277
4276
4278
4277
case AT_AddConstraint:
4279
- case AT_AddConstraintRecurse: /* becomes AT_AddConstraint */
4280
4278
case AT_ReAddConstraint: /* becomes AT_AddConstraint */
4281
4279
case AT_ReAddDomainConstraint: /* becomes AT_AddConstraint */
4282
4280
if (IsA(cmd->def, Constraint))
@@ -4628,7 +4626,7 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
4628
4626
/* Recursion occurs during execution phase */
4629
4627
/* No command-specific prep needed except saving recurse flag */
4630
4628
if (recurse)
4631
- cmd->subtype = AT_AddConstraintRecurse ;
4629
+ cmd->recurse = true ;
4632
4630
pass = AT_PASS_ADD_CONSTR;
4633
4631
break;
4634
4632
case AT_AddIndexConstraint: /* ADD CONSTRAINT USING INDEX */
@@ -4643,7 +4641,7 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
4643
4641
/* Other recursion occurs during execution phase */
4644
4642
/* No command-specific prep needed except saving recurse flag */
4645
4643
if (recurse)
4646
- cmd->subtype = AT_DropConstraintRecurse ;
4644
+ cmd->recurse = true ;
4647
4645
pass = AT_PASS_DROP;
4648
4646
break;
4649
4647
case AT_AlterColumnType: /* ALTER COLUMN TYPE */
@@ -4765,7 +4763,7 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
4765
4763
/* Recursion occurs during execution phase */
4766
4764
/* No command-specific prep needed except saving recurse flag */
4767
4765
if (recurse)
4768
- cmd->subtype = AT_ValidateConstraintRecurse ;
4766
+ cmd->recurse = true ;
4769
4767
pass = AT_PASS_MISC;
4770
4768
break;
4771
4769
case AT_ReplicaIdentity: /* REPLICA IDENTITY ... */
@@ -4930,12 +4928,7 @@ ATExecCmd(List **wqueue, AlteredTableInfo *tab,
4930
4928
case AT_AddColumn: /* ADD COLUMN */
4931
4929
case AT_AddColumnToView: /* add column via CREATE OR REPLACE VIEW */
4932
4930
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,
4939
4932
lockmode, cur_pass, context);
4940
4933
break;
4941
4934
case AT_ColumnDefault: /* ALTER COLUMN DEFAULT */
@@ -4989,13 +4982,7 @@ ATExecCmd(List **wqueue, AlteredTableInfo *tab,
4989
4982
break;
4990
4983
case AT_DropColumn: /* DROP COLUMN */
4991
4984
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,
4999
4986
cmd->missing_ok, lockmode,
5000
4987
NULL);
5001
4988
break;
@@ -5015,27 +5002,14 @@ ATExecCmd(List **wqueue, AlteredTableInfo *tab,
5015
5002
/* Transform the command only during initial examination */
5016
5003
if (cur_pass == AT_PASS_ADD_CONSTR)
5017
5004
cmd = ATParseTransformCmd(wqueue, tab, rel, cmd,
5018
- false , lockmode,
5005
+ cmd->recurse , lockmode,
5019
5006
cur_pass, context);
5020
5007
/* Depending on constraint type, might be no more work to do now */
5021
5008
if (cmd != NULL)
5022
5009
address =
5023
5010
ATExecAddConstraint(wqueue, tab, rel,
5024
5011
(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);
5039
5013
break;
5040
5014
case AT_ReAddConstraint: /* Re-add pre-existing check constraint */
5041
5015
address =
@@ -5060,22 +5034,12 @@ ATExecCmd(List **wqueue, AlteredTableInfo *tab,
5060
5034
address = ATExecAlterConstraint(rel, cmd, false, false, lockmode);
5061
5035
break;
5062
5036
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,
5069
5038
false, lockmode);
5070
5039
break;
5071
5040
case AT_DropConstraint: /* DROP CONSTRAINT */
5072
5041
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,
5079
5043
cmd->missing_ok, lockmode);
5080
5044
break;
5081
5045
case AT_AlterColumnType: /* ALTER COLUMN TYPE */
@@ -5351,7 +5315,7 @@ ATParseTransformCmd(List **wqueue, AlteredTableInfo *tab, Relation rel,
5351
5315
case AT_AddConstraint:
5352
5316
/* Recursion occurs during execution phase */
5353
5317
if (recurse)
5354
- cmd2->subtype = AT_AddConstraintRecurse ;
5318
+ cmd2->recurse = true ;
5355
5319
switch (castNode(Constraint, cmd2->def)->contype)
5356
5320
{
5357
5321
case CONSTR_PRIMARY:
@@ -6110,7 +6074,6 @@ alter_table_type_to_string(AlterTableType cmdtype)
6110
6074
switch (cmdtype)
6111
6075
{
6112
6076
case AT_AddColumn:
6113
- case AT_AddColumnRecurse:
6114
6077
case AT_AddColumnToView:
6115
6078
return "ADD COLUMN";
6116
6079
case AT_ColumnDefault:
@@ -6135,24 +6098,20 @@ alter_table_type_to_string(AlterTableType cmdtype)
6135
6098
case AT_SetCompression:
6136
6099
return "ALTER COLUMN ... SET COMPRESSION";
6137
6100
case AT_DropColumn:
6138
- case AT_DropColumnRecurse:
6139
6101
return "DROP COLUMN";
6140
6102
case AT_AddIndex:
6141
6103
case AT_ReAddIndex:
6142
6104
return NULL; /* not real grammar */
6143
6105
case AT_AddConstraint:
6144
- case AT_AddConstraintRecurse:
6145
6106
case AT_ReAddConstraint:
6146
6107
case AT_ReAddDomainConstraint:
6147
6108
case AT_AddIndexConstraint:
6148
6109
return "ADD CONSTRAINT";
6149
6110
case AT_AlterConstraint:
6150
6111
return "ALTER CONSTRAINT";
6151
6112
case AT_ValidateConstraint:
6152
- case AT_ValidateConstraintRecurse:
6153
6113
return "VALIDATE CONSTRAINT";
6154
6114
case AT_DropConstraint:
6155
- case AT_DropConstraintRecurse:
6156
6115
return "DROP CONSTRAINT";
6157
6116
case AT_ReAddComment:
6158
6117
return NULL; /* not real grammar */
@@ -6671,7 +6630,7 @@ ATPrepAddColumn(List **wqueue, Relation rel, bool recurse, bool recursing,
6671
6630
ATTypedTableRecursion(wqueue, rel, cmd, lockmode, context);
6672
6631
6673
6632
if (recurse && !is_view)
6674
- cmd->subtype = AT_AddColumnRecurse ;
6633
+ cmd->recurse = true ;
6675
6634
}
6676
6635
6677
6636
/*
@@ -8376,7 +8335,7 @@ ATPrepDropColumn(List **wqueue, Relation rel, bool recurse, bool recursing,
8376
8335
ATTypedTableRecursion(wqueue, rel, cmd, lockmode, context);
8377
8336
8378
8337
if (recurse)
8379
- cmd->subtype = AT_DropColumnRecurse ;
8338
+ cmd->recurse = true ;
8380
8339
}
8381
8340
8382
8341
/*
0 commit comments