pganalyze/libpg_query
View on GitHub ↗ ★ 1,494 C
C library for accessing the PostgreSQL parser outside of the server environment
24 mentions on Hacker News by 17 people: 2 stories, 22 comments · first 2017-07-24 · latest 2026-09-18
20082026
-
▲ 4
Show HN: pg_raw_parse - parse PgSQL in Ruststory by levkk · 2026-09-18 · 0 comments
-
…because in non-performance critical cases, it is more ergonomic across the different bindings. [0]: https://github.com/pganalyze/libpg_query/pull/321
comment by lfittl · 2026-01-23 · in Replacing Protobuf with Rust -
…would have to either also be moved out of the backend source, or use some other abstraction). [0]: https://github.com/pganalyze/libpg_query/tree/17-latest/patc... [1]: https://github.com/pganalyze/libpg_query/blob/17-latest/scri...
comment by lfittl · 2025-04-15 · in Hacking the Postgres wire protocol -
Yes, the same way. It's all based on the extremely useful ` https://github.com/pganalyze/libpg_query ` project, which is where the "extracted the parser from Postgres" part comes in. Supabase's LSP also uses tree-sitter for corrections and…
comment by bri3d · 2025-04-15 · in Hacking the Postgres wire protocol -
Tends to be a matter of opinion. Postgres does not expose the relevant functions, so https://github.com/pganalyze/libpg_query has to do some heavy lifting to convert their source code into a nice library. Conversely, Postgres is very well…
comment by ZiiS · 2025-04-15 · in Hacking the Postgres wire protocol -
…underlying C implementation having several wrappers that exist for a number of languages[1]. [1] https://github.com/pganalyze/libpg_query/blob/15-latest/READ...
comment by craigkerstiens · 2025-04-15 · in Hacking the Postgres wire protocol -
…a good library! "C library for accessing the PostgreSQL parser outside of the server environment" https://github.com/pganalyze/libpg_query?tab=readme-ov-file#... pg_query wrappers in other languages: - Ruby: pg_query - Go: pg_query_go -…
comment by pella · 2024-09-23 · in Show HN: Parse your Postgres queries into a fully-typed AST in TypeScript -
This in combination with [pg_query]( https://github.com/pganalyze/libpg_query ) could allow for writing generic static analyzers.
comment by amw-zero · 2024-03-18 · in Transpile Any SQL to PostgreSQL Dialect -
…that file is safe to run per your company policy — or with some other exit code if it's not. (Use https://github.com/pganalyze/libpg_query , or one of its HLL bindings. I'd probably recommend the Golang one for simplest deployment.) 5.…
comment by derefr · 2023-12-16 · in Show HN: I've built a MySQL proxy that supports online DDL -
…which this project would not be possible! [0] https://news.ycombinator.com/item?id=37020610 [1] https://github.com/pganalyze/libpg_query
comment by steinroe · 2023-12-08 · in Postgres Language Server: Implementing the Parser -
…(i.e. raw parser + AST structs). Hopefully something we can spend a bit of time on next year. [0]: https://github.com/pganalyze/libpg_query
comment by lfittl · 2023-11-18 · in An automatic indexing system for Postgres -
…the pganalyze team has actually extracted out the parser of PG for including in your own projects: https://github.com/pganalyze/libpg_query
comment by gavinray · 2023-10-10 · in Postgres: The next generation -
…and/or causally ordered event logs. yjs also does CRDTs (Jupyter RTC,) #. pganalyze/libpg_query: https://github.com/pganalyze/libpg_query : > C library for accessing the PostgreSQL parser outside of the server environment #. Ibis +…
comment by westurner · 2023-08-09 · in SQLedge: Replicate Postgres to SQLite on the Edge -
…You can see how many files we pull in from the main tree that are prefixed with "src_backend": https://github.com/pganalyze/libpg_query/tree/15-latest/src/... Further, there isn't a canonical way to output node trees into a text format…
comment by lfittl · 2023-08-06 · in Postgres Language Server -
…various projects using it (e.g. sqlc uses it for a type-safe way for using hand-written SQL in Go): https://github.com/pganalyze/libpg_query#resources
comment by lfittl · 2023-08-06 · in Postgres Language Server -
Can't you just give some love to the issue https://github.com/pganalyze/libpg_query/issues/44 instead ? As I said before this would be very helpful for the community because there are a lot of libraries that use libpg_query and cannot be…
comment by spapas82 · 2023-08-06 · in Postgres Language Server -
The libpg query library has a very important problem: It does not work on windows https://github.com/pganalyze/libpg_query/issues/44 I'd recommend starting with fixing that instead. It would be much more helpful for the community.
comment by spapas82 · 2023-08-06 · in Postgres Language Server -
it leverages your code-base, rather than connecting to your database. it uses to libpg_query ( https://github.com/pganalyze/libpg_query ) to construct the syntax tree which can then be used to for the LSP features
comment by kiwicopple · 2023-08-06 · in Postgres Language Server -
…pg_query together with my colleagues at pganalyze, which packages the Postgres parser as a library: https://github.com/pganalyze/libpg_query Might be useful to include in your product as a way to run a quick syntax check on the query…
comment by lfittl · 2023-06-14 · in Show HN: pgMagic – a Mac Postgres client that lets you query in natural language -
…databases! 2. any valid SQL to novel syntax; a bit harder, but I'd start by using a SQL parser like https://github.com/pganalyze/libpg_query and translating the resulting AST into the novel syntax. 3. novel syntax to SQL back to novel…
comment by jcdreads · 2022-01-24 · in PRQL – A proposal for a better SQL -
…feel comfortable. A few words about open source. At first, I used this AST parser for PostgreSQL https://github.com/lfittl/libpg_query But it's frozen on Postgresql 10. And we don't know if there'll be any updates. No official AST parser…
comment by antonrevyako · 2020-03-22 · in Ask HN: What projects are you working on now? -
▲ 1
Libpg_query: C library for accessing the PostgreSQL parser outside of the serverstory by merqurio · 2019-01-18 · 0 comments
-
…e.g. in some custom tooling to analyze SQL queries, I extracted it into a library some time ago: https://github.com/lfittl/libpg_query Your comment still applies though, as a lot of the parser output is very specific to the chosen Postgres…
comment by lfittl · 2018-03-01 · in Queryparser, an Open Source Tool for Parsing and Analyzing SQL -
The PostgreSQL parser is available as a C library. C - https://github.com/lfittl/libpg_query Ruby - https://github.com/lfittl/pg_query Go - https://github.com/lfittl/pg_query_go Node - https://github.com/zhm/pg-query-parser Python -…
comment by j_s · 2017-07-24 · in Pev: Postgres ‘Explain’ Visualizer (2016)