feat: ADR-0035 4d — CREATE [UNIQUE] INDEX / DROP INDEX
Advanced-mode SQL CREATE [UNIQUE] INDEX [IF NOT EXISTS] [<name>] ON <T> (cols) -> SqlCreateIndex and DROP INDEX [IF EXISTS] <name> -> SqlDropIndex, both reusing the ADR-0025 executors (do_add_index / do_drop_index), like 4c reused do_drop_table. - CREATE UNIQUE INDEX admitted in advanced mode (ADR-0025 Amendment 1): ADR-0025 deferred UNIQUE indexes for the simple-mode DSL, but advanced mode trusts the user like SQL does. Adds an additive IndexSchema.unique flag (project.yaml, serde-default, version stays 1); rebuild re-emits CREATE UNIQUE INDEX; the redundant-set guard keys on (columns, unique). Simple-mode `add unique index` stays deferred. - IF [NOT] EXISTS on both forms reuses the 4c no-op-with-note skip (journalled, not snapshotted) via CreateIndexOutcome / DropIndexOutcome. - Unnamed CREATE INDEX auto-named (ADR-0025 convention); the [UNIQUE] prefix is a concrete-keyword Choice and the optional name an on-led-first selector (the drop-index selector precedent) — trap-safe. - create/drop each gain a second advanced node; the existing all-candidates dispatch handles it (locked by parse tests). - Unique indexes marked [unique] in the structure view and items panel. - do_add_index refuses internal __rdbms_* tables as "no such table", closing a latent exposure on both the simple `add index` and the new SQL CREATE INDEX surfaces (ADR-0025 Amendment 1). Docs: ADR-0035 status + §13 4d + 4i; ADR-0025 Amendment 1; ADR README; requirements.md Q1/C3. Plan: docs/plans/20260525-adr-0035-sql-ddl-4d.md. Tests: 1834 passing / 0 failing / 0 skipped / 1 ignored; clippy clean.
This commit is contained in:
@@ -278,6 +278,29 @@ pub enum Command {
|
||||
DropIndex {
|
||||
selector: IndexSelector,
|
||||
},
|
||||
/// Advanced-mode SQL `DROP INDEX [IF EXISTS] <name>` (ADR-0035 §4,
|
||||
/// sub-phase 4d). Name-only (SQL has no positional column form — that
|
||||
/// is the simple `drop index on T(…)`). Executes through the same
|
||||
/// `do_drop_index` machinery as [`Self::DropIndex`]; `if_exists`
|
||||
/// turns an absent index into a no-op-with-note rather than an error.
|
||||
SqlDropIndex {
|
||||
name: String,
|
||||
if_exists: bool,
|
||||
},
|
||||
/// Advanced-mode SQL `CREATE [UNIQUE] INDEX [IF NOT EXISTS] [<name>]
|
||||
/// ON <table> (<col>, …)` (ADR-0035 §4d). Executes through the same
|
||||
/// `do_add_index` machinery as [`Self::AddIndex`] (the columns/
|
||||
/// auto-name reuse), plus the `unique` flag (simple mode has no
|
||||
/// `add unique index` — that stays deferred per ADR-0025). `name` is
|
||||
/// `None` for the unnamed form (auto-named at execution);
|
||||
/// `if_not_exists` makes an existing index name a no-op-with-note.
|
||||
SqlCreateIndex {
|
||||
name: Option<String>,
|
||||
table: String,
|
||||
columns: Vec<String>,
|
||||
unique: bool,
|
||||
if_not_exists: bool,
|
||||
},
|
||||
/// Add a column-level constraint to an existing column
|
||||
/// (ADR-0029 §2.2). Applied through the rebuild-table
|
||||
/// primitive after a §5 dry-run guards populated columns.
|
||||
@@ -710,6 +733,8 @@ impl Command {
|
||||
Self::DropRelationship { .. } => "drop relationship",
|
||||
Self::AddIndex { .. } => "add index",
|
||||
Self::DropIndex { .. } => "drop index",
|
||||
Self::SqlDropIndex { .. } => "drop index",
|
||||
Self::SqlCreateIndex { .. } => "create index",
|
||||
Self::AddConstraint { .. } => "add constraint",
|
||||
Self::DropConstraint { .. } => "drop constraint",
|
||||
Self::ShowTable { .. } => "show table",
|
||||
@@ -783,6 +808,11 @@ impl Command {
|
||||
// sensible fallback for logging.
|
||||
IndexSelector::Named { name } => name,
|
||||
},
|
||||
// The SQL drop is name-only; the index name identifies it
|
||||
// until the executor resolves the table (mirrors the named
|
||||
// `DropIndex` / `SqlDropTable` fallback).
|
||||
Self::SqlDropIndex { name, .. } => name,
|
||||
Self::SqlCreateIndex { table, .. } => table,
|
||||
// Replay isn't tied to a single table; the path is
|
||||
// the most identifying thing for log output.
|
||||
Self::Replay { path } => path,
|
||||
|
||||
Reference in New Issue
Block a user