libpg_query

C library for accessing the PostgreSQL parser outside of the server environment

BSD-3-CLAUSE License

Stars
1.2K
Committers
36

Bot releases are hidden (Show)

libpg_query - Latest Release

Published by lfittl 9 months ago

  • Add support for compiling on Windows
    • In order to build on Windows when using MSVC, use the new "Makefile.msvc"
      with nmake, or directly compile all .c files in the src folder into a library
    • If compiling directly, add src/postgres/include/port/win32 to the include path,
      and when using MSVC also add src/postgres/include/port/win32_msvc
  • Add support for compiling on 32-bit systems
    • The relevant code is enabled at compile time by checking the pointer
      size (__SIZEOF_POINTER__ == 4)
  • Move internal headers and included .c files to src/include folder
    • This avoids having any .c files in the top-level src/ folder that can't
      be directly compiled, and thus lets us simplify the logic for defining
      which source units are to be compiled.
  • Remove strnlen fallback implementation
  • Avoid use of mmap, asprintf and strndup to improve portability
  • Improve compatibility with non-POSIX systems and C89 compilers
% shasum -a 256 libpg_query-16-5.1.0.*
31f25b573da1c966bc762b0313b0a50cdd03aabdbaf666d90469eddcb1656df7  libpg_query-16-5.1.0.tar.gz
35b73753428435e1da10a7a4fc6e61fcdf1819c9527ba5515f1035697c3e0ab7  libpg_query-16-5.1.0.zip
libpg_query - 16-5.0.0

Published by msepga 10 months ago

  • Update to Postgres 16.1 (#225, #229)
  • Drop support for arbitrary trailing junk on integer literals
    • Support for parsing junk after parameters, e.g. $1OR is retained
  • Deparser:
    • Fix deparsing of SYSTEM_USER
    • Add support for deparsing STORAGE mode
    • Add support for deparsing REVOKE ... CASCADE
    • Rework a_expr/b_expr/c_expr deparsing to match gram.y structure
    • Add support for deparsing COMPRESSION option for columns
    • Add support for deparsing NULLS NOT DISTINCT in unique constraints
    • Add support for deparsing new SQL/JSON functionality
❯ shasum -a 256 libpg_query-16-5.0.0.*
7cf26922cbc41668fa79332504f2d5638339baa9411912b8df4526ccd1d7029e  libpg_query-16-5.0.0.tar.gz
2a516f977904376ac4969472aa0106818cdca66401f326dead272228def218db  libpg_query-16-5.0.0.zip
libpg_query - 15-4.2.4

Published by msepga 10 months ago

  • Scanner: Add token ASCII_36 ("$") to support queries like "SELECT $identifier" #211, #219
    • Whilst these queries are not valid SQL and would fail parsing, this token can show up when using pg_query_scan or pg_query_split_with_scanner directly
  • Normalize: Fix incorrect type cast #223
  • Deparser:
    • Fix some BooleanTest cases #206
    • Fix ALTER TABLE ... ENABLE TRIGGER ALL #222
    • Add parens around type casts in IndexElem #214
    • Treat type casts in func_expr_windowless as functions #214
  • Support changing parse mode and config settings affecting the parser #216
    • Alternate parse modes are useful for parsing PL/pgSQL expressions, as well as type names
    • Additionally, you can now change config settings that affect parsing, like standard_conforming_strings
    • To pass options, use the new methods ending in _opts, e.g. pg_query_parse_opts
❯ shasum -a 256 libpg_query-15-4.2.4.*
d0ace0bff40e5daa99e32753a22a7558f9b2207e89260f00171fc50723b831dd  libpg_query-15-4.2.4.tar.gz
dcd43e04ac56db018b7553f0f0d3506be45dd993ae727f7c190a88589573807c  libpg_query-15-4.2.4.zip
libpg_query - 15-4.2.3

Published by msepga about 1 year ago

  • Fix builds when compiling with glibc >= 2.38 #203
  • Deparser: Add support for COALESCE and other expressions in LIMIT clause #199
❯ shasum -a 256 libpg_query-15-4.2.3.*
8b820d63442b1677ce4f0df2a95b3fafdbc520a82901def81217559ec4df9e6b  libpg_query-15-4.2.3.tar.gz
eab782a3fcc5a252044db92d315d54053ac3951e6f10ea849eb70837d26668d4  libpg_query-15-4.2.3.zip
libpg_query -

Published by lfittl over 1 year ago

  • Deparser:
    • Add support for multi-statement CREATE PROCEDURE definitions #197
    • Correctly quote identifier in ALTER TABLE ... ADD CONSTRAINT [x] #196
    • Add support for index fillfactor within CREATE TABLE, fix SHOW ALL #193
    • Move to dedicated file for easier inclusion in third-party projects #192
% shasum -a 256 libpg_query-15-4.2.2.*
03d6631b4a5ea9cc26cb2569e0303b9cce2bc1c6b6e1488f5ab9d63e6bd5346d  libpg_query-15-4.2.2.tar.gz
2d15b71c3808a3e1ea1e90ce86d4d83dc863bea32d5ad8a9eafcffe0d8197891  libpg_query-15-4.2.2.zip
libpg_query -

Published by lfittl over 1 year ago

  • Deparser: Handle INTERVAL correctly when used in SET statements #184
  • Deparser: Ensure index names are quoted as identifiers #182
  • Remove limits.h from pg_query_deparse.c #181
% shasum -a 256 libpg_query-15-4.2.1.*
5828124517d8fd3091336fad6897e16ab49ec0b0b188f5859b3b928fc91608c2  libpg_query-15-4.2.1.tar.gz
9dfd77102825f998a1a2ffa8c5f32aa896e97c4d92b92f5edb8ac89a8491e198  libpg_query-15-4.2.1.zip
libpg_query - 15-4.2.0

Published by msepga over 1 year ago

  • Update copyright notice years and authors #175
  • Allow trailing junk in numeric literals #177
    • Allows parsing queries like SELECT * FROM a WHERE b=$1ORc=$2
  • NetBSD support #172
❯ shasum -a 256 libpg_query-15-4.2.0.*
573b7b0d3b04702ec9e541e0a504632de17bd90b948c5658e72c1cf9dfc3a05d  libpg_query-15-4.2.0.tar.gz
c457406a0ae3faf85254c7fa34bb5f773630b2e71f67bd54946ceb7f33af0eaf  libpg_query-15-4.2.0.zip
libpg_query - 15-4.1.0

Published by msepga almost 2 years ago

  • Add Boolean fingerprinting
    • Boolean nodes are now output during fingerprinting
  • Fix parsing issue on 32-bit big endian machines
    • Now we use size_t to indicate the protobuf message size
❯ shasum -a 256 libpg_query-15-4.1.0.*
256fca8ebc64820cb9859cb891027b85fc45d2ccdcbdbc131097087abd733234  libpg_query-15-4.1.0.tar.gz
7f13c46cf458a1a741e803bc8a9fcc71a36058756dfbd312076b1397fd401c93  libpg_query-15-4.1.0.zip
libpg_query - 15-4.0.0

Published by msepga almost 2 years ago

  • Update to Postgres 15.1
  • Add support for MERGE statements
  • Add support for ALTER TABLE ALL IN TABLESPACE ... statements
  • Add support for publication objects
    • CREATE PUBLICATION foo FOR TABLES IN SCHEMA CURRENT_SCHEMA
  • Deparser now attempts to deparse COPY statements first using the old Postgres 8.4-style syntax (e.g. COPY foo FROM STDIN FREEZE CSV).
❯ shasum -a 256 libpg_query-15-4.0.0.*
1d8a9057b34faed5fa272c6fad8fc706d494b5a877cbe2b582f546660329883d  libpg_query-15-4.0.0.tar.gz
63f88c157db79a58e2b01b0adbd7eecf5181f84f8995a00de21d59d4359831a4  libpg_query-15-4.0.0.zip
libpg_query - 14-3.0.0

Published by msepga almost 2 years ago

Special thanks to @wolfgangwalther and @tlisanti for most of the work done on this release.

  • Update to Postgres 14.6
  • Drop support for ? parameter syntax
  • Update fingerprint.json to include newly added tests, regenerate tests
$ shasum -a 256 libpg_query-14-3.0.0.*
59c5cd6d41e36e3f5c9d1179b40190c5429045e211a29527e8500f93a9a75f78  libpg_query-14-3.0.0.tar.gz
dbc7f12526db9cd5f5e1f614992ad41aa93a57172e3d5fccd766fa79307fb0f5  libpg_query-14-3.0.0.zip
libpg_query -

Published by lfittl almost 2 years ago

  • Update to Postgres 13.8 patch release #156
  • Backport Xcode 14.1 build fix from upcoming 13.9 release #156
  • Fingerprinting version 3.1 #155
    • 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)
  • Normalize additional DDL statements #155
    • Normalizes arguments to CreateFunctionStmt, DoStmt,
      CreateSubscriptionStmt, AlterSubscriptionStmt, CreateUserMapping and
      AlterUserMapping.
    • Note that this is different from pg_stat_statements itself, which does
      not normalize utility statements at all today.
$ shasum -a 256 libpg_query-13-2.2.0.* 
07916be1a2b780dee6feed936aaa04ccee2a3afde8570a6920c3a839c87539c6  libpg_query-13-2.2.0.tar.gz
6aa05d5ca983be6e2c797bf53e629f33c7fc229e6afda496235e43efd6296232  libpg_query-13-2.2.0.zip
libpg_query -

Published by lfittl over 2 years ago

  • Add support for analyzing PL/pgSQL code inside DO blocks #142
  • Fix memory leak in pg_query_fingerprint error handling #141
$ shasum -a 256 libpg_query-13-2.1.2.*
101a7851ee065d824fe06e300b78355a79bd5411864de707761282a0c57a0a97  libpg_query-13-2.1.2.tar.gz
fe4462e3e8dc41f4c5610d3d2d2c821adccc9228f1c9ec5834277c5139e0d668  libpg_query-13-2.1.2.zip
libpg_query -

Published by lfittl over 2 years ago

  • PL/pgSQL parser
    • Add support for Assert #135
    • Add support for SET, COMMIT, ROLLBACK and CALL #130
  • Add support for parsing more operators that include a ? character (special cased to support old pg_stat_statements query texts)
    • ltree extension #136
    • promscale extension #133
  • Deparser improvements
    • Prefix errors with "deparse", and remove some asserts #131
    • Fix potential segfault when passing invalid protobuf (RawStmt without Stmt) #128
$ shasum -a 256 libpg_query-13-2.1.1.*
a9011e14868762bc894e5c02172efde4e70f4f868fbffcc490b15ca351f31b06  libpg_query-13-2.1.1.tar.gz
7e1b9d0b79b394e60dba0f8b87f7e4788dd945c15179c49b6207b3ee47ca943b  libpg_query-13-2.1.1.zip
libpg_query -

Published by lfittl about 3 years ago

  • Normalize: add funcname error object #121
  • Normalize: Match GROUP BY against target list and re-use param refs #124
  • PL/pgSQL: Setup namespace items for parameters, support RECORD types #123
    • This significantly improves parsing for PL/pgSQL functions, to the extent
      that most functions should now parse successfully
$ shasum -a 256 libpg_query-13-2.1.0.*
a01329ae5bac19b10b8ddf8012bd663a20f85f180d6d7b900c1a1ca8444d19a5  libpg_query-13-2.1.0.tar.gz
16e2804a5f1cbedec3ae74bef49c9b61d7728e61a1b472da41fac1e506785d73  libpg_query-13-2.1.0.zip
libpg_query -

Published by lfittl over 3 years ago

  • Normalize: Don't modify constants in TypeName typmods/arrayBounds fields (#118)
    • This matches how pg_stat_statement behaves, and avoids causing parsing
      errors on the normalized statement
  • Don't fail builds on systems that have strchrnul support (FreeBSD)
$ shasum -a 256 libpg_query-13-2.0.7.*
ea08b32619b37cb2beb2dd07e1121a4a1e7372d71d0edfa935e5a30ebc490821  libpg_query-13-2.0.7.tar.gz
4c82dfe22fa0bbfb3ddbafe14e363067223fa6ba460b9a5a43e78057778deaee  libpg_query-13-2.0.7.zip
libpg_query -

Published by lfittl over 3 years ago

  • Normalize: Don't touch "ORDER BY 1" expressions, keep original text #115
    • This avoids obscuring the semantic meaning of integers in the ORDER BY
      clause, which is to reference a particular column in the target list.
$ shasum -a 256 libpg_query-13-2.0.6.*
61f384ac949bd7404efe6bcc37a8a6fca79030e59c02659f108ee1db45e93414  libpg_query-13-2.0.6.tar.gz
d1d03d61c8251f5b8b7d81f60ba1141ff5efc577cd2a74d92ce894170a84dbd4  libpg_query-13-2.0.6.zip
libpg_query -

Published by lfittl over 3 years ago

  • Update to Postgres 13.3 patch release #114
  • Add optional Makefile target to build as shared library #100
  • Normalize: Don't touch "GROUP BY 1" type statements, keep original text #113
    • This avoids obscuring the semantic meaning of integers in the GROUP BY
      clause, which is to reference a particular column in the target list.
  • Fingerprint: Cache list item hashes to fingerprint complex queries faster #112
    • This was exhibiting quite bad runtime behaviour before, causing both an
      explosion in memory, as well as very high CPU runtime for complex queries.
    • The new approach ensures we don't calculate the hashes for a particular
      list more than once, which ensures that we roughly have quadratic runtime
      instead of exponential runtime.
  • Deparser: Emit the RangeVar catalogname if present #105
  • Fix crash in pg_scan function when encountering backslash escapes #109
  • Integrate oss-fuzz fuzzer #106
$ shasum -a 256 libpg_query-13-2.0.5.*
65e99d0a813666a365612bada17430bbc40b01a1aacf2836309f9de0570bb52d  libpg_query-13-2.0.5.tar.gz
7883440bb891e7f2cf04b7cf25585994575d1c025db6b6adae72cb68a7dc2cd0  libpg_query-13-2.0.5.zip
libpg_query -

Published by lfittl over 3 years ago

  • Deparser: Fix crash in CopyStmt with HEADER or FREEZE inside WITH parens
    • The parse tree does not contain an explicit argument in those cases,
      but does when specified in the legacy mode without the wrapping WITH.
    • With this change we only output the "1" argument when the original tree
      also had this, to ensure parse tree comparisons match. Note the intent
      here is technically the same, which is to enable these options.
$ shasum -a 256 libpg_query-13-2.0.4.*
a67ef3e3b6c9cb1297f362888d6660dac165d3b020f78d23afe4293b8ceaf190  libpg_query-13-2.0.4.tar.gz
783b72123f23538db5cf45ab979284025dbdffbac60304602a0c124e4dba53ed  libpg_query-13-2.0.4.zip
libpg_query -

Published by lfittl over 3 years ago

  • Normalize: Fix handling of two subsequent DefElem elements #96
    • We were incorrectly adding too many DefElem locations to the recorded
      constant values, causing a crash when more than a single DefElem
      is present in a utility statement.
$ shasum -a 256 libpg_query-13-2.0.3.*
7f2b74e1fcc7322e7565fd7465d85db3fb453e9cb7f2edba7e5ea7ab63d27dfe  libpg_query-13-2.0.3.tar.gz
49fe7bbc0c727ff7b2e0ac2aecaf2863a1ca61543701986a71d7a0c24daf825b  libpg_query-13-2.0.3.zip
libpg_query -

Published by lfittl over 3 years ago

  • srcdata/nodetypes.json: Avoid bogus values accidentally parsed from inside comments
$ shasum -a 256 libpg_query-13-2.0.2.*
fe485f48bb51dcc5ed146b1c9929da417357ae8844c2f0c8fe1e235fa1d14257  libpg_query-13-2.0.2.tar.gz
160b3bf55e94a3bb06825fdd20019e53d21380824f13ca9f7b97adf842b0978e  libpg_query-13-2.0.2.zip
Package Rankings
Top 8.82% on Alpine-edge
Top 10.36% on Alpine-v3.16
Top 4.48% on Alpine-v3.18
Top 8.54% on Alpine-v3.14
Top 9.71% on Alpine-v3.15
Top 11.18% on Alpine-v3.17