1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
//! Rust pg_query   [![Build Status]][actions] [![Latest Version]][crates.io] [![Docs Badge]][docs]
//! ===========
//!
//! [Build Status]: https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fpganalyze%2Fpg_query.rs%2Fbadge%3Fref%3Dmain&style=flat&label=build&logo=none
//! [actions]: https://actions-badge.atrox.dev/pganalyze/pg_query.rs/goto?ref=main
//! [Latest Version]: https://img.shields.io/crates/v/pg_query.svg
//! [crates.io]: https://crates.io/crates/pg_query
//! [Docs Badge]: https://docs.rs/pg_query/badge.svg
//! [docs]: https://docs.rs/pg_query
//!
//! 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](https://github.com/pganalyze/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](https://pganalyze.com/blog/parse-postgresql-queries-in-ruby.html). The Rust version tries to have a very similar API.
//!
//! ## Getting started
//!
//! Add the following to your `Cargo.toml`
//!
//! ```toml
//! [dependencies]
//! pg_query = "6.1"
//! ```
//!
//! # Example: Parsing a query
//!
//! ```rust
//! use pg_query::NodeRef;
//!
//! let result = pg_query::parse("SELECT * FROM contacts");
//! assert!(result.is_ok());
//! let result = result.unwrap();
//! assert_eq!(result.tables(), vec!["contacts"]);
//! assert!(matches!(result.protobuf.nodes()[0].0, NodeRef::SelectStmt(_)));
//! ```
//!
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use Node;
// From Postgres source: src/include/storage/lockdefs.h
// From Postgres source: src/include/catalog/pg_trigger.h