Skip to content

audit: routine viewer #390

Closed
Closed

Description

@EVWorth

Status: filed
Drives: docs/audits/routine.md

Findings

Critical (P0/P1)

Backlog (P2/P3)

  • F7 [P2] [bug] RoutineViewer Monaco editor hardcodes theme=vs-dark — doesn't respect app theme setting
  • F8 [P2] [bug] parseRoutineMetadata RETURNS regex doesn't capture CHARSET / COLLATE modifiers on the return type
  • F9 [P2] [ux] RoutineViewer DROP uses window.confirm — native browser dialog, not styled
  • F10 [P2] [test] RoutineViewer.test.tsx doesn't cover the OUT-param execution flow
  • F11 [P3] [bug] routine-parser.ts doesn't handle backslash-escaped single quotes
  • F12 [P3] [arch] RoutineViewer calls api.executeQuery directly — bypasses resultStore safety
  • F13 [P3] [test] No unit tests for lib/routine-parser.ts — fragile regex-heavy code is untested
  • F14 [P3] [arch] RoutineViewer reuses Monaco editor with raw import — no shared abstraction

Good (👍)

  • parseRoutineMetadata correctly handles NOT DETERMINISTIC before DETERMINISTIC
  • splitParams respects parens depth and single-quote escaping
  • IPC chain is clean (api.* only)
  • Procedure execution via session variables (canonical MySQL pattern)
  • Type-aware input rendering (number/date/datetime-local/time/text)
  • Result display handles both result sets and rows_affected statements
  • Direction badges color-coded (IN blue, OUT amber, INOUT purple)
  • Retry button on load failure
  • Edit button opens new query tab and copies DDL
  • DROP confirmation via window.confirm (minimal friction)
  • Function vs procedure render paths are distinct
  • Test coverage: 11 tests for happy-path, error-retry, FUNCTION vs PROCEDURE

Doc drift

  • DESIGN_REQUIREMENTS FR-4.2.3 promises "definer" but parser doesn't extract DEFINER=…@…
  • DESIGN_REQUIREMENTS doesn't promise a "Drop routine" UI — viewer has one, not in spec
  • TESTING_STRATEGY has no routine_tests.rs table

Activity

  1. added
    audit
    area/routine
    on Jul 31, 2026
  2. EVWorth commented on Sep 12, 2026

    @EVWorth
    OwnerAuthor

    Routine viewer is clear.

    The P0/P1s

    #393 DROP through raw executeQuery with string concat fixed earlier — it goes through the store, so the production gate applies, and the identifiers are quoted
    #394 the SET/CALL/SELECT batch identifier quoting fixed; found and fixed a side effect nobody had noticed — the call was overwriting the user's own @x on the shared connection, so parameters now go through @sqlpilot_param_<name>. The transaction the issue asked for is rejected: session variables are not transactional, and wrapping a CALL changes the semantics of procedures that manage their own transactions
    #395 DEFAULT clauses lost fixed earlier
    #396 OUT params read from the last result set fixed earlier
    #397 raw concat and backslash escaping in the function call already fixed by the sql-quote work; now verified live on MySQL 8.0.46 and MariaDB 11.8 rather than assumed, with tests pinning the statement shapes
    #398 no client-side validation fixed — and the real bug was upstream of the one described: type="number" reads back "" for anything the browser cannot parse, which this dialog sends as NULL, so a mistyped id became a call with no id, silently

    The P2/P3 backlog

    Fixed:

    • F7 the DDL panel hardcoded theme="vs-dark", so on a light theme it was the only black rectangle on the screen.
    • F8 the RETURNS regex dropped the character set. RETURNS varchar(80) CHARSET utf8mb4 — which is what SHOW CREATE FUNCTION actually prints — showed as varchar(80), and a function returning utf8mb4 is a different function from one returning latin1. COLLATE and the CHARACTER SET spelling too.
    • F9 window.confirm for the drop. Replaced with the app's own dialog — and while there, the five in the schema tree (view, procedure, function, trigger, event) as well, since they were the same call. On a production connection it does not ask twice: the drop runs through resultStore, whose production dialog names the statement and is the stronger of the two.
    • F10 no test for the OUT-param flow — there are now nine on buildProcedureBatch, covering OUT and INOUT initialisation, the read-back SELECT, and the case where there is nothing to read back.
    • F13 no tests for routine-parser.ts — 22 now.

    Not done, with reasons:

    • F11 the parser does not handle backslash-escaped quotes in a DEFAULT. True, and it is a display-only path: the parsed default is shown as a hint, never executed. The comment parser already handles both escape forms; extending it to defaults is worth doing when defaults are used for more than a hint.
    • F12 the viewer calls api.executeQuery directly — no longer true for the destructive path, which was the point: the drop goes through resultStore. The reads still call the API directly, which is correct — there is no gate to skip on a SHOW CREATE.
    • F14 no shared Monaco abstraction. Two call sites with different options is not yet an abstraction; it would be one when there is a third.

    Nothing from this audit is outstanding.

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/routineaudit

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions