Skip to content

Map MySQL 26.7 statement coverage and support SIGNAL, RESIGNAL, and GET DIAGNOSTICS - #38

Merged
kyleconroy merged 2 commits into
mainfrom
claude/marino-mysql-sql-coverage-xmy5nz
Aug 18, 2026
Merged

Map MySQL 26.7 statement coverage and support SIGNAL, RESIGNAL, and GET DIAGNOSTICS#38
kyleconroy merged 2 commits into
mainfrom
claude/marino-mysql-sql-coverage-xmy5nz

Conversation

@kyleconroy

Copy link
Copy Markdown
Contributor

Summary

Two pieces of work toward full MySQL 26.7 statement coverage:

  1. 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 a Restore() golden, so the diff makes each coverage change explicit.

  2. 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_compound group is renamed to mysql_compound with expanded coverage (20 cases: both condition-value forms, SQLSTATE VALUE normalization, 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, GetDiagnosticsStmt with SignalConditionValue, SignalSetItem, DiagnosticsItem, and a DiagnosticsArea enum, each with Restore/Accept; SEMCommand strings added in ast/sem.go.
  • Keyword tables: SIGNAL, RESIGNAL, and GET become reserved words and DIAGNOSTICS and STACKED unreserved, matching their MySQL 26.7 classification, updated consistently across token_kinds.go, misc.go, keywords.go, and keyword_classes.go (TestKeywordsLength counts 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 to ProcedureStatementStmt, so they parse inside procedure bodies.

Notes for review

  • The two in-procedure test cases are written in canonical Restore() spelling (backquotes, _UTF8MB4 prefixes). ProcedureBlock.Accept deliberately 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.
  • Goldens were generated with go test ./parser -run TestParserData -update per the framework's workflow.

Testing

go test ./... -count=1 -timeout 120s

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

claude added 2 commits August 18, 2026 19:29
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants