Repository navigation
fix(parser): reserve TOP in SQL Server names; parse full MariaDB DELETE HISTORY - #880
Conversation
…TE HISTORY SQL Server: a delimited [top] / "top" is now an ordinary name (the select list no longer reads it as the TOP clause) and keeps its delimiters in SQL() and the formatter. Bare TOP is rejected where a table name, DML/MERGE target, table alias or select-item alias is expected, matching T-SQL, instead of being accepted in FROM/INSERT/DELETE but rejected in UPDATE. MariaDB: DELETE HISTORY FROM t [PARTITION (p, ...)] [BEFORE SYSTEM_TIME [TIMESTAMP | TRANSACTION] expr] parses any point expression and round-trips the partition list and unit keyword. The new fields live in DMLTargetFields.History (DeleteHistoryOptions) so DeleteStatement keeps its size class. 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 19s —— View job Review of PR #880I read the diff only. I didn't build or run the tests, so I haven't confirmed the Overall: The change is clean and well scoped. Putting the new DELETE fields in SQL Server TOP
MariaDB DELETE HISTORY
Tests: Coverage looks good: parse, SQL round-trip, formatter casing, rejections, and other-dialect checks. I'd add the Performance and security: I found no concerns. The benchmark numbers in the description show no B/op or allocs/op change. Verdict: Looks good to merge. The comments above are minor nits. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DnbRnTFErhoMJdAjVEeCg2
|
Claude finished @ajitpratap0's task in 22s —— View job Review of PR #880 (updated for the latest push)I read the diff only. I didn't build or run the tests, so I haven't confirmed the Overall: The change is well scoped and I found no blocking issues.
SQL Server TOP
MariaDB DELETE HISTORY
Performance and securityNo concerns. The benchmark numbers in the description show no B/op or allocs/op change. Nothing here touches input handling in a way that adds risk. Verdict: Good to merge. The points above are minor and non-blocking. |
Summary
WP-J (parser grammar edge cases). I reproduced each reported item on
origin/main(adc8838):FROM t FINAL FINALINSERT top ...case consistencytopaccepted as a name in FROM/INSERT/DELETE/CREATE/aliases but rejected in UPDATE,SELECT [top] FROM tread as the TOP clause, and[top]/"top"losing their delimitersDELETE HISTORYBEFORE SYSTEM_TIMEaccepting only a primary expression orTIMESTAMP 'lit'(failed onNOW() - INTERVAL 1 DAYandTRANSACTION 42) and noPARTITION (...)^a -> 'b' ^ 2=a -> ('b' ^ 2),2 ^ a -> 'b'=(2 ^ a) -> 'b')::/ DDL across dialectsChanges:
isReservedTopName()(a dialect check first, so other dialects pay nothing) now guards table names, DML/MERGE targets, table/join/PIVOT aliases and select-item aliases.parseTopClauseand the non-TOP-dialect guard useisUnquotedWord("TOP").delimitedNameMustStayQuotedkeeps delimiters on TOP in SQL Server. TOP is not intokenizer.IsKeyword, which is why delimiters were dropped before.DELETE HISTORY FROM t [PARTITION (p, ...)] [BEFORE SYSTEM_TIME [TIMESTAMP | TRANSACTION] expr]. The partition list and unit go in a newast.DMLTargetFields.History *ast.DeleteHistoryOptions, soDeleteStatementkeeps its 176 B size class. The fields are rendered bySQL()andpkg/formatter, reachable viaChildren(), and released and zeroed on pool return.FOR SYSTEM_TIMEparsing is unchanged. WHERE and LIMIT stay rejected, as in MariaDB.Implemented by Codex from a brief. I reviewed it and moved the new DELETE fields out of
DeleteStatementafter a B/op regression showed up in the benchmark (544 to 592 B/op onBenchmarkParserDelete).Test Plan
pkg/sql/parser/sqlserver_top_reserved_test.go,pkg/sql/parser/mariadb_delete_history_test.go,pkg/formatter/mariadb_delete_history_test.go. They cover parse,SQL(), re-parse stability, formatter output (compact, readable, lower-case) and rejection cases, plus checks that other dialects are unchanged.task check: pass, no FAIL lines.task test:cbinding: pass.benchstat, 6 interleaved runs each, main vs branch, for SimpleSelect, ComplexSelect, Insert, Delete and ParseBytesWithDialect (pg, mysql). Time geomean -0.07%; B/op and allocs/op identical on every benchmark.Breaking Changes
top(any case) is now a syntax error as a table name, INSERT/UPDATE/DELETE/MERGE target, table alias or select-item alias, as in T-SQL. Quote it as[top]. Other dialects are unchanged.ast.DMLTargetFields.Historyandast.DeleteHistoryOptions. This is additive.🤖 Generated with Claude Code
https://claude.ai/code/session_01DnbRnTFErhoMJdAjVEeCg2