You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit c3e1714
Browse filesBrowse the repository at this point in the historyBrowse files
feat: extend PostgreSQL expressions, query composition and object DDL
Expand ParserSQL's own PostgreSQL grammar with structured productions for
VARIADIC arguments, array slices, ILIKE/SIMILAR TO and ESCAPE, POSITION,
OVERLAY, IS JSON and ORDER BY USING in queries, aggregates and windows.
Preserve bit/hex literal prefixes, field/subscript indirection and pattern
precedence through SQL reconstruction. Reject incomplete binary operands,
invalid fields and malformed nonassociative predicate chains.
Represent nested joins, USING aliases, TABLESAMPLE/REPEATABLE, ROWS FROM,
row-lock strengths/targets/wait policies and SELECT INTO explicitly.
Retain the established AST representation for compatible simple joins and
preserve comma-join scope for richer trees. Distinguish PostgreSQL EXCEPT
query operands from ParserSQL's existing star-column exclusion extension.
EXPLAIN now retains grouped options and forwards inner completion/error
state instead of reporting an incomplete or failed child as successful.
Add CREATE/ALTER DOMAIN, shell/composite/enum/range/base TYPE definitions,
CREATE/ALTER SEQUENCE, routine properties and SET/RESET clauses, common
object identity changes and additional DROP families. Validate object
names, option boundaries, defaults, constraints and quoted prefixes while
retaining traversable names, types, expressions and clause operands.
Map PostgreSQL DefineStmt to CREATE in the development compatibility tool.
Append AST node kinds without changing the 48-byte layout. Guard local
execution of newly represented semantics, including PostgreSQL bit/hex
literals, and keep parameterization conservative. Production parsing has
no PostgreSQL runtime dependency or fallback. Benchmarks and benchmark-only
documentation/configuration edits are intentionally outside this commit.
Validation:
- Forced make all/build-corpus-test: 1,455 passed; 37 external-backend skips.
- ASan/UBSan: all 27 new tests passed, including bounded-arena sweeps.
- 87 Python PostgreSQL compatibility harness tests passed.
- PostgreSQL 18.4 raw AST comparisons: all 1,838 relevant object-DDL corpus
statements and 405 newly covered query/DML/EXPLAIN cases matched after
removing source positions; positive/negative and mutation controls passed.
- Independent review confirmed pattern precedence, EXPLAIN, allocation
handling, AST emission, execution guards and MySQL compatibility.
The separately committed correctness snapshot records the complete corpus
replay and remaining unsupported grammar; this does not claim full parity.
# PostgreSQL grammar continuation implementation plan
2
+
3
+
> **For agentic workers:** Use superpowers:subagent-driven-development for independent expression and DDL work. Parent owns query integration and final verification.
4
+
5
+
**Goal:** Extend the native parser against the remaining PostgreSQL corpus, prioritizing SELECT composition and common object DDL.
6
+
**Architecture:** Preserve the current tokenizer/arena/AST architecture; add validated productions and explicit nodes where existing AST shapes cannot preserve semantics. Unsupported local engine behavior must be rejected before execution. Use the pinned PostgreSQL parser only as a development oracle.
**Spec:** Continues the user-approved native grammar work documented in 2026-09-26-pg-grammar-gaps.md and the user's request to continue filling remaining gaps.
9
+
10
+
## Global constraints
11
+
12
+
- Continue branch feat/postgresql-coverage-and-ast-apis and update PR #67 with detailed commits.
13
+
- Do not commit benchmarks, benchmark README/.gitignore edits, or generated binaries.
14
+
- Preserve MySQL behavior, appended enum values, and the 48-byte AST layout.
15
+
- No runtime PostgreSQL dependency or unvalidated opaque-tail acceptance.
16
+
- Base 91880dc: 43,373 deep parses of 51,415 pinned corpus statements; preserve prior accepted coverage.
17
+
18
+
## Review focus
19
+
20
+
- Nested joins retain association and ON/USING ownership through emission.
21
+
- Keywords used as names and quoted names remain distinguishable from grammar.
22
+
- New syntax operands stay traversable; syntax constants do not become bind values.
23
+
- Malformed separators/clauses and exhausted arenas cannot produce a truncated successful AST.
24
+
- Planner guards reject new semantics rather than executing a simplified statement.
25
+
26
+
## Tasks
27
+
28
+
-[x] Expressions: tests/test_pg_expression_continuation.cpp; expression_parser.h and owned shared markers. Start with failing positive/negative fixtures for VARIADIC calls, array slices, ILIKE/SIMILAR TO/ESCAPE, POSITION/OVERLAY and IS JSON. Examples: SELECT a[:3], b[1:]; SELECT POSITION('a' IN s); SELECT OVERLAY(s PLACING 'x' FROM 2 FOR 1); SELECT f(VARIADIC ARRAY[1,2]); SELECT doc IS JSON OBJECT WITH UNIQUE KEYS. Compare emitted PostgreSQL AST, reject malformed bounds/operands and guard local execution.
29
+
-[x] DDL: tests/test_pg_object_ddl.cpp; pg_ddl_parser.h. Start with ALTER FUNCTION f(int) PARALLEL SAFE, CREATE DOMAIN d AS int CHECK(VALUE>0), CREATE TYPE t AS ENUM('a','b'), CREATE TYPE t AS(a int,b text), CREATE SEQUENCE s START WITH 3, ALTER SEQUENCE s RESTART WITH 4. Add routine options/ownership/schema/renaming, common ALTER domain/type/sequence and validated remaining DROP families. Keep names/types/expressions structural. Verify positive/negative/oracle cases.
30
+
-[x] Query composition: tests/test_pg_query_continuation.cpp; table_ref_parser.h, select_parser.h, compound_query_parser.h and pg_query_clauses.h. Tests first for parenthesized/nested joins, TABLESAMPLE/REPEATABLE, ROWS FROM, ORDER BY USING operators, row-lock strength/OF/wait policies and SELECT INTO. Preserve EXPLAIN options and inner completion while validating new query forms inside EXPLAIN. Preserve existing simple-join execution representation where possible; use appended guarded nodes for richer forms. Validate PostgreSQL AST equivalence and malformed syntax.
31
+
-[ ] Integration: register tests, run independent cross-reviews, force full build and corpus runner, focused ASan/UBSan, oracle comparisons and Python harness. Replay all 51,415 statements and inspect losses/status transitions. Commit implementation first, refresh correctness snapshot against that commit, verify full compatibility workflow, commit snapshot and push/update PR #67. Report concrete remaining grammar variants without claiming complete PostgreSQL parity.
32
+
33
+
Implementation workers must not commit, run full make or change shared files outside their owned markers. Parent consolidates commits and verifies the final tree.
0 commit comments