Skip to content

Advance the pin to libpg_query 18.1.0 (PostgreSQL 18.6) - #14

Merged
kyleconroy merged 1 commit into
mainfrom
claude/project-thread-zg9pu0
Dec 1, 2026
Merged

kyleconroy merged 1 commit into
mainfrom
claude/project-thread-zg9pu0

Conversation

@kyleconroy

Copy link
Copy Markdown
Contributor

Requested by Kyle · project thread

Summary

The request was Postgres 19. PostgreSQL 19.0 is out, but pganalyze/libpg_query has no 19 release, branch or PR yet, and our goldens can only come from the pinned libpg_query oracle. So this PR moves the pin to the newest release, libpg_query 18.1.0 (PostgreSQL 18.6). The 19 upgrade can follow once libpg_query ships it.

ParseResult.Version is now 180006. Every golden in parser/testdata was regenerated with cmd/regenerate against the 18.1.0 oracle. None were edited by hand, and two regenerate runs produced byte-identical output.

What changed upstream and how it was ported

  • Lexer (patch 04): comments are now whitespace to the grammar unless return_comments is set, which only pg_query_scan does. Before, NOT /* c */ IN did not merge to NOT_LA; now it does. A -- comment between continued string literals is now allowed. Scan uses the new lexer.NewReturningComments.
  • New location fields (patch 15): DefElem.arg_location, NotifyStmt.payload_location, and CreateSubscriptionStmt/AlterSubscriptionStmt.conninfo_location. makeDefElem defaults arg_location to -1. The LANGUAGE rule is split into NonReservedWord and Sconst forms.
  • Normalize: constant locations come from the parser instead of a text scan. There is an overlap and bounds check, and NOTIFY payloads are normalized.
  • Fingerprint: new skip fields (the new location fields, the NOTIFY payload, role names in CreateRole, Rename and RoleSpec). TransactionStmt.options is now included. A specific node field is cut off at the depth limit.
  • Deparse: operator-precedence based parenthesization (libpg_query #371), in the new internal/deparse/precedence.go.
  • Summary: CTE self-reference handling (#367).
  • PL/pgSQL: DO and plpgsql functions with no body now error, matching #363.
  • Oracle and tooling: oracle/update-pg-query-go.sh copies upb instead of protobuf-c, plus pg_query_scan_tokens.h, and falls back to pg_query_go's testdata now that libpg_query dropped testdata/fingerprint.json. cmd/regenerate accepts the NULL sentinel that now ends parse_tests.c.
  • Reference and generated files: internal/reference was re-vendored from PG 18.6 with patches 01, 03, 04, 09, 14 and 15. srcdata is from the 18.1.0 tag. Generated files were rebuilt with cmd/generate. The docs (README, PLAN.md, CLAUDE.md, the regenerate workflow) now name the new pin.

Not ported

  • 18.1.0 adds stack-depth checks for deeply nested input. The C limit depends on the build's stack size, so the result isn't deterministic, and oliphant does not emulate it.
  • ALTER SUBSCRIPTION s CONNECTION '' crashes the C deparser. oliphant returns a result here, so this one case can't be matched.

Testing

  • go test ./... passes, and go test ./parser -run TestCorpus -check-parse shows 0 todo cases in every suite.
  • gofmt and go vet are clean.
  • I spot-checked 49 edge-case inputs against the oracle for parse, deparse, normalize and fingerprint. The only mismatch was the deparser crash listed above.

Generated by Claude Code

Moves the oracle and the reference grammar to libpg_query 18.1.0 and
regenerates every golden from it. Ports the behavior changes:

- Lexer: comments are whitespace to the grammar unless returnComments
  is set (only Scan sets it); "--" comments may sit between continued
  string literals.
- Parser: DefElem.arg_location, NotifyStmt.payload_location and
  Create/AlterSubscriptionStmt.conninfo_location; LANGUAGE split into
  NonReservedWord and Sconst forms.
- Normalize: constant locations come from the parser, with an overlap
  check; NOTIFY payloads are normalized.
- Fingerprint: new skip fields (location fields, NOTIFY payload, role
  names), TransactionStmt options included, depth cutoff for specific
  node fields.
- Deparse: operator-precedence based parenthesization (#371).
- Summary: CTE self-reference handling (#367).
- PL/pgSQL: errors for a DO or function with no body (#363).
- Oracle build script: upb instead of protobuf-c, scan tokens header,
  testdata now from pg_query_go. Regenerate accepts the NULL sentinel
  in parse_tests.c.

Version is now 180006.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LuRZ4KpRYD6ucjb97ykMZQ
@kyleconroy kyleconroy self-assigned this Dec 1, 2026
@kyleconroy
kyleconroy merged commit 6a524ae into main Dec 1, 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