Repository navigation
fix(parser): end VACUUM, ANALYZE and LISTEN at their grammar - #878
Conversation
PostgreSQL, Redshift and SQLite VACUUM / ANALYZE and PostgreSQL LISTEN, UNLISTEN and NOTIFY were kept verbatim, so trailing same-line tokens (VACUUM t junk) were swallowed into the statement text. They now follow the GRANT / COPY pattern: a small per-dialect grammar finds the end and utilityTailError rejects anything after it. Generic mode accepts the union of the dialect forms; MySQL / MariaDB / Oracle ANALYZE TABLE keeps its verbatim path. Adds regression tests for the already-fixed CREATE TRIGGER / PREPARE / GRANT / COPY boundaries and for the splitter's MySQL backslash escapes and PostgreSQL CREATE RULE ... DO (a; b) command lists. 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 39s —— View job Review of PR #878: end VACUUM, ANALYZE and LISTEN at their grammarI read the diff and the supporting code by hand. I could not run the test suite here (
Potential bug: VACUUM under other dialects (needs verification)
The new
I expect that to produce garbled text, a spurious error, or a loop. On Suggested fix, either of these:
Other observations
SummaryThe design follows the existing GRANT/COPY pattern and reads cleanly. The main risk is the missing fallback for dialects with no grammar, so please check that before merging. The rest are minor nits. |
Summary
VACUUMandANALYZE, and PostgreSQLLISTEN/UNLISTEN/NOTIFY, now use a small per-dialect grammar (newpkg/sql/parser/utility_maintenance.go) following the existing GRANT / COPY pattern (parseGrammarStatement+utilityTailError). Trailing same-line tokens such asVACUUM t junkorLISTEN c extraare now an E2002 "expected semicolon or end of statement" error. Before this change they were folded into the verbatim text.ANALYZE TABLE ...and MariaDBANALYZE <statement>keep their existing paths.SplitStatementswith MySQL/MariaDB backslash escapes, and PostgreSQLCREATE RULE ... DO [ALSO|INSTEAD] (a; b).Test Plan
task check(fmt, vet, lint, test:race): passedtask test:cbinding: passedTestParser_MaintenanceBoundaries,TestParser_MaintenanceForms,TestParser_MaintenanceText,TestParser_MaintenanceIncomplete,TestParser_UtilitySelectBoundaryRegressions,TestSplitStatements_MySQLBackslashBoundaries,TestSplitStatements_PostgreSQLRuleCommandListBenchmarkParserStatementTypesandBenchmarkParserMixedWorkload,-benchmem -count=10, before and after runs interleaved: B/op and allocs/op are identical and ns/op shows no regression (for example SELECT_Complex 6089 to 5610 ns/op, MixedWorkload_Sequential 933 to 930 ns/op)Breaking Changes
Input that origin/main accepted is now rejected when it puts invalid trailing tokens after these maintenance statements. One example is
VACUUM t junkin PostgreSQL, SQLite or generic mode. Valid forms still parse, including every such statement in the testdata/realworld corpus.🤖 Generated with Claude Code
https://claude.ai/code/session_01DnbRnTFErhoMJdAjVEeCg2