diff options
-rw-r--r-- | src/backend/commands/tablecmds.c | 67 | ||||
-rw-r--r-- | src/backend/parser/parse_utilcmd.c | 2 | ||||
-rw-r--r-- | src/include/catalog/catversion.h | 2 | ||||
-rw-r--r-- | src/include/nodes/parsenodes.h | 5 | ||||
-rw-r--r-- | src/test/modules/test_ddl_deparse/test_ddl_deparse.c | 20 |
5 files changed, 18 insertions, 78 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; } /* diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c index 342a1791338..f743cd548c2 100644 --- a/src/backend/parser/parse_utilcmd.c +++ b/src/backend/parser/parse_utilcmd.c @@ -3362,7 +3362,6 @@ transformAlterTableStmt(Oid relid, AlterTableStmt *stmt, switch (cmd->subtype) { case AT_AddColumn: - case AT_AddColumnRecurse: { ColumnDef *def = castNode(ColumnDef, cmd->def); @@ -3386,7 +3385,6 @@ transformAlterTableStmt(Oid relid, AlterTableStmt *stmt, } case AT_AddConstraint: - case AT_AddConstraintRecurse: /* * The original AddConstraint cmd node doesn't go to newcmds diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index 501a434b904..f52ed8f929d 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -57,6 +57,6 @@ */ /* yyyymmddN */ -#define CATALOG_VERSION_NO 202212092 +#define CATALOG_VERSION_NO 202212121 #endif diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h index 8fe9b2fcfe9..bebb9620b27 100644 --- a/src/include/nodes/parsenodes.h +++ b/src/include/nodes/parsenodes.h @@ -1979,7 +1979,6 @@ typedef struct AlterTableStmt typedef enum AlterTableType { AT_AddColumn, /* add column */ - AT_AddColumnRecurse, /* internal to commands/tablecmds.c */ AT_AddColumnToView, /* implicitly via CREATE OR REPLACE VIEW */ AT_ColumnDefault, /* alter column default */ AT_CookedColumnDefault, /* add a pre-cooked column default */ @@ -1993,19 +1992,15 @@ typedef enum AlterTableType AT_SetStorage, /* alter column set storage */ AT_SetCompression, /* alter column set compression */ AT_DropColumn, /* drop column */ - AT_DropColumnRecurse, /* internal to commands/tablecmds.c */ AT_AddIndex, /* add index */ AT_ReAddIndex, /* internal to commands/tablecmds.c */ AT_AddConstraint, /* add constraint */ - AT_AddConstraintRecurse, /* internal to commands/tablecmds.c */ AT_ReAddConstraint, /* internal to commands/tablecmds.c */ AT_ReAddDomainConstraint, /* internal to commands/tablecmds.c */ AT_AlterConstraint, /* alter constraint */ AT_ValidateConstraint, /* validate constraint */ - AT_ValidateConstraintRecurse, /* internal to commands/tablecmds.c */ AT_AddIndexConstraint, /* add constraint using existing index */ AT_DropConstraint, /* drop constraint */ - AT_DropConstraintRecurse, /* internal to commands/tablecmds.c */ AT_ReAddComment, /* internal to commands/tablecmds.c */ AT_AlterColumnType, /* alter column type */ AT_AlterColumnGenericOptions, /* alter column OPTIONS (...) */ diff --git a/src/test/modules/test_ddl_deparse/test_ddl_deparse.c b/src/test/modules/test_ddl_deparse/test_ddl_deparse.c index 7e9e443306c..fa90b717489 100644 --- a/src/test/modules/test_ddl_deparse/test_ddl_deparse.c +++ b/src/test/modules/test_ddl_deparse/test_ddl_deparse.c @@ -114,9 +114,6 @@ get_altertable_subcmdinfo(PG_FUNCTION_ARGS) case AT_AddColumn: strtype = "ADD COLUMN"; break; - case AT_AddColumnRecurse: - strtype = "ADD COLUMN (and recurse)"; - break; case AT_AddColumnToView: strtype = "ADD COLUMN TO VIEW"; break; @@ -156,9 +153,6 @@ get_altertable_subcmdinfo(PG_FUNCTION_ARGS) case AT_DropColumn: strtype = "DROP COLUMN"; break; - case AT_DropColumnRecurse: - strtype = "DROP COLUMN (and recurse)"; - break; case AT_AddIndex: strtype = "ADD INDEX"; break; @@ -168,9 +162,6 @@ get_altertable_subcmdinfo(PG_FUNCTION_ARGS) case AT_AddConstraint: strtype = "ADD CONSTRAINT"; break; - case AT_AddConstraintRecurse: - strtype = "ADD CONSTRAINT (and recurse)"; - break; case AT_ReAddConstraint: strtype = "(re) ADD CONSTRAINT"; break; @@ -183,18 +174,12 @@ get_altertable_subcmdinfo(PG_FUNCTION_ARGS) case AT_ValidateConstraint: strtype = "VALIDATE CONSTRAINT"; break; - case AT_ValidateConstraintRecurse: - strtype = "VALIDATE CONSTRAINT (and recurse)"; - break; case AT_AddIndexConstraint: strtype = "ADD CONSTRAINT (using index)"; break; case AT_DropConstraint: strtype = "DROP CONSTRAINT"; break; - case AT_DropConstraintRecurse: - strtype = "DROP CONSTRAINT (and recurse)"; - break; case AT_ReAddComment: strtype = "(re) ADD COMMENT"; break; @@ -326,7 +311,10 @@ get_altertable_subcmdinfo(PG_FUNCTION_ARGS) break; } - values[0] = CStringGetTextDatum(strtype); + if (subcmd->recurse) + values[0] = CStringGetTextDatum(psprintf("%s (and recurse)", strtype)); + else + values[0] = CStringGetTextDatum(strtype); if (OidIsValid(sub->address.objectId)) { char *objdesc; |