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
+25 -7
View File
@@ -4,14 +4,14 @@
Accepted. Design agreed with the user (2026-05-24); the approach is
**validated end-to-end by sub-phases 4a / 4a.2 / 4a.3 / 4b / 4c / 4d /
4e** (`CREATE TABLE` with column- and table-level constraints and foreign
keys, `DROP TABLE [IF EXISTS]`, `CREATE [UNIQUE] INDEX` /
`DROP INDEX [IF EXISTS]`, and `ALTER TABLE` add/drop/rename column,
implemented 2026-05-25 — plans
4e / 4f** (`CREATE TABLE` with column- and table-level constraints and
foreign keys, `DROP TABLE [IF EXISTS]`, `CREATE [UNIQUE] INDEX` /
`DROP INDEX [IF EXISTS]`, `ALTER TABLE` add/drop/rename column, and
`ALTER TABLE … ALTER COLUMN TYPE`, implemented 2026-05-25 — plans
`docs/plans/20260524-adr-0035-sql-ddl-4a.md`, `…-4a2.md`, `…-4a3.md`,
`docs/plans/20260525-adr-0035-sql-ddl-4b.md`, `…-4c.md`, `…-4d.md`,
`…-4e.md`), so the decision is accepted while the remaining sub-phases
(**4f4i**, §13) continue. This is **Phase 4** of the ADR-0030 roadmap (the
`…-4e.md`, `…-4f.md`), so the decision is accepted while the remaining
sub-phases (**4g4i**, §13) continue. This is **Phase 4** of the ADR-0030 roadmap (the
advanced-mode SQL surface), the peer of ADR-0031 (expression grammar),
ADR-0032 (`SELECT`), and ADR-0033 (DML). It **clarifies ADR-0030 §4**
on how DDL is represented and executed.
@@ -436,7 +436,25 @@ ADR-0033's structure:
internal-table guard on `do_change_column_type` / `do_add_constraint` /
`do_add_relationship` is a tracked follow-up.)*
- **4f — `ALTER TABLE … ALTER COLUMN TYPE`** (the §7 conversion
model + the lossy-with-note path).
model + the lossy-with-note path). *(Implemented 2026-05-25 — plan
`docs/plans/20260525-adr-0035-sql-ddl-4f.md`.)* A fourth
`AlterTableAction::AlterColumnType`, runtime-decomposed to the existing
`change_column_type` executor with `ChangeColumnMode::ForceConversion`
— which **is** the §7 advanced policy: lossy cells are *performed* and
counted (the engine-neutral `client_side.transformed_lossy` note
fires), incompatible cells refuse, and the ADR-0017 static refusals
(`↔ blob`, same-type, `date ↔ datetime`, non-`int → serial`) refuse in
both modes. **`int → serial` is *allowed*** (auto-fills nulls, adds
UNIQUE if non-PK — ADR-0018 §8; the §7 "static-refused →serial"
summary is looser than the code). No force flag, no `USING`, no
`SET DATA TYPE` synonym (§7/§12); `undo` is the advanced safety net.
The 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 2026-05-25), closing the simple `change column`
exposure too. *(The remaining internal-table guard on
`do_add_constraint` / `do_add_relationship` rides in 4g.)*
- **4g — `ALTER TABLE` add/drop constraint, add foreign key.**
- **4h — `ALTER TABLE … RENAME TO`** (the §6 new low-level op).
- **4i — Verification sweep.** Typing-surface + matrix coverage,