Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
7ece262
Don't include NOTIFY payload in fingerprints. (#353)
duckinator Jul 24, 2026
17934a6
Release 17-6.2.3 (#364)
msepga Aug 25, 2026
ebc4f6d
Normalize role name during fingerprinting (#357)
duckinator Aug 27, 2026
7632d03
Make the TransactionStmt options field affect fingerprints for BEGIN/…
duckinator Aug 27, 2026
47075dd
Summary: Fix a relation going missing when a CTE shares its name (#367)
aurelienbottazini Sep 23, 2026
9f071db
Add stack overflow crash protection, error out instead (#348)
lfittl Sep 26, 2026
e275398
Return errors for PL/pgSQL statements without bodies (#363)
carrerasdarren-cell Sep 26, 2026
bdaee0b
Add benchmarks for serialization/deserialization
lfittl Jun 22, 2026
2e73bba
Pass enclosing message type to generated WRITE_*/READ_* macros
lfittl Sep 24, 2026
10da170
Add pg_query_scan_tokens to get scan result without protobuf
lfittl Sep 26, 2026
06840a2
Read funcs: Drop version check assert
lfittl Sep 26, 2026
2774d89
Refactor stack depth check, restore stack base when done
lfittl Sep 26, 2026
617395c
Switch to upb instead of protobuf-c
lfittl Jun 22, 2026
70f7040
Fingerprint: Apply depth cutoff when recursing into specific node types
lfittl Sep 26, 2026
cb3541b
Check stack depth when recursing directly into specific node types
lfittl Sep 26, 2026
6d6d66b
Normalize: Don't return from inside PG_TRY in const_record_walker
lfittl Sep 26, 2026
ff70834
Normalize: Don't swallow stack depth errors in const_record_walker
lfittl Sep 26, 2026
a34617c
Summary: Free stderr buffer when the tree walk throws
lfittl Sep 26, 2026
7da45b5
Check stack depth in exprLocation
lfittl Sep 26, 2026
be0d884
gitattributes: Ignore line ending style for tests, don't treat as binary
lfittl Sep 26, 2026
6337a5e
Deparser: Rework when parentheses are added based on operator precend…
lfittl Sep 29, 2026
df9f13b
Parser: Avoid quadratic memory use for rules that involve dotted name…
lfittl Sep 29, 2026
aa71ad9
Fingerprint: Add options to control RangeVar fingerprinting and allow…
lfittl Sep 30, 2026
0dd0031
Ignore comments when parsing queries, only treat as significant for s…
lfittl Sep 30, 2026
e550e07
Normalize: Take constant locations from the parser, not the query text
lfittl Sep 10, 2026
c7c6c98
Deparser: Add strict checking for unexpected pointer values (#4)
lfittl Sep 17, 2026
6c8e7d6
README: Clarify release handling for older branches (#380)
lfittl Sep 30, 2026
e087c65
Update to Postgres 18.6 (#381)
lfittl Sep 30, 2026
c1546e7
Release 18.1.0 (#379)
lfittl Sep 30, 2026
f3a0406
Add PL/pgSQL output for PLPGSQL_DTYPE_PROMISE (#384)
lfittl Oct 1, 2026
776c2ac
Document how to report vulnerabilities in SECURITY.md (#383)
lfittl Oct 1, 2026
73d842c
Output default_val, isconst and notnull for PL/pgSQL record variables…
svenklemm Oct 20, 2026
27112f8
OSS-Fuzz: Add new fuzzer target for deparsing (#376)
arthurscchan Nov 10, 2026
b4fd2a0
Summary: Fix a CTE reported as a table when a nested WITH redefines i…
jessieay Nov 20, 2026
0a47254
Return an error when parsing runs out of memory (#394)
R3gardless Nov 20, 2026
8c80b9f
Support parsing parameter references for NOTIFY payload (#387)
lfittl Nov 20, 2026
9409eec
Create the thread-exit key once per process (#401)
colinhacks Nov 20, 2026
7663e07
Free the error in pg_query_free_deparse_comments_result() (#392)
R3gardless Nov 20, 2026
0870a3c
Sync 18-constructive with upstream PostgreSQL 18.6
pyramation Nov 22, 2026
e40f64c
Support schema-qualified PL/pgSQL types without a catalog
pyramation Nov 22, 2026
611eea0
fix: derive PL/pgSQL block labels from unqualified function names
pyramation Nov 22, 2026
815b347
fix: recognize typed VARIADIC arrays in PG18 PL/pgSQL parser
pyramation Nov 22, 2026
0093649
Serialize retvarno for PL/pgSQL RETURN / RETURN NEXT
pyramation Nov 22, 2026
5be69de
Serialize PL/pgSQL OUT parameter datum indexes on PG 18
pyramation Nov 22, 2026
2bd2d93
Report scan allocation failures as out-of-memory errors
pyramation Nov 22, 2026
5ab5824
fix: preserve PL/pgSQL record datatypes and record arrays on PG18
pyramation Nov 22, 2026
29651ab
Preserve PL/pgSQL declaration type spelling
pyramation Nov 22, 2026
6d54ae2
Preserve PL/pgSQL ALIAS FOR declarations on PG18
pyramation Nov 22, 2026
7efa2ab
fix: restore standalone PL/pgSQL RETURN compatibility on PG18
pyramation Nov 22, 2026
32631e8
Guard recursion when serializing PL/pgSQL statements
pyramation Nov 22, 2026
1e54c6b
chore: regenerate PL/pgSQL expected output for combined PG 18 patches…
pyramation Nov 22, 2026
002792f
fix: treat custom-type arrays as array variables, not records, in PL/…
pyramation Nov 22, 2026
8620f7f
fix: mark skipped non-PL/pgSQL functions as having no OUT parameter
pyramation Nov 22, 2026
d63bdb1
fix: detect trigger functions only by unqualified or pg_catalog trigg…
pyramation Nov 22, 2026
0832f81
fix: recognize database-qualified pg_catalog trigger return types
pyramation Nov 22, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
*.sql binary
*.psql binary
# Never convert line endings for test SQL files (e.g. to CRLF on Windows checkouts),
# since the tests compare exact bytes. These are still text, so diffs show up in reviews.
*.sql -text
*.psql -text

# Contains WIN1252-encoded (non-UTF-8) data
test/sql/postgres_regress/collate.windows.win1252.sql binary
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
matrix:
os: [ubuntu-24.04]
compiler: [clang, gcc]
protobuf_lib: [protobuf-c, protobuf-cpp]
protobuf_lib: [upb, protobuf-cpp]
valgrind: [valgrind,no-valgrind]
exclude:
# this combination hits linking errors: see https://github.com/pganalyze/libpg_query/pull/289
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ pg_query.lib
examples/*
!examples/*.c

benchmark/*
!benchmark/*.c
!benchmark/*.md

test/*
!test/*.c
!test/*.sql
Expand All @@ -21,3 +25,5 @@ tmp/*
!tmp/.gitkeep

.vs/*

vendor/upb/.upb-update-tmp/
116 changes: 116 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,88 @@

All versions are tagged by the major Postgres version, plus a minor/patch version to indicate changes to the libpg_query supporting code. The minor version does not reflect the Postgres minor version, but is instead used to indicate major or API breaking changes in libpg_query itself.

## 18.1.0 2026-09-30

* Security fix: Heap out-of-bounds write and read in pg_query_normalize ([GHSA-6ggm-xmc9-8ffg](https://github.com/pganalyze/libpg_query/security/advisories/GHSA-6ggm-xmc9-8ffg))
- When normalizing certain utility statements (e.g. `DO ... LANGUAGE`, statements with
string options, or `CREATE/ALTER SUBSCRIPTION ... CONNECTION`), pg_query_normalize
searched the query text for the location of string constants, which could yield
wrong locations for crafted input. This could cause out-of-bounds writes and reads
on the heap, leaking process memory in the normalized output or crashing the process.
- Constant locations are now recorded by the parser instead, and the normalizer checks
at runtime that constant locations never overlap
- This adds new location fields to the parse tree output (`DefElem.arg_location`,
`NotifyStmt.payload_location`, `CreateSubscriptionStmt.conninfo_location` and
`AlterSubscriptionStmt.conninfo_location`). Like other location fields, these are
ignored for fingerprinting.
- Applications that normalize untrusted query text should upgrade
- Reported by Paul Gerste (Cure53)
* Deparser: Add strict checking for unexpected pointer values
- This ensures that a bad input parse tree doesn't cause the deparser to crash, and
instead returns an error
- Use cases that do not work with user input can define `PG_QUERY_DEPARSE_NO_STRICT_CHECKS`
to turn off the most detailed checks, for slightly better performance
- Reported by Paul Gerste (Cure53)
* Add stack overflow crash protection, error out instead [#348](https://github.com/pganalyze/libpg_query/pull/348)
- Overly deep queries now return the standard Postgres "stack depth limit exceeded"
error instead of crashing the process
- The allowed stack depth defaults to 100 kB, auto-sized up to 2 MB, and is
recalculated on each call, since callers may use threads with varying stack sizes
- Stack depth is also checked when recursing directly into specific node types (e.g.
long `UNION` chains), and in `exprLocation` during raw parsing
* Switch Protobuf implementation from protobuf-c to upb
- upb is developed as part of the main Protobuf project, and is substantially faster,
in part due to its built-in arena allocation
- upb also allows limiting parse depth for complex Protobuf input, avoiding crashes
* Update to Postgres 18.6 release
* Add `pg_query_scan_tokens` to get scan results without involving Protobuf
- This allows pure C callers to walk a simple list of `PgQueryScanToken` structs
* Ignore comments when parsing queries, only treat them as significant for scanning [#378](https://github.com/pganalyze/libpg_query/pull/378)
- This fixes parse errors when comments are placed between related tokens
(e.g. `NOT /* comment */ IN`), or between string literals that get concatenated
* Parser: Avoid quadratic memory use for rules that involve dotted names [#374](https://github.com/pganalyze/libpg_query/pull/374)
* Return errors for PL/pgSQL statements without bodies [#363](https://github.com/pganalyze/libpg_query/pull/363)
- This avoids an assertion failure or crash when `CREATE FUNCTION` or `DO` omits
its function body
* Fingerprinting: Add fingerprint options to `pg_query_fingerprint_opts` [#361](https://github.com/pganalyze/libpg_query/pull/361)
- This is a breaking change for callers of `pg_query_fingerprint_opts`,
which now takes a fingerprint options bitmask as a third argument
- By default, relation references are fingerprinted following Postgres 18+
query ID behavior: in SELECT/DML statements the alias name replaces the
relation name when present, and schema names are ignored
- `PG_QUERY_FINGERPRINT_RANGEVAR_IGNORE_ALIASES` always fingerprints
relation names and ignores aliases
- `PG_QUERY_FINGERPRINT_RANGEVAR_INCLUDE_SCHEMA` also fingerprints schema
names in SELECT/DML statements
- Combining both flags (`PG_QUERY_FINGERPRINT_RANGEVAR_PG17_COMPAT`)
matches how Postgres 17 and earlier calculate query IDs, and how
libpg_query 17 and earlier calculated fingerprints
- `PG_QUERY_FINGERPRINT_FULL_RELNAME` fingerprints the full relation name,
instead of the default behavior of ignoring 2+ consecutive digits (which
groups queries on date/number-suffixed tables together)
* Fingerprinting:
- Ignore `NOTIFY` payloads, similar to channel names [#353](https://github.com/pganalyze/libpg_query/pull/353)
- Ignore role names (e.g. in `CREATE ROLE`, `DROP ROLE`, `GRANT` and `ALTER ... RENAME`) [#357](https://github.com/pganalyze/libpg_query/pull/357)
- Include `BEGIN`/`START TRANSACTION` options (e.g. read-only, isolation level) [#358](https://github.com/pganalyze/libpg_query/pull/358)
- Apply the depth cutoff when recursing into specific node types
- This changes fingerprints for set operation chains deeper than 100 levels,
which are now cut off consistently like other deeply nested nodes
* Deparser:
- Rework when parentheses are added based on operator precedence [#371](https://github.com/pganalyze/libpg_query/pull/371)
- This fixes cases where the deparsed SQL changed meaning or was invalid, and
avoids adding unnecessary parentheses in others
- Use `strlcpy` instead of `strncpy` in deparser and summary truncate [#345](https://github.com/pganalyze/libpg_query/pull/345)
* pg_query_normalize:
- Add support for `NOTIFY` statements [#340](https://github.com/pganalyze/libpg_query/pull/340)
- Avoid undefined behaviour for overly large parameter references [#346](https://github.com/pganalyze/libpg_query/pull/346)
- Fix handling of `U&` special constants in DefElem nodes [#347](https://github.com/pganalyze/libpg_query/pull/347)
- Don't swallow stack depth errors and return a partially normalized query
* pg_query_summary:
- Fix a relation going missing when a CTE shares its name [#367](https://github.com/pganalyze/libpg_query/pull/367)
- Fix memory leak when the tree walk throws an error
* Use built-in `strlcpy`/`strlcat` on older glibc versions [#339](https://github.com/pganalyze/libpg_query/pull/339)
* Add new OSS-Fuzz fuzzer targets for Protobuf processing and PL/pgSQL parsing [#341](https://github.com/pganalyze/libpg_query/pull/341) [#343](https://github.com/pganalyze/libpg_query/pull/343)

## 18.0.0 2026-05-20

* Upgrade to Postgres 18
Expand All @@ -22,6 +104,40 @@ All versions are tagged by the major Postgres version, plus a minor/patch versio
pointer values, that would be retained in such a copy).
* Fingerprinting: Rework alias/schema name handling to match Postgres 18

## 17-6.2.4 2026-09-30

* Security fix: Heap out-of-bounds write and read in pg_query_normalize ([GHSA-6ggm-xmc9-8ffg](https://github.com/pganalyze/libpg_query/security/advisories/GHSA-6ggm-xmc9-8ffg))
- When normalizing certain utility statements (e.g. `DO ... LANGUAGE`, statements with
string options, or `CREATE/ALTER SUBSCRIPTION ... CONNECTION`), pg_query_normalize
searched the query text for the location of string constants, which could yield
wrong locations for crafted input. This could cause out-of-bounds writes and reads
on the heap, leaking process memory in the normalized output or crashing the process.
- Constant locations are now recorded by the parser instead, and the normalizer checks
at runtime that constant locations never overlap
- This adds new location fields to the parse tree output (`DefElem.arg_location`,
`NotifyStmt.payload_location`, `CreateSubscriptionStmt.conninfo_location` and
`AlterSubscriptionStmt.conninfo_location`). Like other location fields, these are
ignored for fingerprinting.
- Applications that normalize untrusted query text should upgrade
- Reported by Paul Gerste (Cure53)
* Deparser: Add strict checking for unexpected pointer values
- This ensures that a bad input parse tree doesn't cause the deparser to crash, and
instead returns an error
- Use cases that do not work with user input can define `PG_QUERY_DEPARSE_NO_STRICT_CHECKS`
to turn off the most detailed checks, for slightly better performance
- Reported by Paul Gerste (Cure53)
* pg_query_normalize:
- Add support for `NOTIFY` statements [#340](https://github.com/pganalyze/libpg_query/pull/340)
- Avoid undefined behaviour for overly large parameter references [#346](https://github.com/pganalyze/libpg_query/pull/346)

## 17-6.2.3 2026-08-24

* Deparser:
- Preserve parentheses around subscripted array constructors
- This prevents `(ARRAY[...])[...]` from being deparsed as invalid SQL
- Fix handling of constraint key named `value` in `ALTER TABLE` [#329](https://github.com/pganalyze/libpg_query/pull/329)
* Preserve `ARFLAGS` when overriding `AR` [#328](https://github.com/pganalyze/libpg_query/pull/328)

## 17-6.2.2 2026-01-26

* pg_query_normalize: Fix handling of special strings in DefElem [#325](https://github.com/pganalyze/libpg_query/pull/325)
Expand Down
Loading
Loading