- ...
- Upgrade to libpg_query 17-6.2.5
- Security fix: Heap out-of-bounds write and read in Normalize (GHSA-6ggm-xmc9-8ffg)
- When normalizing certain utility statements (e.g.
DO ... LANGUAGE, statements with string options, orCREATE/ALTER SUBSCRIPTION ... CONNECTION), 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.ArgLocation,NotifyStmt.PayloadLocation,CreateSubscriptionStmt.ConninfoLocationandAlterSubscriptionStmt.ConninfoLocation). Like other location fields, these are ignored for fingerprinting. - Applications that normalize untrusted query text should upgrade
- Reported by Paul Gerste (Cure53)
- When normalizing certain utility statements (e.g.
- 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
- Reported by Paul Gerste (Cure53)
- Preserve parentheses around subscripted array constructors
- This prevents
(ARRAY[...])[...]from being deparsed as invalid SQL
- This prevents
- Fix handling of constraint key named
valueinALTER TABLE
- Add strict checking for unexpected pointer values
- Normalize:
- Add support for
NOTIFYstatements - Avoid undefined behaviour for overly large parameter references
- Fix compiler warning due to mismatch between
int64andlong
- Add support for
- Security fix: Heap out-of-bounds write and read in Normalize (GHSA-6ggm-xmc9-8ffg)
- Bump google.golang.org/protobuf from 1.31.0 to 1.33.0 #111
- Upgrade to libpg_query 17-6.2.2
- Add IsUtilityStmt function to determine if query text contains utility statements
- This is a fast check for callers that don't actually need the parse tree itself
- Add Summary function to get summary information about a statement quickly
- This allows gathering certain information, for example which tables are referenced in a statement, without requiring a Protobuf serialization step in a higher level library
- Additionally this can also be used to perform "smart truncation" of a query by omitting deeply nested information (e.g. a CTE definition, or a target list) whilst preserving more essential parts like the FROM clause
- Normalize:
- Fix handling of special strings in DefElem
- This avoids a crash when running the normalize function on certain utility statements
- Add support for CALL statements
- Fix handling of special strings in DefElem
- Deparser:
- Introduce pretty printing / formatting
- Introduces a new optional pretty print mode that emits a human readable output. A detailed explanation of the mechanism can be found at the start of the deparser file.
- Rework handling of expressions inside typecasts
- Prefer (..)::type syntax, unless we are already in a function call.
- Use lowercase keywords in xmlroot functions
- This matches other XML functions as well as the Postgres documentation, since these are closer to function argument names than regular keywords.
- Fix deparse of ALTER TABLE a ALTER b SET STATISTICS DEFAULT
- Fix the null pointer dereference when handling identity columns
- Introduce pretty printing / formatting
- Allow alternate definitions of NAMEDATALEN identifier limit
- This allows building libpg_query with an override of the built-time limit of Postgres identifiers (typically 63 characters)
- Bump Postgres to 17.7 and switch back to release tarballs
- Add IsUtilityStmt function to determine if query text contains utility statements
- Avoid conflicts with other cgo libraries utilizing xxhash by using XXH_NAMESPACE #144
- Remove redundant copy of result in ParseToProtobuf #139
- Upgrade to libpg_query 17-6.1.0
- Update to Postgres 17.4, and add recent patches scheduled for Postgres 17.5 (not yet released)
- Notably, this pulls in support for macOS 15.4 which defines strchrnul in its standard library, fixing builds on up-to-date macOS versions.
- Deparser improvements
- Add parenthesis around AT LOCAL / AT TIMEZONE if needed
- Correctness improvements related to expressions and function calls
- Update to Postgres 17.4, and add recent patches scheduled for Postgres 17.5 (not yet released)
- Allow vendoring pg_query_go with built-in "go mod vendor" command (#131)
- Upgrade to libpg_query 17-6.0.0
- Updates to the Postgres 17 parser
- Deparser improvements:
- Add support for deparsing
JSON_TABLE,JSON_QUERY,JSON_EXISTS,JSON_VALUE - Add support for deparsing
JSON,JSON_SCALAR,JSON_SERIALIZE - Add support for deparsing
COPY ... FORCE_NULL(*) - Add support for deparsing
ALTER COLUMN ... SET EXPRESSION AS - Add support for deparsing
SET STATISTICS DEFAULT - Add support for deparsing
SET ACCESS METHOD DEFAULT - Add support for deparsing
... AT LOCAL - Add support for deparsing
merge_action() - Add support for deparsing
MERGE ... RETURNING - Add support for deparsing
NOT MATCHED [ BY TARGET ]
- Add support for deparsing
- Add function
TestNormalizeUtilityto normalize only utility statements (#116)
- Update to libpg_query 16-5.1.0
- Add support for running on Windows
- Add support for compiling on 32-bit systems
- Upgrade to libpg_query 16-5.0.0
- Updates to the Postgres 16 parser
- Multiple deparser improvements
- Allow importing parse tree proto with cgo disabled
- Add parser.SplitWithScanner() and parser.SplitWithParser()
- Update to libpg_query 15-4.2.3, including changes from 15-4.2.2
- Fix builds when compiling with
glibc >= 2.38#203 - Deparser: Add support for COALESCE and other expressions in LIMIT clause #199
- Deparser: Add support for multi-statement CREATE PROCEDURE definitions #197
- Deparser: Correctly quote identifier in ALTER TABLE ... ADD CONSTRAINT [x] #196
- Deparser: Add support for index fillfactor within CREATE TABLE, fix SHOW ALL #193
- Deparser: Move to dedicated file for easier inclusion in third-party projects #192
- Fix builds when compiling with
- Update to libpg_query 15-4.2.1 (#85)
- Suppress -Wdeprecated-non-prototype warnings (#83 and #84)
- Return full structured error info instead of just error message (#76)
- Update to libpg_query 15-4.2.0
- Update to PostgreSQL 15.1
- Update to libpg_query 13-2.2.0 (#64)
- Fingerprinting version 3.1
- Fixes issue with "SELECT DISTINCT" having the same fingerprint as "SELECT" (fingerprints for "SELECT DISTINCT" will change with this revision)
- Group additional DDL statements together that otherwise generate a lot of unique fingerprints (ListenStmt, UnlistenStmt, NotifyStmt, CreateFunctionStmt, FunctionParameter and DoStmt)
- Update to Postgres 13.8 patch release
- Backport Xcode 14.1 build fix from upcoming 13.9 release
- Normalize additional DDL statements
- Fingerprinting version 3.1
- Update libpg_query to 13-2.1.2 (#58)
- Update libpg_query to 13-2.1.0 (#53)
- Normalize: add funcname error object
- Normalize: Match GROUP BY against target list and re-use param refs
- PL/pgSQL: Setup namespace items for parameters, support RECORD types
- This significantly improves parsing for PL/pgSQL functions, to the extent that most functions should now parse successfully
- Update libpg_query to 13-2.0.7 (#49)
- Normalize: Don't modify constants in TypeName typmods/arrayBounds fields
- Don't fail builds on systems that have strchrnul support (FreeBSD)
- Update libpg_query to 13-2.0.6 (#47)
- Normalize: Don't touch "ORDER BY 1" expressions, keep original text
- Update libpg_query to 13-2.0.5 (#45)
- Update to Postgres 13.3 patch release
- Normalize: Don't touch "GROUP BY 1" type statements, keep original text
- Fingerprint: Cache list item hashes to fingerprint complex queries faster
- Deparser: Emit the RangeVar catalogname if present
- Fix crash in pg_scan function when encountering backslash escapes
- Add pg_query.Scan to access Postgres scanner (#43)
- Update to libpg_query 13-2.0.3
- Normalize: Fix handling of two subsequent DefElem elements
- Parser CFLAGS: Build with -std=gnu99 to ensure CentOS compatibility
- Update to libpg_query 13-2.0.2
- Fix ARM builds: Avoid dependency on cpuid.h header
- Simplify deparser of TableLikeClause
- Fix asprintf warnings by ensuring _GNU_SOURCE is set early enough
- Add FingerprintToUInt64 method for callers that prefer to handle uint64s
- This prevents a caller from having to do a hex string to uint64 conversion by simply returning the uint64 version of the fingerprint instead, which is already always provided by libpg_query.
- Add HashXXH3_64 helper method for generating XXH3 64-bit hash values
- This can be useful when trying to fit other values into a data structure sized for the fingerprint, such as when encountering a parsing error during fingerprinting, and wanting to encode that fact uniquely into the fingerprint value.
- Update libpg_query to 13-2.0.0
- Switch to use Protobuf generated nodes instead of custom logic
- WARNING: This is breaking API change!
- This is a breaking change in the API, but necessary in order to significantly improve the performance of parsing a query into Go structs, as well as allowing future bi-directional passing of parse trees between Go and C, such as for a future addition of a deparser.
- Rename pg_query.FastFingerprint to pg_query.Fingerprint
- WARNING: This is breaking API change!
- We no longer have direct support for running the fingerprint in the Go library, as its unnecessarily complex to support, and we can instead rely on the C fingerprinting method.
- Add support for deparsing parse trees back into a SQL statement
- Call the new
pg_query.Deparsemethod to get back the SQL text for a particular parse tree structure - This relies on the new deparser in libpg_query to transform a given parse tree back into a SQL statement. Note that this is currently considered experimental, and should not be used on unsanitized input, due to the risk of crashes in the C code with unexpected conditions.
- Call the new
- Update import path to
github.com/pganalyze/pg_query_go
- Update libpg_query to 10-1.0.5
- This resolves memory leak problems, adds PPC architecture support, and refreshes the Postgres minor version to 10.16.
- Update libpg_query to 10-1.0.3
- This fixes ARM builds, and refreshes the Postgres patch version. This commit does not change the Postgres major version yet (still at PG 10).
- Initial release with a tagged version
- Note that 1.X releases will reflect Postgres 10 parser based releases from now on. When the Postgres 11 parser is released, that will be a new major version.