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
//! SPG SQL front-end. v0.2 ships only the lexer + a minimal recursive-descent
//! parser for the `SELECT [..] FROM [..] WHERE [..]` subset.
//!
//! Layers (each in its own module):
//!
//! - [`lexer`] — byte stream → tokens
//! - [`ast`] — abstract syntax tree types + `Display` (pretty-print)
//! - [`parser`] — tokens → AST (Pratt parser for expression precedence)
extern crate alloc;
/// v7.12.4 — convenience re-export of the PL/pgSQL body parser.
/// Used by the engine-side trigger executor to lazy-re-parse the
/// function body that the catalog stores as raw source text.
pub use parse_function_body;
/// v7.37.14 (A2.5-stub) — process-wide counter of silent
/// FOR UPDATE / FOR SHARE / FOR KEY SHARE / FOR NO KEY UPDATE
/// clauses the parser accepted-and-discarded.
///
/// Pre-v7.37.15 the parser silently absorbs row-lock clauses so
/// mailrs / Rails / Django code paths that emit `SELECT … FOR
/// UPDATE` for advisory pessimistic locking load without a parser
/// error. The clauses are not enforced — SPG is currently single-
/// writer + Arc snapshot,which already satisfies the implicit
/// ordering most callers want.
///
/// v7.37.15 (B2.5 / fine-grained MVCC) will land per-row tuple
/// locking and start honouring these clauses. Until then, this
/// counter is the *observability hook* so operators can surface
/// "FOR UPDATE is widely used in this workload — once 7.37.15
/// ships, ensure the application semantics are still correct".
///
/// Bumped once per FOR clause consumed (so `FOR UPDATE OF t1 FOR
/// SHARE OF t2` increments by 2). Reads via [`silent_for_update_count`].
static SILENT_FOR_UPDATE_COUNT: AtomicU64 =
new;
/// v7.37.14 (A2.5-stub) — bump the silent-FOR-UPDATE counter.
/// Called from the parser's `consume_optional_for_lock_clauses`
/// path. Public-but-low-traffic API; not part of the stable parser
/// surface.
/// v7.37.14 (A2.5-stub) — read the process-wide silent-FOR-UPDATE
/// counter. Engines / spgctl / monitoring use this to surface
/// "how many advisory row locks did the workload ask for since
/// process start". Returns 0 if no FOR UPDATE / FOR SHARE clause
/// has hit the parser yet.