Repository navigation
fix(mysql): identify reads by result set instead of the leading keyword - #573
Open
cyberspace-cs wants to merge 1 commit into
Open
cyberspace-cs wants to merge 1 commit into
cyberspace-cs wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
What
MySQLConnector.execute_querydecided whether a statement was a read by sniffing its leading keyword:The check runs after
cursor.execute(), so the statement has already been sent to the server. It now asks the server instead — MySQL setscursor.descriptionfor every statement that returns rows and leaves itNonefor DML:Why
SQLExecutabilityFilter/SQLExecutionFilterexplicitly keep CTE queries —filter_select_sqlaccepts bothselectandwith. The SQLite connector supports them because it already keys offcursor.description. MySQL did not, so the two backends disagreed on the same dataset:filter_select_sqlSQLiteConnectorMySQLConnector(before)SELECT a FROM tWITH x AS (SELECT a FROM t) SELECT a FROM x/* hint */ SELECT a FROM t-- note\nSELECT a FROM t(SELECT a FROM t) UNION (SELECT a FROM t)DELETE FROM tTwo consequences on a MySQL-backed text2sql pipeline:
success=False, so both filters discard it from the output dataset even though phase 1 just admitted it.batch_compare_queriesruns gold and prediction throughbatch_execute_queries. A CTE-based prediction fails, the comparison falls back toequal=False, and a correct prediction is scored as wrong. CTEs are common in Spider/BIRD-style outputs, so this is not a rare shape.The write guard is unchanged: a DML statement still has
description is Noneand is still rejected, andSET SESSION TRANSACTION READ ONLYremains the primary defense inconnect().Tests
New
test/cpu_only/test_mysql_connector_result_sets.pydrives the connector with a fake pymysql cursor (no server needed). 5 of the 9 read cases fail onmain, all pass after the change; the 4 write cases keep failing as before.The read cases cover
SELECT, lower-case / paddedSELECT,WITH,WITH RECURSIVE, a/* */-prefixed and a---prefixed read, a parenthesizedUNION,SHOW, andEXPLAIN. The write cases coverDELETE,UPDATE,INSERT, andWITH ... DELETE(a CTE that still writes — accepted by phase 1, still rejected here).