Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
pg_query.rs

This Rust library uses the actual PostgreSQL server source to parse SQL queries and return the internal PostgreSQL parse tree.
It also allows you to normalize queries (replacing constant values with $1, etc.) and parse these normalized queries into a parse tree again.
When you build this library, it builds parts of the PostgreSQL server source (see libpg_query), and then statically links it into this library.
You can find further examples and a longer rationale for the original Ruby implementation here. The Rust version tries to have a very similar API.
Getting started
Add the following to your Cargo.toml
[]
= "5.1"
Examples
Parsing a query
use NodeRef;
let result = parse;
assert!;
let result = result.unwrap;
assert_eq!;
assert!;
Normalizing a query
let result = normalize.unwrap;
assert_eq!;
Fingerprinting a query
let result = fingerprint.unwrap;
assert_eq!;
Truncating a query
let query = "INSERT INTO \"x\" (a, b, c, d, e, f) VALUES (?)";
let result = parse.unwrap;
assert_eq!;
Credits
Thanks to Paul Mason for his work on pg_parse that this crate is based on.
After version 0.6.0, Paul donated the pg_query crate to the pganalyze team. pg_parse is a lighter alternative that focuses on query parsing, while pg_query aims for feature parity with the Ruby gem.
License
PostgreSQL server source code, used under the PostgreSQL license. Portions Copyright (c) 1996-2023, The PostgreSQL Global Development Group Portions Copyright (c) 1994, The Regents of the University of California
All other parts are licensed under the MIT license, see LICENSE file for details. Copyright (c) 2021 Paul Mason paul@form1.co.nz Copyright (c) 2021-2023, Duboce Labs, Inc. (pganalyze) team@pganalyze.com