Map MySQL 26.7 statement coverage and support SIGNAL, RESIGNAL, and GET DIAGNOSTICS - #38
Merged
Merged
Conversation
…parse Probe every statement family documented in the MySQL 26.7 reference manual (Chapter 15, SQL Statements) against the parser and record the gaps as error goldens in seven new testdata/parser groups, organized by manual chapter: - mysql_unsupported_ddl: EVENT, stored/loadable FUNCTION, JSON DUALITY VIEW, LIBRARY, LOGFILE GROUP, PROCEDURE (ALTER), SERVER, TABLESPACE, TRIGGER, SPATIAL REFERENCE SYSTEM, MASKING POLICY, ALTER VIEW, and ALTER INSTANCE ROTATE INNODB MASTER KEY - mysql_unsupported_dml: HANDLER, IMPORT TABLE, LOAD XML, and SELECT ... INTO var - mysql_unsupported_txn: XA transactions and LOCK/UNLOCK INSTANCE - mysql_unsupported_replication: PURGE BINARY LOGS, RESET BINARY LOGS AND GTIDS, CHANGE REPLICATION FILTER, RESET/START/STOP REPLICA, and START/STOP GROUP_REPLICATION - mysql_unsupported_compound: SIGNAL, RESIGNAL, GET DIAGNOSTICS - mysql_unsupported_admin: MySQL-syntax resource groups, CHECK/CHECKSUM/ REPAIR TABLE, INSTALL/UNINSTALL COMPONENT and PLUGIN, CLONE, CACHE INDEX, LOAD INDEX INTO CACHE, RESET PERSIST - mysql_unsupported_show: the SHOW variants that do not parse (BINARY LOGS, BINLOG/RELAYLOG EVENTS, CREATE EVENT/FUNCTION/TRIGGER/LIBRARY/ MASKING POLICY, ENGINE, FUNCTION/PROCEDURE CODE, LIBRARY STATUS, PARSE_TREE, REPLICAS) The goldens document current behavior: when one of these statements gains support, its -- error segment turns into a Restore() golden and the diff makes the coverage change explicit. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XbrFvXrQbj3sTh7SiaUxr7
Implement the condition handling statements of MySQL 26.7 §15.6.7, both as top-level statements and inside stored procedure bodies (ProcedureStatementStmt), and rename the mysql_unsupported_compound test group to mysql_compound with expanded coverage now that its statements parse. Grammar, following the reference manual since these postdate the goyacc grammar (parser/parse_signal.go): - SIGNAL condition_value [SET item, ...] and RESIGNAL with both parts optional, where condition_value is SQLSTATE [VALUE] 'xxxxx' or a named condition, and each item assigns a condition information item name a literal or variable value. - GET [CURRENT | STACKED] DIAGNOSTICS with the statement information form (NUMBER, ROW_COUNT) and the CONDITION n form (condition information items plus RETURNED_SQLSTATE); targets are user variables or stored program variables. New AST nodes (ast/signal.go): SignalStmt, ResignalStmt, GetDiagnosticsStmt with SignalConditionValue, SignalSetItem, DiagnosticsItem, and DiagnosticsArea, plus SEMCommand strings. Keyword tables: SIGNAL, RESIGNAL, and GET become reserved words and DIAGNOSTICS and STACKED unreserved, matching their MySQL 26.7 classification; TestKeywordsLength counts updated accordingly. The information item names are not keywords (non-reserved in MySQL) and are matched case-insensitively in identifier position, as is CONDITION. The two in-procedure test cases are written in canonical Restore() spelling: ProcedureBlock.Accept deliberately does not traverse the body statements, so the round-trip check can only normalize node text and expression offsets when input and restored output coincide byte for byte. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XbrFvXrQbj3sTh7SiaUxr7
This was referenced Aug 18, 2026
Support the MySQL spatial types, SRID attribute, SPATIAL constraint, and CHAR/VARCHAR attributes
#42
Merged
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.
Summary
Two pieces of work toward full MySQL 26.7 statement coverage:
Coverage map as test cases. Every statement family documented in the MySQL 26.7 reference manual (Chapter 15, SQL Statements) was probed against the parser; the gaps are recorded as error goldens in seven new file-driven test groups under
parser/testdata/parser/, organized by manual chapter:mysql_unsupported_ddl,_dml,_txn,_replication,_admin, and_show(78 cases). When one of these statements gains support, its-- error:segment flips to aRestore()golden, so the diff makes each coverage change explicit.First gap closed: condition handling statements (manual §15.6.7). SIGNAL, RESIGNAL, and GET DIAGNOSTICS now parse, both as top-level statements and inside stored procedure bodies, and the former
mysql_unsupported_compoundgroup is renamed tomysql_compoundwith expanded coverage (20 cases: both condition-value forms,SQLSTATE VALUEnormalization, multi-item SET clauses, variable values, all GET DIAGNOSTICS areas and both item forms, in-procedure usage, and three negative cases pinning validation errors).Implementation
parser/parse_signal.go— new statement-family file. The productions are written from the MySQL 26.7 manual since these statements postdate the goyacc grammar. Values and targets are restricted the way MySQL restricts them (literals, user/system variables, or stored program variables — not arbitrary expressions), and information item names are validated against the manual's three sets (signal items, statement items, condition items).ast/signal.go— new backwards-compatible nodes:SignalStmt,ResignalStmt,GetDiagnosticsStmtwithSignalConditionValue,SignalSetItem,DiagnosticsItem, and aDiagnosticsAreaenum, each withRestore/Accept;SEMCommandstrings added inast/sem.go.token_kinds.go,misc.go,keywords.go, andkeyword_classes.go(TestKeywordsLengthcounts move from 685/236 to 690/239). No existing test or golden used these words as identifiers. The information item names and CONDITION remain non-keywords (non-reserved in MySQL) and are matched case-insensitively in identifier position.parse_procedure.go— the three statements are added toProcedureStatementStmt, so they parse inside procedure bodies.Notes for review
Restore()spelling (backquotes,_UTF8MB4prefixes).ProcedureBlock.Acceptdeliberately does not traverse body statements, so the round-trip check can only normalize expression offsets when input and restored output coincide byte for byte. This is a pre-existing property of all procedure statements, not specific to this change.go test ./parser -run TestParserData -updateper the framework's workflow.Testing
All packages pass, including
TestKeywordConsistent,TestRDErrorFidelity, and the full file-driven suite.🤖 Generated with Claude Code
https://claude.ai/code/session_01XbrFvXrQbj3sTh7SiaUxr7
Generated by Claude Code