feat: ADR-0035 4f — ALTER TABLE … ALTER COLUMN TYPE

Fourth AlterTableAction (AlterColumnType), runtime-decomposed to the
existing change_column_type executor with ForceConversion — which IS the
§7 advanced policy: lossy converts with a note (no force flag),
incompatible + the ADR-0017 static refusals (↔blob, same-type,
date↔datetime, non-int→serial) still refuse, while int→serial is allowed
(auto-fills nulls + UNIQUE, ADR-0018 §8). No new mode/note/persistence;
undo is the advanced safety net.

Grammar adds a fourth action branch leading on `alter`, discriminated in
the builder by the `type` keyword (unique — ADD COLUMN's type is an
ident); the type slot reuses SQL_TYPE. The internal-__rdbms_* guard was
folded into do_change_column_type (user-confirmed), closing the simple
`change column` exposure.

Tests: 7 Tier-3 e2e via run_replay + 4 Tier-1 parse (incl. a column-named-
`type` discriminator probe) + the simple-surface guard. Help/usage
refreshed; ADR-0035 §13 4f + README + requirements.md in lockstep.
This commit is contained in:
claude@clouddev1
2026-05-25 21:16:37 +00:00
parent a2fc3c9e57
commit 5b76315d1e
11 changed files with 479 additions and 36 deletions
+11 -3
View File
@@ -714,9 +714,11 @@ pub enum IndexSelector {
Columns { table: String, columns: Vec<String> },
}
/// The action of an advanced-mode `ALTER TABLE` (ADR-0035 §4). Sub-phase
/// 4e carries the column actions; 4f/4g/4h add `AlterColumnType`,
/// `AddConstraint`/`AddForeignKey`/`DropConstraint`, and `RenameTo`.
/// The action of an advanced-mode `ALTER TABLE` (ADR-0035 §4).
///
/// Sub-phase 4e carries the column actions; 4f adds `AlterColumnType`;
/// 4g/4h add `AddConstraint`/`AddForeignKey`/`DropConstraint`, and
/// `RenameTo`.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum AlterTableAction {
/// `ADD COLUMN <name> <type> [NOT NULL] [UNIQUE] [DEFAULT …]
@@ -731,6 +733,12 @@ pub enum AlterTableAction {
DropColumn { column: String },
/// `RENAME COLUMN <old> TO <new>` — reuses `do_rename_column`.
RenameColumn { old: String, new: String },
/// `ALTER COLUMN <name> TYPE <type>` — reuses `do_change_column_type`
/// with `ChangeColumnMode::ForceConversion`, which is the ADR-0035 §7
/// advanced-mode policy (lossy cells are *performed* with a note, no
/// force flag; static-refused / incompatible still refuse). One undo
/// step (the executor's rebuild). ADR-0035 §4f.
AlterColumnType { column: String, ty: Type },
}
impl std::fmt::Display for IndexSelector {