diff options
Diffstat (limited to 'src/backend/commands/tablecmds.c')
-rw-r--r-- | src/backend/commands/tablecmds.c | 67 |
1 files changed, 13 insertions, 54 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index ee88e87d76d..0b352a5fff6 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -4070,8 +4070,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 (or, in some older coding, - * changes the command subtype of a "Recurse" variant XXX to be cleaned up.) + * those cases, phase 1 sets the cmd->recurse 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. @@ -4276,7 +4275,6 @@ AlterTableGetLockLevel(List *cmds) break; case AT_AddConstraint: - case AT_AddConstraintRecurse: /* becomes AT_AddConstraint */ case AT_ReAddConstraint: /* becomes AT_AddConstraint */ case AT_ReAddDomainConstraint: /* becomes AT_AddConstraint */ if (IsA(cmd->def, Constraint)) @@ -4628,7 +4626,7 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd, /* Recursion occurs during execution phase */ /* No command-specific prep needed except saving recurse flag */ if (recurse) - cmd->subtype = AT_AddConstraintRecurse; + cmd->recurse = true; pass = AT_PASS_ADD_CONSTR; break; case AT_AddIndexConstraint: /* ADD CONSTRAINT USING INDEX */ @@ -4643,7 +4641,7 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd, /* Other recursion occurs during execution phase */ /* No command-specific prep needed except saving recurse flag */ if (recurse) - cmd->subtype = AT_DropConstraintRecurse; + cmd->recurse = true; pass = AT_PASS_DROP; break; case AT_AlterColumnType: /* ALTER COLUMN TYPE */ @@ -4765,7 +4763,7 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd, /* Recursion occurs during execution phase */ /* No command-specific prep needed except saving recurse flag */ if (recurse) - cmd->subtype = AT_ValidateConstraintRecurse; + cmd->recurse = true; pass = AT_PASS_MISC; break; case AT_ReplicaIdentity: /* REPLICA IDENTITY ... */ @@ -4930,12 +4928,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, - false, false, - lockmode, cur_pass, context); - break; - case AT_AddColumnRecurse: - address = ATExecAddColumn(wqueue, tab, rel, &cmd, - true, false, + cmd->recurse, false, lockmode, cur_pass, context); break; case AT_ColumnDefault: /* ALTER COLUMN DEFAULT */ @@ -4989,13 +4982,7 @@ ATExecCmd(List **wqueue, AlteredTableInfo *tab, break; case AT_DropColumn: /* DROP COLUMN */ address = ATExecDropColumn(wqueue, rel, cmd->name, - cmd->behavior, false, false, - cmd->missing_ok, lockmode, - NULL); - break; - case AT_DropColumnRecurse: /* DROP COLUMN with recursion */ - address = ATExecDropColumn(wqueue, rel, cmd->name, - cmd->behavior, true, false, + cmd->behavior, cmd->recurse, false, cmd->missing_ok, lockmode, NULL); break; @@ -5015,27 +5002,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, - false, lockmode, + cmd->recurse, 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, - false, false, lockmode); - break; - case AT_AddConstraintRecurse: /* ADD CONSTRAINT with recursion */ - /* Transform the command only during initial examination */ - if (cur_pass == AT_PASS_ADD_CONSTR) - cmd = ATParseTransformCmd(wqueue, tab, rel, cmd, - true, 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, - true, false, lockmode); + cmd->recurse, false, lockmode); break; case AT_ReAddConstraint: /* Re-add pre-existing check constraint */ address = @@ -5060,22 +5034,12 @@ ATExecCmd(List **wqueue, AlteredTableInfo *tab, address = ATExecAlterConstraint(rel, cmd, false, false, lockmode); break; case AT_ValidateConstraint: /* VALIDATE CONSTRAINT */ - address = ATExecValidateConstraint(wqueue, rel, cmd->name, false, - false, lockmode); - break; - case AT_ValidateConstraintRecurse: /* VALIDATE CONSTRAINT with - * recursion */ - address = ATExecValidateConstraint(wqueue, rel, cmd->name, true, + address = ATExecValidateConstraint(wqueue, rel, cmd->name, cmd->recurse, false, lockmode); break; case AT_DropConstraint: /* DROP CONSTRAINT */ ATExecDropConstraint(rel, cmd->name, cmd->behavior, - false, false, - cmd->missing_ok, lockmode); - break; - case AT_DropConstraintRecurse: /* DROP CONSTRAINT with recursion */ - ATExecDropConstraint(rel, cmd->name, cmd->behavior, - true, false, + cmd->recurse, false, cmd->missing_ok, lockmode); break; case AT_AlterColumnType: /* ALTER COLUMN TYPE */ @@ -5351,7 +5315,7 @@ ATParseTransformCmd(List **wqueue, AlteredTableInfo *tab, Relation rel, case AT_AddConstraint: /* Recursion occurs during execution phase */ if (recurse) - cmd2->subtype = AT_AddConstraintRecurse; + cmd2->recurse = true; switch (castNode(Constraint, cmd2->def)->contype) { case CONSTR_PRIMARY: @@ -6110,7 +6074,6 @@ alter_table_type_to_string(AlterTableType cmdtype) switch (cmdtype) { case AT_AddColumn: - case AT_AddColumnRecurse: case AT_AddColumnToView: return "ADD COLUMN"; case AT_ColumnDefault: @@ -6135,13 +6098,11 @@ alter_table_type_to_string(AlterTableType cmdtype) case AT_SetCompression: return "ALTER COLUMN ... SET COMPRESSION"; case AT_DropColumn: - case AT_DropColumnRecurse: return "DROP COLUMN"; case AT_AddIndex: case AT_ReAddIndex: return NULL; /* not real grammar */ case AT_AddConstraint: - case AT_AddConstraintRecurse: case AT_ReAddConstraint: case AT_ReAddDomainConstraint: case AT_AddIndexConstraint: @@ -6149,10 +6110,8 @@ alter_table_type_to_string(AlterTableType cmdtype) case AT_AlterConstraint: return "ALTER CONSTRAINT"; case AT_ValidateConstraint: - case AT_ValidateConstraintRecurse: return "VALIDATE CONSTRAINT"; case AT_DropConstraint: - case AT_DropConstraintRecurse: return "DROP CONSTRAINT"; case AT_ReAddComment: return NULL; /* not real grammar */ @@ -6671,7 +6630,7 @@ ATPrepAddColumn(List **wqueue, Relation rel, bool recurse, bool recursing, ATTypedTableRecursion(wqueue, rel, cmd, lockmode, context); if (recurse && !is_view) - cmd->subtype = AT_AddColumnRecurse; + cmd->recurse = true; } /* @@ -8376,7 +8335,7 @@ ATPrepDropColumn(List **wqueue, Relation rel, bool recurse, bool recursing, ATTypedTableRecursion(wqueue, rel, cmd, lockmode, context); if (recurse) - cmd->subtype = AT_DropColumnRecurse; + cmd->recurse = true; } /* |