feat(dialect): add MariaDB SQL dialect with SEQUENCE, temporal tables, and CONNECT BY#430
feat(dialect): add MariaDB SQL dialect with SEQUENCE, temporal tables, and CONNECT BY#430ajitpratap0 wants to merge 22 commits intomainfrom
Conversation
… React error #310 useState(copied) and useCallback(handleCopy) were declared after the if (loading) and if (error) early returns, violating the Rules of Hooks. When the WASM binary was a 404, the component always hit the error branch so both renders exited with the same hook count. After committing the WASM binary (#423), the component now successfully transitions loading→ready, causing React to see 11 hooks instead of 9 on the second render → #310. Fix: move both hooks above all conditional returns. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…yword inheritance
…alect doc comment
…equenceStatement nodes Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…nce tests - Guard s.Name nil dereference in CreateSequenceStatement.ToSQL, DropSequenceStatement.ToSQL, and AlterSequenceStatement.ToSQL - Split SequenceOptions.Restart (*LiteralValue) into two fields: Restart bool (bare RESTART) and RestartWith *LiteralValue (RESTART WITH n) - Update writeSequenceOptions to emit bare RESTART or RESTART WITH n accordingly - Add ast_sequence_test.go with full ToSQL table-driven tests and pool round-trip test Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…fields - Add SystemTimeClauseType enum with AS OF, BETWEEN, FROM/TO, ALL variants - Add ForSystemTimeClause struct for MariaDB FOR SYSTEM_TIME temporal queries - Add PeriodDefinition struct for PERIOD FOR clauses in CREATE TABLE - Extend TableReference with ForSystemTime field (MariaDB 10.3.4+) - Extend CreateTableStatement with WithSystemVersioning and PeriodDefinitions fields - Add ForSystemTimeClause.ToSQL() and tableRefSQL integration in sql.go Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ctStatement field order Add SQL() methods to ForSystemTimeClause, ConnectByClause, and PeriodDefinition (all implement expressionNode()) so they satisfy the Expression interface fully without silently degrading via the exprSQL() fallback. Move StartWith and ConnectBy fields in SelectStatement to directly follow Having, matching logical SQL clause ordering. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…B dialect Add parseCreateSequenceStatement, parseDropSequenceStatement, and parseAlterSequenceStatement to mariadb.go with full option parsing (START WITH, INCREMENT BY, MINVALUE, MAXVALUE, CYCLE, CACHE, RESTART WITH). Wire dispatch into parseStatement() for DROP/ALTER and into parseCreateStatement() for CREATE. Gate all paths behind isMariaDB() so MySQL and other dialects are unaffected. Add six passing parser tests in mariadb_test.go. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… SYSTEM VERSIONING, PERIOD FOR) Add parseForSystemTimeClause and parseTemporalPointExpression to mariadb.go supporting AS OF, BETWEEN, FROM/TO, and ALL variants. Hook into parseFromTableReference in select_subquery.go (after alias, before SQL Server hints) with a peek-ahead guard so FOR is only consumed when followed by SYSTEM_TIME. Add WITH SYSTEM VERSIONING parsing to parseCreateTable (after closing paren, before PARTITION BY) and PERIOD FOR column parsing to the column loop in ddl.go. Add four passing tests for temporal queries and system versioning in mariadb_test.go. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…iaDB dialect Add parseConnectByCondition to mariadb.go which handles the PRIOR prefix operator by wrapping the referenced column in a FunctionCall node and building a BinaryExpression for the full PRIOR col = parent_col pattern. Wire START WITH and CONNECT BY [NOCYCLE] parsing into parseSelectStatement in select.go after the HAVING clause. Guard CONNECT and START from being consumed as table aliases in parseFromTableReference via a peek-ahead check in select_subquery.go. Add three passing tests covering basic, NOCYCLE, and no-START-WITH variants in mariadb_test.go. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ion test Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Claude finished @ajitpratap0's task —— View job PR Review: MariaDB SQL Dialect ImplementationComprehensive review of the MariaDB dialect implementation focusing on code quality, best practices, potential issues, performance, security, and test coverage. Review Tasks
✅ Code Quality & ArchitectureExcellent Design Decisions:
Well-structured keyword organization in
✅ Implementation QualityAST Nodes - Well-designed with proper object pooling:
Parser Logic - Robust implementation:
✅ Test Coverage (23 tests across 3 packages)Excellent coverage breadth:
Test data quality: Realistic SQL examples covering edge cases and feature combinations
|
…rser
AST layer:
- Add `Prior` UnaryOperator constant for CONNECT BY PRIOR expressions
- Add `NoCache bool` to SequenceOptions (NOCACHE was previously a silent no-op)
- Add `Pos models.Location` to all 6 new MariaDB AST nodes (CreateSequence,
DropSequence, AlterSequence, ForSystemTimeClause, ConnectByClause, PeriodDefinition)
- Add `NewDropSequenceStatement()` / `ReleaseDropSequenceStatement()` pool funcs
to match Create/Alter sequence pooling consistency
- Emit NOCACHE in writeSequenceOptions when NoCache=true
Keywords:
- Remove duplicate MINVALUE, MAXVALUE, INCREMENT, RESTART, NOCACHE entries
from MARIADB_SPECIFIC (already covered by base/Oracle keyword lists)
Parser:
- Fix PRIOR operator: switch from FunctionCall to UnaryExpression{Operator: Prior}
- Fix PRIOR on RHS: CONNECT BY col = PRIOR col now parsed correctly
- Fix parseJoinedTableRef: add isMariaDBClauseKeyword guard to prevent CONNECT/START
from being consumed as table aliases (same guard already in parseFromTableReference)
- Fix parseJoinedTableRef: add FOR SYSTEM_TIME temporal clause support on JOIN refs
- Fix DROP SEQUENCE: support IF NOT EXISTS in addition to IF EXISTS
- Fix DROP SEQUENCE: use NewDropSequenceStatement() for pool consistency
- Fix parseSequenceOptions: set opts.NoCache=true for NOCACHE keyword
- Add comment in parseTemporalPointExpression explaining quote-stripping behaviour
Tests:
- Add TestMariaDB_ConnectBy_PriorOnRight
- Add TestMariaDB_DropSequence_IfNotExists
- Add TestMariaDB_Sequence_NoCache
- Expand testdata SQL files with NO MINVALUE/MAXVALUE forms, PRIOR-on-right cases,
IF NOT EXISTS on DROP, and multi-table temporal JOIN query
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Claude finished @ajitpratap0's task —— View job PR Review: MariaDB SQL Dialect ImplementationComprehensive review of the MariaDB dialect implementation focusing on code quality, best practices, potential issues, performance, security, and test coverage. Review Tasks
✅ Code Quality & ArchitectureExcellent Design Decisions:
Well-structured keyword organization in
✅ Implementation QualityAST Nodes - Well-designed with proper object pooling:
Parser Logic - Robust implementation:
✅ Test Coverage (23 tests across 3 packages)Excellent coverage breadth:
Test data quality: Realistic SQL examples covering edge cases and feature combinations
|
…T BY, dedup Parser dispatch (parser.go, ddl.go, select.go): - Populate Pos on CreateSequenceStatement (at SEQUENCE token in ddl.go) - Populate Pos on DropSequenceStatement (at DROP token in parser.go) - Populate Pos on AlterSequenceStatement (at ALTER token in parser.go) - Populate Pos on ConnectByClause (at CONNECT token in select.go) - Populate Pos on PeriodDefinition (at PERIOD token in ddl.go) mariadb.go: - Fix NO CACHE (two-token) to also set opts.NoCache=true, matching NOCACHE - Fix parseConnectByCondition to handle complex AND/OR chains: CONNECT BY PRIOR id = parent_id AND active = 1 now fully parsed - Extract isMariaDBClauseStart() method (was duplicated closure in two functions) - Populate Pos on ForSystemTimeClause (at SYSTEM_TIME token) - Add comment clarifying IF NOT EXISTS is a non-standard permissive extension select_subquery.go: - Remove both isMariaDBClauseKeyword closures, replace with p.isMariaDBClauseStart() ast.go: - Update DropSequenceStatement doc to show [IF EXISTS | IF NOT EXISTS] Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Claude finished @ajitpratap0's task —— View job PR Review: MariaDB SQL Dialect ImplementationComprehensive review of the MariaDB dialect implementation focusing on code quality, best practices, potential issues, performance, security, and test coverage. Review Tasks
✅ Code Quality & ArchitectureExcellent Design Decisions:
Well-structured keyword organization in
✅ Implementation QualityAST Nodes - Well-designed with proper object pooling:
Parser Logic - Robust implementation:
✅ Test Coverage (23 tests across 3 packages)Excellent coverage breadth:
Test data quality: Realistic SQL examples covering edge cases and feature combinations
|
|
Claude finished @ajitpratap0's task —— View job PR Review: MariaDB SQL Dialect ImplementationComprehensive review of the MariaDB dialect implementation focusing on code quality, best practices, potential issues, performance, security, and test coverage. Review Tasks
✅ Code Quality & ArchitectureExcellent Design Decisions:
Well-structured keyword organization in
✅ Implementation QualityAST Nodes - Well-designed with proper object pooling:
Parser Logic - Robust implementation:
✅ Test Coverage (23 tests across 3 packages)Excellent coverage breadth:
Test data quality: Realistic SQL examples covering edge cases and feature combinations
|
Summary
Adds MariaDB as a fully-supported SQL dialect (
--dialect mariadb) extending MySQL with three MariaDB-specific feature areas: SEQUENCE DDL, temporal tables, and CONNECT BY hierarchical queries.What's New
MariaDB Dialect (
DialectMariaDB)validDialects, supported in CLI and high-level APISEQUENCE DDL
Full option set:
START WITH,INCREMENT BY,MINVALUE,MAXVALUE,CACHE,CYCLE,NOCACHE,NOCYCLE,RESTART,RESTART WITH.Temporal Tables
CONNECT BY Hierarchical Queries
Supports
PRIORprefix operator,START WITH, andNOCYCLE.Changes
keywords/dialect.go,keywords/mariadb.go,keywords/keywords.goDialectMariaDBconstant, 17 MariaDB-specific keywords, MySQL inheritancekeywords/detect.goast/ast.go,ast/sql.go,ast/pool.goCreateSequenceStatement,DropSequenceStatement,AlterSequenceStatement,ForSystemTimeClause,PeriodDefinition,ConnectByClause; extendedTableReferenceandSelectStatementparser/mariadb.go(new, ~390 lines)parser/parser.go,parser/ddl.go,parser/select.go,parser/select_subquery.gop.isMariaDB()config/config.go,cmd/validate.go"mariadb"invalidDialectskeywords/mariadb_test.go,ast/ast_sequence_test.go,parser/mariadb_test.goparser/testdata/mariadb/*.sqldocs/SQL_COMPATIBILITY.md,CHANGELOG.mdTest Coverage
TestMariaDB_SQLFiles) parses every statement intestdata/mariadb/go test -race ./...Design Decisions
MYSQL_SPECIFICkeywords first, thenMARIADB_SPECIFIC— ensures full MySQL compatibilityp.isMariaDB()— zero impact on other dialectsPRIOR colwrapped asFunctionCallnode since it's a prefix operator without a dedicated AST typeTest Plan
go test -race ./...— zero races, all packages passgo test -v -run TestMariaDB ./pkg/sql/parser/ ./pkg/sql/keywords/gosqlx validate "CREATE SEQUENCE s START WITH 1" --dialect mariadbgosqlx validate "SELECT * FROM t FOR SYSTEM_TIME ALL" --dialect mariadbgosqlx validate "SELECT id FROM emp START WITH id=1 CONNECT BY PRIOR id = parent_id" --dialect mariadbgo test -bench=. -benchmem ./pkg/sql/parser/— performance healthy🤖 Generated with Claude Code