Repository navigation
fix(parser,tokenizer): stop GRANT cursor panic; MySQL/MariaDB # line comments - #881
Merged
Merged
Conversation
…comments - utility grammar cursor no longer stores the -1 groupEnd/bracketEnd sentinel before failing (GRANT ... TO [ / [AppUser / CURRENT_USER(, MariaDB IDENTIFIED VIA ... USING PASSWORD(, COPY (); Parser.seek clamps negative indexes to EOF. These inputs now return E2002 instead of panicking. - With the MySQL or MariaDB dialect, '#' starts a line comment in the tokenizer (recorded in Comments, preserved by the formatter), the statement splitter and its procedural lookahead, highlight error recovery and the dropped-word checker. Other dialects keep their '#' meaning. - Regression tests over all 8 dialects, fuzz seeds, realworld corpus cases; literal golden regenerated (only mysql/mariadb digests change for inputs containing '#'). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DnbRnTFErhoMJdAjVEeCg2
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Claude finished @ajitpratap0's task in 23s —— View job Review of PR #881: GRANT cursor panic fix and MySQL/MariaDB
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DnbRnTFErhoMJdAjVEeCg2
|
Claude finished @ajitpratap0's task in 31s —— View job Review of PR #881: GRANT cursor panic fix and MySQL/MariaDB
|
This branch was successfully 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.
Summary
Panic fix (HIGH-1):
ParseWithDialect("GRANT SELECT ON t TO [", d)(alsoTO [AppUserandTO CURRENT_USER() panicked withindex out of range [-1]for pg, mysql, mariadb, oracle, snowflake and clickhouse. The utility-grammar cursor stored the-1sentinel frombracketEnd/groupEndinc.iand then calledc.fail, which runsseek(-1). Fixed at every such site:grantee(both cases),mariadbAuth(IDENTIFIED VIA ... USING PASSWORD() andcopyEnd(COPY (). As a second guard,Parser.seeknow treats a negative index as EOF. These inputs now return a structured E2002 error ("expected]" or "expected)").MySQL/MariaDB
#comments (HIGH-2): with the MySQL or MariaDB dialect,#now starts a line comment, the same as--:Comments(StyleLineComment, verbatim text), and the formatter re-emits it;SplitStatementsand its procedural BEGIN/END lookahead skip it, so a;inside the comment no longer splits;highlighterror recovery andinternal/dropcheck(used by the realworld corpus test) know about it too;#, which PostgreSQL reads as XOR.Other dialects keep their current meaning of
#: PostgreSQL#,#>,#>>and#-; SQL Server#tempand##global; Oracleemp#; generic.Tests: a table test over all 8 dialects that recovers any panic, a
seek(-1)unit test, new FuzzParse seeds, tokenizer/splitter/format/transpile/dropcheck cases, andtestdata/realworld/{mysql,mariadb}/91_hash_comments.sql. I regenerated the tokenizer literal golden. Among existing entries, only the mysql/mariadb digests changed, and only for inputs that contain#. The other changes are new entries and line-number shifts.Test Plan
task check(fmt, vet, lint, test:race): passes, no FAIL or panic in the outputtask test:cbinding: passesgo test -raceon tokenizer, parser, gosqlx (including TestRealWorldCorpus and splitter/parser agreement), formatter, transpiler, highlight and internal/...-count=6, compared with benchstat: no significant change. The largest difference was +1.39% on Tokenizer/ComplexSQL. B/op and allocs/op are identical.Breaking Changes
Behaviour change for MySQL/MariaDB only:
#used to tokenize asTokenTypeSharp(an operator) and now starts a comment. This matches what MySQL and MariaDB do. No API changes.🤖 Generated with Claude Code
https://claude.ai/code/session_01DnbRnTFErhoMJdAjVEeCg2