feat: ADR-0035 4a — SQL CREATE TABLE command, worker, and exit gate
Command + builder + worker for advanced-mode SQL CREATE TABLE (sub-phase 4a), executed structurally through do_create_table: - Command::SqlCreateTable + build_sql_create_table (ddl.rs): aliases via from_sql_name (incl. double precision), column- and table-level PRIMARY KEY, redundant-flag de-dup off a sole PK, IF NOT EXISTS. Advanced REGISTRY entry on the shared `create` word (SQL-first, DSL fallback); no-PK tables allowed (user-confirmed). - Worker (db.rs): Request::SqlCreateTable + CreateOutcome + snapshot_then (one undo step); IF NOT EXISTS no-op (no snapshot, but journalled, like read-only commands). do_create_table inline-PK rule aligned with the rebuild generator schema_to_ddl — no round-trip DDL drift; serial autoincrement is independent of inline-PK (verified by round-trip tests). - Runtime/App: dispatch + CommandOutcome::SchemaSkipped + AppEvent::DslCreateSkipped (structure + "already exists — skipped" note). Friendly catalog keys added (engine-neutral). DEFAULT/CHECK/table-level UNIQUE are absent from the 4a grammar (parse error with usage skeleton; friendly message + support land in the 4a.2 constraint slice) — user-confirmed. Tests: type resolver, grammar shape, builder (incl. the PK detection bug they caught), and tests/sql_create_table.rs (worker round-trip, serial autoincrement first/non-first across rebuild, IF NOT EXISTS no-op + journalling, no-PK table, one undo step) + a replay-as- write test. 1739 pass / 0 fail / 1 ignored; clippy clean. Exit gate: ADR-0035 Proposed -> Accepted (validated end-to-end by 4a); README + requirements.md Q1 updated.
This commit is contained in:
@@ -2,11 +2,14 @@
|
||||
|
||||
## Status
|
||||
|
||||
Proposed. Design agreed with the user (2026-05-24); implementation
|
||||
is phased and pending (§13). 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.
|
||||
Accepted. Design agreed with the user (2026-05-24); the approach is
|
||||
**validated end-to-end by sub-phase 4a** (`CREATE TABLE`, implemented
|
||||
2026-05-25 — plan `docs/plans/20260524-adr-0035-sql-ddl-4a.md`), so the
|
||||
decision is accepted while the remaining sub-phases (**4a.2, 4b–4i**,
|
||||
§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.
|
||||
|
||||
**Refinements (2026-05-24, pre-implementation `/runda` round,
|
||||
user-confirmed).** Two open micro-calls were settled before 4a:
|
||||
@@ -310,9 +313,12 @@ ADR-0033's structure:
|
||||
**clean-reuse column constraints only** — `NOT NULL` / `UNIQUE` /
|
||||
column-level `PRIMARY KEY` — + single/compound table-level
|
||||
`PRIMARY KEY`, plus `IF NOT EXISTS` (no-op-with-note, §4). Reuses
|
||||
`do_create_table` (extended so a `serial` sole-PK inlines `PRIMARY
|
||||
KEY` in a multi-column table, preserving autoincrement). **No FK**
|
||||
(4b); **no `DEFAULT`/`CHECK`/table-level `UNIQUE`** (4a.2).
|
||||
`do_create_table`, whose inline-PK rule is aligned with the rebuild
|
||||
generator `schema_to_ddl` (inline only a first-column single PK) so a
|
||||
created table and its rebuilt form have identical DDL; `serial`
|
||||
autoincrement is independent of inline-vs-table-level PK (the insert
|
||||
path computes the next value), verified by round-trip tests. **No
|
||||
FK** (4b); **no `DEFAULT`/`CHECK`/table-level `UNIQUE`** (4a.2).
|
||||
- **4a.2 — The constraint slice.** Split out (2026-05-24,
|
||||
user-confirmed) for the constraints that are *not* a clean reuse:
|
||||
(1) **`CHECK`/`DEFAULT`** via the full `sql_expr` surface stored as
|
||||
|
||||
Reference in New Issue
Block a user