Skip to content

feat: add PostgreSQL 18 support#149

Merged
pyramation merged 8 commits into
mainfrom
feat/pg18-setup
May 22, 2026
Merged

feat: add PostgreSQL 18 support#149
pyramation merged 8 commits into
mainfrom
feat/pg18-setup

Conversation

@pyramation
Copy link
Copy Markdown
Collaborator

@pyramation pyramation commented May 22, 2026

Summary

Adds PostgreSQL 18 support targeting the upstream 18.0.0 tag from pganalyze/libpg_query.

New packages:

  • versions/18/@libpg-query/v18 with libpgQueryTag: "18.0.0"
  • types/18/@libpg-query/types18 (proto parser points to protos/18/pg_query.proto)
  • enums/18/@libpg-query/enums18 (proto parser points to protos/18/pg_query.proto)
  • protos/18/pg_query.proto — fetched from upstream 18.0.0

Config/script updates:

  • pnpm-workspace.yaml — added versions/18, types/18, enums/18
  • scripts/fetch-protos.js — added '18' to version list
  • scripts/update-versions-types.js — extended range to include PG 18
  • parser/package.json — added ./v18 export entries
  • parser/scripts/prepare.js — updated full (13-18) and lts (15-18) build configs
  • parser/test/ — updated version arrays and error message assertions for PG 18

CI updates:

  • Added v18 to build-wasm and test matrices
  • Added v18 WASM artifact download steps in build-parser and test-parser jobs
  • Added v18 to types build loop

README updates:

  • Updated version tables in ALL version READMEs (v13-v18) to include PG 18
  • Updated @pgsql/parser descriptions to mention PG 18 support
  • Updated root README with PG 18 references, install examples, and API doc links

Not included (follow-up): The full/ package (@libpg-query/parser) remains on PG 17. Upgrading it requires wasm_wrapper.c changes for breaking API changes in PG 18 (deparse opts by pointer, new functions like pg_query_summary, pg_query_is_utility_stmt, reworked PL/pgSQL parsing).

Review & Testing Checklist for Human

  • Verify the v18 WASM builds successfully in CI (emscripten compilation of libpg_query 18.0.0)
  • Verify v18 tests pass on all 3 platforms (ubuntu, macos, windows)
  • Verify the parser package build succeeds with all 6 versions (13-18)
  • Once types are published to npm as @pgsql/types@pg18, update versions/18/package.json dependency from ^17.6.2 to the appropriate ^18.x version
  • Run pnpm run build:proto in types/18/ and enums/18/ to regenerate TS types from the PG 18 proto (the current src files are carried over from v17 and need regeneration)

Notes

  • The upstream tag naming convention changed: 18.0.0 instead of the old 17-6.1.0 dash-separated format. This is correct — upstream genuinely changed their convention for PG 18.
  • PG 18 proto adds a new ReturningExpr node type and shifts all subsequent Node oneof field numbers
  • The types/18/src/ and enums/18/src/ files are currently the v17-generated TS files — they'll be correct after running build:proto against the v18 proto

Link to Devin session: https://app.devin.ai/sessions/5d3588c124524869b388ced885962d70
Requested by: @pyramation

- Add versions/18/ package targeting libpg_query 18.0.0
- Add types/18/ and enums/18/ packages with proto parser pointing to protos/18/
- Fetch protos/18/pg_query.proto from upstream 18.0.0 tag
- Update pnpm-workspace.yaml with v18 entries
- Update parser/ with v18 exports and build configs (full: 13-18, lts: 15-18)
- Update CI workflow with v18 build/test matrix entries
- Update scripts (fetch-protos, update-versions-types) for v18
- Update README.md and PUBLISH.md with PG 18 references

Note: The full/ package (@libpg-query/parser with deparse, fingerprint, etc.)
remains on PG 17 — upgrading it to PG 18 requires wasm_wrapper.c changes
for the new API (deparse opts by pointer, new functions like pg_query_summary,
pg_query_is_utility_stmt, reworked PL/pgSQL parsing).
@devin-ai-integration
Copy link
Copy Markdown

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Previously types/18/src and enums/18/src were byte-identical to v17
(build:proto was never run against protos/18/pg_query.proto), so the
published @pgsql/types@pg18 / @pgsql/enums@pg18 packages had the PG 17
AST shape. This regenerates from protos/18/pg_query.proto, picking up:

  - new node types: ReturningExpr, ReturningClause, ReturningOption,
    ATAlterConstraint, SummaryResult (plus nested Table/Function/
    FilterColumn/Context under SummaryResult)
  - removed node: SinglePartitionSpec
  - new enums: CompareType, ReturningOptionKind, VarReturningType
  - removed enum: RowCompareType (subsumed by CompareType)
  - field additions on 19 messages, mostly RETURNING OLD/NEW
    machinery, application-time period constraints, virtual generated
    columns, NOT ENFORCED, and parser location metadata
Nothing has shipped to npm yet for PG 18 (no 18.x on registry for
@pgsql/types or @pgsql/enums), and the previous 18.0.1/18.0.2 bumps
were paired with stale src/ generated from PG 17. Resetting so the
first real PG 18 publish lands as a clean 18.0.0.

  - types/18:    18.0.2 -> 18.0.0
  - enums/18:    18.0.1 -> 18.0.0
  - versions/18: 18.0.1 -> 18.0.0
@pyramation pyramation merged commit eeecfcb into main May 22, 2026
66 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.

1 participant