Repository navigation
Commit 19d77ca
committed
feat: parse PostgreSQL policies, statistics and foreign objects
Continue the native PostgreSQL grammar with CREATE/ALTER POLICY and extended
statistics, preserving policy modes, commands, roles and predicates as AST
children. Retain the distinction between statistics columns, function calls
and parenthesized expressions, and reuse native FROM parsing for relations,
aliases and joins. Support statistics targets and object identity changes.
Add foreign data wrappers, servers, user mappings and foreign tables, plus
IMPORT FOREIGN SCHEMA. Preserve handler/validator names, server type/version,
mapping roles, inheritance and partition clauses, relation lists and generic
option names/string values. CREATE option pairs and ALTER ADD/SET/DROP actions
have validated productions. Extend shared column definitions for PostgreSQL
STORAGE, COMPRESSION and OPTIONS syntax without a raw SQL tail fallback.
Append IMPORT_FOREIGN_SCHEMA to the statement types and update compatibility
mapping/name tests. Reuse guarded DDL nodes, keeping enum values, the 48-byte
AST layout and MySQL behavior intact. Parsing these statements does not
execute policies, collect statistics, contact foreign servers or import data.
There is no PostgreSQL fallback or new production parser dependency.
Add positive and malformed fixtures, structured AST traversal/editing,
reconstruction, unsupported execution/parameterization and arena exhaustion
checks. Fix the IMPORT allocation-failure null dereference exposed by the
expanded arena sweep, and cover the grammar boundary cases found in review.
Document supported forms and the remaining shared ALTER CONSTRAINT gap.
Validation:
- Forced full build and corpus executable: 1,483 passed; 37 tests requiring
external databases skipped.
- New grammar suites under ASan/UBSan: 11/11 passed.
- Compatibility harness: 87 tests passed.
- Same 51,415 PostgreSQL 18.4 source statements: 49,120 deeply supported
(95.5%), +807 over 398450a, with no previously supported cases lost.
- All 807 newly supported statements reconstruct to equivalent PostgreSQL
raw ASTs after excluding source-position fields only.
- Independent task and integrated grammar review, including targeted oracle
checks for malformed options, roles and ALTER FOREIGN TABLE boundaries.
The correctness snapshot follows in a separate commit. Benchmark files and
benchmark-only README/.gitignore changes remain excluded.1 parent 398450a commit 19d77ca
9 files changed
Lines changed: 715 additions & 8 deletions
File tree
- docs
- superpowers/plans
- include/sql_parser
- tests
- pg_compat
- tools/pg_compat
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
| 63 | + | |
62 | 64 | | |
63 | 65 | | |
64 | 66 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
171 | 188 | | |
172 | 189 | | |
173 | | - | |
| 190 | + | |
| 191 | + | |
174 | 192 | | |
175 | 193 | | |
176 | 194 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
| 136 | + | |
136 | 137 | | |
137 | 138 | | |
138 | 139 | | |
| |||
0 commit comments