Skip to content

[P1/bug] Multi-statement execution records a single history entry; loses per-statement structure #329

Closed

Description

@EVWorth

Context

doExecuteQuery (src/stores/resultStore.ts:181-219) aggregates results.reduce((sum, r) => sum + r.rows.length, 0) and records one entry per call — even when the user executed a multi-statement batch like SELECT 1; INSERT INTO log ...; SELECT 2. The history loses the per-statement structure.

Problem

If statement 3 fails, the entry records status: "error" with the third statement's error, but the first two may have succeeded — the entry is misleading. The history is supposed to be a personal log of "what I ran"; a multi-statement exec showing "error" because the LAST statement failed is wrong.

Files

  • src/stores/resultStore.ts:181-219
  • src-tauri/crates/mas-core/src/query/executor.rs:97-209 (executor returns Vec)

Expected

One history entry per statement in the batch. Pass through results.map((r, i) => ({ ... entry with sql: statement_index_snippet, status: r.error ? "error" : "success", ... })). Storage cost is minor.

Proposed fix

Scope L — record one history entry per statement in the batch. The entry.id needs to be unique per statement (already UUID, so safe).

Acceptance

A 3-statement batch where the last statement fails shows 3 history entries: the first two success, the third error; the success entries have their row counts; the error entry shows the error message.

Needs human verify

yes

Activity

  1. added
    audit
    severity/p1
    kind/bug
    area/history
    on Jul 31, 2026
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/historyauditkind/bugseverity/p1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions