Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ElectricSQL logo

License - Apache 2.0

PgQuery

An Elixir interface to the lib_pg_query postgres query parser.

{:ok, ast} = PgQuery.parse("select * from a_table")

Installation

The package can be installed by adding pg_query_ex to your list of dependencies in mix.exs:

def deps do
  [
    {:pg_query_ex, "~> 0.10"}
  ]
end

Fuzzing

The fuzz/ directory contains libFuzzer harnesses that exercise the NIF boundary. You need clang with libFuzzer support (standard in most LLVM distributions).

Build all four targets:

make fuzz

Optionally seed the deparse corpus from known-good SQL strings:

make fuzz-corpus

Then run a target, for example:

# Fuzz the parse → deparse round-trip (highest-value target)
fuzz/_build/fuzz_roundtrip -max_len=4096 -artifact_prefix=fuzz/crashes/ fuzz/corpus/parse/

# Fuzz raw protobuf bytes fed directly into the deparser
fuzz/_build/fuzz_deparse -max_len=65536 -artifact_prefix=fuzz/crashes/ fuzz/corpus/deparse/

# Fuzz the SQL parser
fuzz/_build/fuzz_parse_protobuf -max_len=4096 -artifact_prefix=fuzz/crashes/ fuzz/corpus/parse/

# Fuzz the SQL scanner
fuzz/_build/fuzz_scan -max_len=4096 -artifact_prefix=fuzz/crashes/ fuzz/corpus/parse/

Crash artifacts are written to fuzz/crashes/ (the -artifact_prefix flag controls this; without it libFuzzer writes to the current directory). Replay a crash by passing the file as a positional argument:

fuzz/_build/fuzz_roundtrip fuzz/crashes/<file>

Clean up build artefacts and generated corpus with make fuzz-clean.

License

This Elixir interface is distributed under the terms of the Apache 2.0 license.

The codebase also contains a git-subtree snapshot of lib_pg_query which is distributed under the BSD 3-Clause license.

Contributing

See the Community Guidelines including the Guide to Contributing and Contributor License Agreement.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages