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
[P2][bug] The row limit is appended to EXPLAIN and SHOW, rewriting the statement it is meant to bound #520
execute_owned applies the user's max-row setting by appending LIMIT n to statements it considers row-returning.
Problem
src-tauri/crates/mas-core/src/query/executor.rs:110-131 matches on SELECT, SHOW, DESCRIBE and EXPLAIN, then appends LIMIT n to any of them that has no LIMIT of its own. That is wrong for three of the four:
EXPLAIN — EXPLAIN SELECT * FROM users becomes EXPLAIN SELECT * FROM users LIMIT 1000. The LIMIT binds to the inner statement, so the plan reported is the plan for a different query than the user asked about. EXPLAIN ANALYZE would additionally execute the modified statement.
SHOW — most SHOW forms accept LIMIT, but SHOW CREATE TABLE t LIMIT 1000 is a syntax error.
DESCRIBE — DESCRIBE users LIMIT 1000 is a syntax error.
Currently dormant
EXPLAIN is not reachable today: since #512, explain goes through the explain_query command, which calls execute_owned with limit: None precisely so the statement is not rewritten. The SHOW/DESCRIBE paths depend on whether any caller passes a limit alongside them — resultStore.doExecuteQuery passes the configured row limit for whatever the user typed, so a user running DESCRIBE users in the editor with the row limit enabled is the reachable case.
Filing it because the guard is a call-site convention rather than anything the executor enforces, and the next caller that passes a limit re-opens it.
Repro
Settings → enable the result row limit
Run DESCRIBE users in a query tab
The executor sends DESCRIBE users LIMIT 1000
Expected
The row limit applies only to statements where LIMIT means what the setting intends — SELECT, and TABLE/VALUES/WITH ... SELECT. EXPLAIN, SHOW and DESCRIBE are passed through untouched.
Proposed fix
Reuse query::statement::effective_verb (added in #512, and already used by returns_rows) rather than a second prefix list — the two lists answering different questions about the same statement is what let this drift. Truncation for the statements a LIMIT cannot bound should be handled by the existing row cap on the result, not by rewriting the SQL.
Add cases to the executor's unit tests for EXPLAIN/SHOW CREATE/DESCRIBE with a limit set. Scope: S.
Needs human verify
no — DESCRIBE users LIMIT 1000 is a syntax error on any MySQL.
Verified against the MySQL 8 test container rather than assumed:
mysql> DESCRIBE users LIMIT 1000;
ERROR 1064 (42000): ... near 'LIMIT 1000' at line 1
mysql> SHOW CREATE TABLE users LIMIT 1000;
ERROR 1064 (42000): ... near 'LIMIT 1000' at line 1
mysql> EXPLAIN SELECT * FROM users LIMIT 1000;
-- succeeds, but the LIMIT binds to the inner SELECT, so the plan
-- described is for a different query than the user asked about
So SHOW CREATE and DESCRIBE fail outright, and EXPLAIN fails silently by answering a question that was not asked — the worse of the two.
Activity
EVWorth commentedon Aug 29, 2026
Verified against the MySQL 8 test container rather than assumed:
So
SHOW CREATEandDESCRIBEfail outright, andEXPLAINfails silently by answering a question that was not asked — the worse of the two.fix(query): bound the rows read, instead of editing the user's SQL
fix(query): bound the rows read, instead of editing the user's SQL (#565
feat(grid): page through a result the row limit cuts off
feat(grid): per-column filters and paging (#391) (#628)