You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[P1][bug] parseSingleParam doesn't extract DEFAULT clauses — default values are lost #395
Routine Viewer parses CREATE PROCEDURE/FUNCTION DDL to render parameter inputs.
Problem
src/lib/routine-parser.ts:124-140 (parseSingleParam) splits on /\s+/ and takes [nameIdx + 1 ..] joined as dataType. A parameter like IN p VARCHAR(255) DEFAULT 'foo' parses with name: "p", dataType: "VARCHAR(255)" — DEFAULT 'foo' is dropped — no defaultValue field on RoutineParameter. Worse, IN p VARCHAR(255) DEFAULT CURRENT_TIMESTAMP parses as dataType: "VARCHAR(255)" (the DEFAULT … is consumed as part of the dataType string). When user calls the procedure and leaves param blank, formatParamValue (RoutineViewer.tsx:528-540) sends SET @p = NULL — silently overriding the server-side default. Opposite of what user expects from a procedure with defaults.
CREATE PROCEDURE foo(IN x INT DEFAULT 5) parses with defaultValue: "5". Calling with empty input sends SET @x = 5. The input placeholder shows (default: 5).
Proposed fix
Extend parseSingleParam to scan for DEFAULT keyword after the dataType (handling quoted strings, NULL, numeric, CURRENT_TIMESTAMP). Add defaultValue?: string to RoutineParameter. Extend RoutineViewer.executeProcedure to emit SET @p = ${formatParamValue(val ?? defaultValue ?? "NULL", p.dataType)} — using the default if the input is empty. Extend the input placeholder: placeholder={isReadOnly ? "(output)" : (\Enter ${p.name} (default: ${p.defaultValue})...`)}`. Scope: M.
Acceptance
CREATE PROCEDURE foo(IN x INT DEFAULT 5) parses with defaultValue: "5". Calling with empty input sends SET @x = 5. The input placeholder shows (default: 5).
Closing as invalid — the premise does not hold on either server we support.
The issue is built on this routine existing:
CREATE PROCEDURE foo(IN x INT DEFAULT 5) BEGINSELECT x; END
Neither MySQL nor MariaDB accepts parameter defaults in a routine declaration:
MySQL 8.0: ERROR 1064 (42000): ... check the manual ... near 'DEFAULT 5) BEGIN SELECT x' at line 1
MariaDB 11: ERROR 1064 (42000): ... near '' at line 1
Run against the repo's own test containers on ports 13306 and 13308.
So parseSingleParam can never encounter a DEFAULT clause: a routine carrying one cannot be created, and therefore cannot appear in SHOW CREATE PROCEDURE output. The stated harm — "SET @p = NULL silently overrides the server-side default" — has no server-side default to override.
Nothing to fix in the parser, and adding a defaultValue field would be dead weight modelling a syntax that does not exist.
If a dialect we later support does have parameter defaults, this is worth reopening against that dialect specifically.
Found while verifying premises before starting work on the routine area. The neighbouring #396 turned out to be unreachable for a different reason — executing any procedure that returns rows panics the executor first, which is now #544.
Activity
EVWorth commentedon Sep 5, 2026
Closing as invalid — the premise does not hold on either server we support.
The issue is built on this routine existing:
Neither MySQL nor MariaDB accepts parameter defaults in a routine declaration:
Run against the repo's own test containers on ports 13306 and 13308.
So
parseSingleParamcan never encounter aDEFAULTclause: a routine carrying one cannot be created, and therefore cannot appear inSHOW CREATE PROCEDUREoutput. The stated harm — "SET @p = NULL silently overrides the server-side default" — has no server-side default to override.Nothing to fix in the parser, and adding a
defaultValuefield would be dead weight modelling a syntax that does not exist.If a dialect we later support does have parameter defaults, this is worth reopening against that dialect specifically.
Found while verifying premises before starting work on the routine area. The neighbouring #396 turned out to be unreachable for a different reason — executing any procedure that returns rows panics the executor first, which is now #544.