feat(parser): fix MySQL replication/admin statement kinds and TABLE value constructor - #59
Merged
Merged
Conversation
…alue constructor Four same-dialect correctness fixes where pinned upstream mis-parses a MySQL statement into an expression or the wrong statement node. All are DEVIATIONS §1 entries verified against real MySQL 8.0.46; each dispatch is gated to a top-level statement so a bare identifier in a nested position (a SET assignment RHS, a CTE body) is never mis-diverted. - START REPLICA / START SLAVE / START GROUP_REPLICATION now degrade to a raw Command instead of a transaction. Upstream maps START to BEGIN and eats the verb as a transaction mode, so these looked identical to START TRANSACTION and a session-passthrough consumer would let a connect-only principal start replication. Upstream's round-trip output for these is itself a MySQL syntax error. MySQL-only; START TRANSACTION / BEGIN and their real modes are untouched. - The admin statement leaders STOP, FLUSH, UNLOCK INSTANCE, XA, BINLOG, HELP, RESTART and SHUTDOWN now degrade to Command via a single statement-start dispatch table, instead of upstream's Alias/Column mis-coercion. The words stay usable as identifiers and as nested values. LOCK/UNLOCK TABLES are unaffected; the XA family is unified under Command. - MySQL 8.0.19+ TABLE tbl now parses to a real Select whose AST is identical to SELECT * FROM tbl, so a lineage consumer sees the full-table read. The operand must be a plain table identifier; trailers, set operations, subquery and INSERT positions are unmodeled and fail closed. The schema-qualified TABLE db.users is grammar beyond pinned upstream and is tracked with a tripwire. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01Bi9bXQhVpzEYuHoZrie9NF
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.
Four MySQL same-dialect parser correctness fixes where pinned upstream (v30.12.0) mis-parses a statement into an expression or the wrong statement node. All are DEVIATIONS §1 entries verified against real MySQL 8.0.46. Requested by the proxy-monster analyzer, which dispatches enforcement on
root.Kind().START REPLICA/SLAVE/GROUP_REPLICATIONTransaction→BEGIN REPLICACommandBEGIN REPLICAoutput is itself ERROR 1064 in MySQL.STOP/FLUSH/UNLOCK INSTANCE/XA/BINLOG/HELP/RESTART/SHUTDOWNAlias/ColumnCommandTABLE t(8.0.19+)AliasSelect(=SELECT * FROM t)Key trap (why the gate matters): all three dispatches fire only at a top-level statement (
statementDepth == 1).parseStatementis re-entered for nested values — aSETassignment RHS, a CTE body — so an ungated dispatch would mis-parseSET x = stop, y = 1(swallowing the second assignment) orSET x = TABLE t(a bogus nested Select). The command leaders andTABLEstay ordinary identifiers/values there.Scope limits (documented in §1.15): only the bare
TABLE tbl_nameis modeled; a non-identifier operand (TABLE f(),TABLE ?) is rejected, and trailers / set-ops / subquery /INSERT … TABLEare unmodeled and fail closed. The schema-qualifiedTABLE db.usersis grammar beyond pinned upstream (it parse-errors at the dot) and carries a tripwire (testdata/upstream_extensions.jsonl); the unqualified form is the §1.15 correctness fix.Verification:
go test ./...green; 1847-case round-trip corpus intact; oracle-checked on MySQL 8.0.46 (TABLE ureturns the same rows asSELECT * FROM u). Reviewed by Codex + Sol + Grok — Grok caught the nested-statement gate, now fixed and regression-tested.🤖 Generated with Claude Code
https://claude.ai/code/session_01Bi9bXQhVpzEYuHoZrie9NF