Skip to content

Milestones 6 and 7: DDL and utility statements — parse corpus at 100% - #6

Merged
kyleconroy merged 24 commits into
mainfrom
claude/milestones-6-7-spztn2
Aug 16, 2026
Merged

Milestones 6 and 7: DDL and utility statements — parse corpus at 100%#6
kyleconroy merged 24 commits into
mainfrom
claude/milestones-6-7-spztn2

Conversation

@kyleconroy

Copy link
Copy Markdown
Contributor

Implements milestones 6 (DDL part 1) and 7 (DDL part 2 + utility) from PLAN.md, driving the parse suite's todo list from 19,787 cases to zero. The gate for milestones 4–7 — 100% of the regress corpus with byte-identical trees, JSON, error messages, and cursor positions — is met; the scan and both split suites are also at zero.

Milestone 6

  • CreateStmt: table elements, column/table constraints (CHECK, UNIQUE, PRIMARY KEY, EXCLUDE, FOREIGN KEY with key match/actions), LIKE clauses, identity/generated columns, partition specs and bounds, typed (OF type) and PARTITION OF tables
  • CreateTableAsStmt including the AS EXECUTE form, with bounded backtracking for the CREATE TABLE t (…) element-list vs. CTAS column-list ambiguity (commits only at AS)
  • AlterTableStmt over TABLE/INDEX/SEQUENCE/VIEW/MATERIALIZED VIEW/FOREIGN TABLE: the full alter_table_cmd set, ATTACH/DETACH PARTITION, AlterTableMoveAllStmt, identity column options, ALTER TYPE … ATTRIBUTE (composite types)
  • IndexStmt, ViewStmt (recursive views via makeRecursiveViewSelect), CreateSeqStmt/AlterSeqStmt, CreateMatViewStmt/RefreshMatViewStmt, CreateSchemaStmt with nested schema elements

Milestone 7

  • Functions/procedures with SQL routine bodies (BEGIN ATOMIC), ALTER FUNCTION, triggers and event triggers, rules, policies
  • GRANT/REVOKE, role grants, ALTER DEFAULT PRIVILEGES
  • Generic DROP/COMMENT/SECURITY LABEL object machinery (function_with_argtypes and friends)
  • Unified ALTER dispatcher: RENAME / SET SCHEMA / OWNER TO / DEPENDS ON EXTENSION across ~30 object kinds, each arm restricted to the tails its object supports
  • DefineStmt family (aggregates, operators, types, collations, text search), operator classes/families, extended statistics, domains, databases, extensions, FDWs/servers/foreign tables/user mappings, publications/subscriptions, tablespaces, conversions, transforms, procedural languages
  • EXPLAIN/VACUUM/ANALYZE/CLUSTER/REINDEX/DO, transactions, SET/RESET/SHOW, LOCK, TRUNCATE, NOTIFY/LISTEN/UNLISTEN, and the rest of the utility set
  • SplitWithParser and IsUtilityStmt now have real implementations (ported from pg_query_split.c / pg_query_is_utility_stmt.c) with unit tests

Byte-parity details the corpus forced out

  • C's zero-valued enums surface as proto-shifted spellings: every AlterTableCmd/RenameStmt carries behavior: DROP_RESTRICT, RenameStmt.relationType defaults to OBJECT_ACCESS_METHOD, AlterPublicationStmt.action to AP_AddObjects
  • NIL-vs-empty-list shapes: the (*) aggregate stores a null list element in DefineStmt.args; an empty BEGIN ATOMIC body is [NIL], not [[]]
  • Support-function ereports carry their C call site's funcname (processCASbits, SplitColQualList, makeOrderedSetArgs, preprocess_pubobj_list, …); ConstraintAttributeSpec's location is always -1 (PG's YYLLOC_DEFAULT gives empty productions -1), so processCASbits errors report no cursor position
  • base_yylex-merged *_LA tokens are never identifiers (found via nulls first in index_elem)
  • makeRangeVarFromAnyName leaves inh false (C makeNode semantics), unlike makeRangeVar

Tooling and docs

  • cmd/difftodo: debug aid printing input/want/got for a file's remaining parse todos
  • PLAN.md updated with as-built notes for milestones 6–7

Testing

  • go test ./... green; every graduated case is regression-locked (a future mismatch is a hard failure, never a new todo)
  • go test -race over the parser and internal packages passes
  • Remaining todo suites (deparse, fingerprint, normalize, normalize_utility) belong to milestones 8–10

🤖 Generated with Claude Code

https://claude.ai/code/session_01J19Kf5LpGUhi2vxFJjzQJE


Generated by Claude Code

claude added 24 commits August 16, 2026 18:59
VariableSetStmt (set_rest/set_rest_more/generic_set, zone_value,
transaction_mode_list), VariableResetStmt, VariableShowStmt,
ConstraintsSetStmt, CheckPointStmt, DiscardStmt, CallStmt,
Create/Alter/Drop Role/User/Group, AlterRoleSetStmt, CreateSchemaStmt,
RoleSpec/RoleId/role_list, and the CREATE/ALTER/DROP dispatch frame.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J19Kf5LpGUhi2vxFJjzQJE
CreateStmt (table elements, column/table constraints, LIKE, partition
specs and bounds, typed and partition-of tables), CreateTableAsStmt
including AS EXECUTE, CreateSeqStmt/AlterSeqStmt, ViewStmt (recursive
views via makeRecursiveViewSelect), IndexStmt, CreateMatViewStmt,
RefreshMatViewStmt, and the shared definition/def_elem, CAS-bits, and
key-action machinery.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J19Kf5LpGUhi2vxFJjzQJE
AlterTableStmt over TABLE/INDEX/SEQUENCE/VIEW/MATERIALIZED VIEW/FOREIGN
TABLE, the full alter_table_cmd set, partition ATTACH/DETACH commands,
AlterTableMoveAllStmt, alter_generic_options, identity column options,
and AlterCompositeTypeStmt (ALTER TYPE ... ATTRIBUTE).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J19Kf5LpGUhi2vxFJjzQJE
Generic DropStmt over all object types, RemoveFuncStmt/RemoveAggrStmt/
RemoveOperStmt, DropCast/DropTransform/DropOpClass/DropOpFamily,
DropOwned/ReassignOwned, DropTableSpace/DropSubscription/Dropdb/
DropUserMapping, CommentStmt, SecLabelStmt, and the shared
function/aggregate/operator_with_argtypes machinery.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J19Kf5LpGUhi2vxFJjzQJE
…ENDS

Unified ALTER dispatcher; RenameStmt, AlterObjectSchemaStmt,
AlterOwnerStmt, AlterObjectDependsStmt, AlterOperatorStmt, AlterTypeStmt,
AlterEnumStmt, AlterCollationStmt, AlterSystemStmt, AlterTblSpcStmt,
AlterStatsStmt, AlterDomainStmt, CreateDomain wiring pieces,
AlterDatabase[Set|RefreshColl]Stmt, AlterEventTrigStmt, AlterTSDictionary.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J19Kf5LpGUhi2vxFJjzQJE
…E ASSERTION

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J19Kf5LpGUhi2vxFJjzQJE
…icies, CREATE ACCESS METHOD

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J19Kf5LpGUhi2vxFJjzQJE
…earch, collations, opclasses, statistics

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J19Kf5LpGUhi2vxFJjzQJE
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J19Kf5LpGUhi2vxFJjzQJE
…appings, IMPORT FOREIGN SCHEMA

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J19Kf5LpGUhi2vxFJjzQJE
…ransforms, TS configurations

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J19Kf5LpGUhi2vxFJjzQJE
…location

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J19Kf5LpGUhi2vxFJjzQJE
…ATION FOR in FROM

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J19Kf5LpGUhi2vxFJjzQJE
…ESET, bare DOUBLE type name, empty routine body

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J19Kf5LpGUhi2vxFJjzQJE
…orpus at zero todos

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J19Kf5LpGUhi2vxFJjzQJE
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J19Kf5LpGUhi2vxFJjzQJE
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J19Kf5LpGUhi2vxFJjzQJE
@kyleconroy
kyleconroy merged commit 89807c6 into main Aug 16, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants