Hacker GitHub

← All repos

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

Mentions per year 24 mentions · busiest year 2023 (11)
20082026
  1. …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
  2. …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
  3. 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
  4. 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
  5. …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
  6. …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 -…
  7. 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
  8. …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.…
  9. …which this project would not be possible! [0] https://news.ycombinator.com/item?id=37020610 [1] https://github.com/pganalyze/libpg_query
  10. …(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
  11. …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
  12. …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 +…
  13. …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
  14. …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
  15. 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
  16. 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
  17. 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
  18. …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…
  19. …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
  20. …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?
  21. …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…
  22. 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 -…