Repository navigation
fix(routine): validate parameters where they are typed - #653
Merged
Merged
Conversation
clobbering the user's session variables Three things, from the routine audit. A mistyped number was sent as NULL. Numeric parameters used `type="number"`, and a number input reads back "" for anything the browser cannot parse — which this dialog sends as NULL. So a mistyped id became a call with no id rather than an error, and the spinner rounded a BIGINT past 2^53, which is the precision the type exists for. Exact numerics now get a text box with a numeric keypad, so the value the user typed is the value that is checked. That check now runs as they type: the same `formatParamValue` the execute path uses, with the reason shown under the input and Execute disabled while any value is wrong. It used to be an error after clicking. A test asserts the two agree, so Execute can never be disabled for a value that would have worked, or enabled for one that will not. Calling a procedure overwrote the user's own session variables. The parameters were passed as `@name`, on the connection the editor also uses, so a procedure with a parameter called `x` silently replaced whatever was in `@x`. They go through `@sqlpilot_param_<name>` now. The batch itself moved out of the component into `buildProcedureBatch`, so what is sent to the server can be read and tested rather than being assembled inline across forty lines. +22 tests. The hostile-value case was checked against MySQL 8.0.46 and MariaDB 11.8: the procedure receives `a' OR 1=1 -- ` as data.
… theme Six drops asked with window.confirm — the routine viewer's, and the schema tree's view, procedure, function, trigger and event. That dialog is unstyled, blocks the whole window, and cannot be tested without stubbing a global. They now use the app's own dialog, which the production guard already had. On a production connection it does not ask twice: the drop runs through resultStore, whose production gate raises its own dialog naming the statement, and that is the stronger of the two. The routine viewer's DDL panel hardcoded theme="vs-dark", so on a light theme it was the only black rectangle on the screen. Routine audit F7 and F9.
`RETURNS varchar(80) CHARSET utf8mb4` — which is what MySQL's own SHOW CREATE FUNCTION prints — showed as `varchar(80)`. A function returning utf8mb4 is a different function from one returning latin1, and the badge hid the difference. COLLATE and the CHARACTER SET spelling too. Routine audit F8. +5 tests, shapes taken from a live server's output.
This was referenced Sep 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #398, #397, #394.
A mistyped number was sent as NULL (#398)
Numeric parameters used
type="number". A number input reads back""for anything the browser cannot parse, and this dialog sends an empty value as NULL — so a mistyped id became a call with no id rather than an error. Its spinner also rounds a BIGINT past 2^53, which is the precision that type exists for.Exact numerics now get a text box with
inputMode="numeric", so the value the user typed is the value that gets checked. And the check runs as they type: the sameformatParamValuethe execute path uses, with the reason under the input,aria-invalidon it, and Execute disabled while any value is wrong — your acceptance criterion. There is a test asserting the two agree on a range of inputs, so Execute can never be disabled for a value that would have worked, or enabled for one that will not.The session variables were the user's own (#394)
Parameters were passed as
@name, on the connection the editor also uses. A procedure with a parameter calledxsilently overwrote whatever the user had put in@x, with nothing in the editor to say so. They now go through@sqlpilot_param_<name>.The batch moved into
buildProcedureBatch, so what is sent can be read and tested rather than assembled inline across forty lines of component.What I did not do, and why. The issue asks for the SET + CALL to be wrapped in a transaction so a procedure that raises leaves no
@varscommitted.ROLLBACKdoes not restore a@var; there is nothing to commit or undo. The stated repro — "subsequent calls see stale session vars" — cannot happen either: every execution sets all of them before the CALL.START TRANSACTIONinside one raises or implicitly commits depending on what it does. Neither DBeaver nor Workbench wraps a CALL; the procedure's transaction semantics are its author's.raw_sql, which is what makes the session variables reachable by the CALL at all. There is a test pinning that they stay one batch.The identifier interpolation the issue names was fixed earlier — the CALL and the OUT-param SELECT go through
quoteIdentifier, and there is a test with a database calledodd`db.#397 was already fixed; verified rather than assumed
formatParamValuedoubles the quote and refuses what a type cannot hold, andbuildFunctionCallquotes both identifiers. Checked live on MySQL 8.0.46 and MariaDB 11.8: a procedure called witha' OR 1=1 --receives it as data and stores it as data;f_in('don''t')returnsfn:don't. Tests pin both shapes.Tests
+22 (9 for the batch, 6 for the inline validation in the component, 7 for the validator and the variable naming). 2692 unit, 344 browser, tsc and eslint clean.