Skip to content

[P0][bug] handleSave runs multi-statement ALTER as a single executeQuery call — partial apply, no transaction, no read-only, no production-safety confirm #379

Closed

Description

@EVWorth

Context

Table Designer Apply Changes handler.

Problem

src/components/designer/TableDesigner.tsx:208-225 (handleSave) calls generateAlterTable which returns a string with multiple ALTER TABLE statements separated by \n\n. api.executeQuery(connectionId, sql) is called once. MySQL's multi_statement flag splits and executes sequentially. If statement 3 of 5 fails (duplicate-key error, FK violation, syntax error from rename), statements 1-2 are committed — table half-modified. The handler also (a) skips resultStore.executeQuery's production-safety confirm (calls api.executeQuery directly), (b) bypasses read_only profile enforcement (admin F1 pattern), (c) doesn't apply query_timeout_secs (editor F3 — column exists but never enforced), (d) doesn't write a history entry.

Files

  • src/components/designer/TableDesigner.tsx:208-225 (handleSave)
  • src/lib/ddl-generator.ts:155-310 (generateAlterTable)

Repro

  1. Create a 5-column table
  2. Open Table Designer in alter mode
  3. Add 5 columns at once, click Apply Changes
  4. If column 3 conflicts (e.g., UNIQUE constraint fails), columns 1-2 are committed

Expected

Either all 5 ALTER statements apply or none do.

Proposed fix

(a) Add a backend command apply_designer_changes(connection_id, database, statements: Vec<String>) -> DesignerResult in commands/mod.rs (or new mas-designer crate) that wraps the statements in sqlx::Transaction<'_, MySql> and commits only on full success. (b) Check profile.read_only and profile.environment === "production"; reject with CoreError::ReadOnlyViolation for read-only; return confirm-prompt payload for production. (c) Wire the frontend to call this command instead of api.executeQuery. (d) Add a separate execute_single_statement command for ALTERs the user wants to run individually (preview path). Scope: L.

Acceptance

A 5-statement ALTER where statement 3 fails leaves the table unchanged (full rollback). Designer against read_only=true profile is rejected. Designer on production with a DROP COLUMN change triggers the confirm dialog. A history entry is written.

Needs human verify

yes

Doc drift

no

Activity

  1. added
    audit
    severity/p0
    kind/bug
    area/designer
    on Jul 31, 2026
  2. added 2 commits that reference this issue on Sep 5, 2026
    c50ff05
    71905c7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/designerauditkind/bugseverity/p0

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions