Repository navigation
MySQL: Fix FLUSH TABLES consuming semicolon delimiter - #2789
slopgobblercobbler wants to merge 1 commit into
Conversation
In `parse_flush`, parsing `FLUSH TABLES` consumed the next token inside a loop using `self.next_token()`. When breaking out of the loop at the end of the table/options list, the following token (such as a semicolon delimiter) was already consumed and not restored, causing subsequent statements to fail parsing with `Expected: end of statement, found: <TOKEN>`. Use `self.peek_token()` instead of unconditionally consuming tokens in the `TABLES` loop, advancing only on matched options and allowing delimiters and EOF to be preserved for statement separation. Closes apache#2764.
|
Thank you for the contribution. The change may well be correct, but I am closing this PR under the DataFusion AI policy, which also applies to sqlparser-rs: https://datafusion.apache.org/contributor-guide/ai-policy.html#what-is-an-ai-dump-and-why-it-is-not-helpful Maintainer review time is the scarcest resource in this project. This account has recently opened many AI-generated PRs across many repositories. That suggests the changes aren't coming from someone who uses sqlparser-rs, and that no human will be around to discuss review feedback and maintain the code. Reviewing PRs like this costs us more time than it saves. If you do use sqlparser-rs and this fix matters to you, please pick the one change you care most about. Then open a focused PR with a short description in your own words, one you have reviewed and understand, and we'd be happy to help with review. |
Dialects: mysql, generic
Description
Fixes #2764.
In
parse_flush, theFLUSH TABLESloop previously consumed tokens unconditionally viaself.next_token(). On the break condition (such as reaching a semicolon or EOF), the token was not restored withprev_token(). Consequently, whenFLUSH TABLES;was immediately followed by another statement in a multi-statement query, the semicolon delimiter had already been consumed and was lost to the outer parser, resulting inExpected: end of statement, found: <TOKEN>.This PR switches the
TABLESloop to inspect tokens viaself.peek_token(), advancing only when matching valid options (WITHorFOR), so statement delimiters and EOF are preserved cleanly.Tests
parse_flush_tables_followed_by_statementintests/sqlparser_mysql.rscovering:FLUSH TABLES; SELECT 1FLUSH TABLES t1, t2; SELECT 1FLUSH TABLES WITH READ LOCK; SELECT 1FLUSH TABLES t1, t2 WITH READ LOCK; SELECT 1FLUSH TABLES t1, t2 FOR EXPORT; SELECT 1cargo test --all-features).cargo clippy --all-features -- -D warningsandcargo fmt --checkare clean.