docs: ADR-0035 — record two /runda refinements (IF [NOT] EXISTS, INTEGER PRIMARY KEY)

Pre-implementation /runda round settled two open micro-calls before 4a,
both user-confirmed:

- IF [NOT] EXISTS admitted (no-op-that-succeeds-with-a-note), not
  refused — a near-universal cross-vendor idiom (PostgreSQL, MySQL,
  SQLite, Oracle 23ai), reclassified into scope rather than treated as
  an engine-specific spelling. Touches §3/§4/§12/§13 (4a, 4c).
- INTEGER PRIMARY KEY maps to a plain int PK, not auto-increment;
  serial stays the sole auto-increment type (§3).

README index updated in the same edit per the lockstep rule.
This commit is contained in:
claude@clouddev1
2026-05-24 22:31:44 +00:00
parent f74226fe8c
commit 19d3cd3306
2 changed files with 37 additions and 8 deletions
+36 -7
View File
@@ -8,6 +8,16 @@ 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:
(1) `IF [NOT] EXISTS` is **admitted** as a no-op-that-succeeds-with-a-note
rather than refused — it is a near-universal cross-vendor idiom
(PostgreSQL, MySQL/MariaDB, SQLite, Oracle 23ai), not an
engine-specific spelling, so it belongs in the standard surface
(§3/§4/§12/§13); (2) `INTEGER PRIMARY KEY` maps to a **plain `int`**
primary key, *not* auto-increment — `serial` remains the sole
auto-increment type (§3).
## Context
ADR-0030 fixed the *architecture* of advanced mode — SQL authored as
@@ -109,6 +119,13 @@ length/precision argument (`varchar(255)`, `numeric(10,2)`) is
unparameterised. Engine storage-type names are neither accepted as
input nor shown (§9).
The map is purely **lexical**: `INTEGER PRIMARY KEY` becomes a plain
`int` primary key — it is **not** treated as auto-increment, unlike
the engine's rowid-alias idiom. Auto-increment is reached only through
the explicit `serial` type (`id serial primary key`). This keeps the
engine's storage behaviour from leaking into the standard surface and
matches ADR-0005's single-auto-increment-type model.
### 4. The DDL surface (full; `Q4`, no pre-emptive cuts)
**`CREATE TABLE <name> ( <element>, … )`**
@@ -123,9 +140,18 @@ input nor shown (§9).
[ON DELETE …] [ON UPDATE …]` (§5).
- `CHECK` and `DEFAULT` expressions reuse the ADR-0031 `sql_expr`
grammar (the same fragment `WHERE`/`HAVING`/projections use).
- `CREATE TABLE IF NOT EXISTS <name> …` is admitted: when the table
already exists the statement is a **no-op that succeeds with a note**
("table already exists — skipped") instead of the plain-form
"table already exists" error. `IF NOT EXISTS` is a near-universal
cross-vendor idiom, not an engine-specific spelling, so it is part of
the standard surface (refines §12).
**`DROP TABLE <name>`** → `SqlDropTable`. Cascade of inbound
relationships follows the existing `drop table` semantics.
**`DROP TABLE [IF EXISTS] <name>`** → `SqlDropTable`. Cascade of inbound
relationships follows the existing `drop table` semantics. `IF EXISTS`
is admitted (universal across the major engines): dropping an absent
table is then a **no-op that succeeds with a note** instead of the
plain-form "no such table" error.
**`ALTER TABLE <name> <action>`** → `SqlAlterTable`, where `<action>`
covers, mapping to the existing low-level operations:
@@ -267,9 +293,10 @@ note). The integration is structural, not free of authoring.
- The **DSL → SQL teaching echo** (ADR-0030 §10) is Phase 5, a
separate ADR — not this one.
- Engine-specific DDL spellings (`AUTOINCREMENT`, `WITHOUT ROWID`,
collations, `IF [NOT] EXISTS` if judged out-of-subset) — the
grammar admits the standard surface; extras are ordinary parse
errors.
collations) — the grammar admits the standard surface; extras are
ordinary parse errors. (`IF [NOT] EXISTS` was **reclassified into
scope** — see §4 — as a near-universal cross-vendor idiom rather
than an engine-specific spelling.)
### 13. Phased implementation plan
@@ -279,10 +306,12 @@ ADR-0033's structure:
- **4a — Dispatch + `CREATE TABLE` core.** Advanced `create`
dispatch; `SqlCreateTable` for columns + types (the §3 map) +
column constraints + single/compound `PRIMARY KEY`. No FK yet.
column constraints + single/compound `PRIMARY KEY`, plus
`IF NOT EXISTS` (no-op-with-note, §4). No FK yet.
- **4b — Foreign keys in `CREATE TABLE`.** Inline `REFERENCES` +
table-level `FOREIGN KEY` → relationship metadata, one undo step.
- **4c — `DROP TABLE`** → `SqlDropTable` (cascade parity).
- **4c — `DROP TABLE [IF EXISTS]`** → `SqlDropTable` (cascade parity;
`IF EXISTS` no-op-with-note, §4).
- **4d — `CREATE [UNIQUE] INDEX` / `DROP INDEX`** → `SqlCreateIndex`
/ `SqlDropIndex` (ADR-0025; the `UNIQUE` flag extension if needed).
- **4e — `ALTER TABLE` add/drop/rename column.**
+1 -1
View File
File diff suppressed because one or more lines are too long