Skip to main content

Module ast

Module ast 

Source
Expand description

AST for the PG-dialect subset SPG accepts in v0.2.

Display is implemented so that for any AST a produced by crate::parser, re-parsing format!("{a}") yields a structurally equal AST. Binary and unary operators always emit parentheses to remove any precedence ambiguity — round-trip safety wins over prettiness.

Structs§

AlterIndexStatement
AlterTableStatement
v6.7.2 — ALTER TABLE t SET <setting> = <value>. v6.7.2 ships the single hot_tier_bytes setting; later v6.7.x sub-versions can add more SET subjects without changing the dispatch shape.
ColumnDef
ColumnName
CreateFunctionStatement
v7.12.4 — CREATE [OR REPLACE] FUNCTION. v7.12.4 ships RETURNS TRIGGER LANGUAGE plpgsql as the primary use case (the row-level trigger body the CREATE TRIGGER below references). Non-trigger user-defined functions parse but error at execution time with a clear unsupported message; that surface lands in v7.12.5+.
CreateIndexStatement
CreatePublicationStatement
v6.1.2 — CREATE PUBLICATION AST node. The scope field uses the PublicationScope shape. v6.1.2 only accepted AllTables; v6.1.3 unlocks the ForTables / AllTablesExcept variants by flipping the parser gate (no AST migration).
CreateSubscriptionStatement
v6.1.4 — CREATE SUBSCRIPTION AST node. v6.1.4 ships a single fixed-shape DDL; the WITH-clause options PG supports (enabled, slot_name, streaming, binary) are out of scope for v6.1.4 — enabled defaults to true and there are no other knobs to set in v6.1.x.
CreateTableStatement
CreateTriggerStatement
v7.12.4 — CREATE [OR REPLACE] TRIGGER. Always row-level (FOR EACH ROW) in v7.12.4 — statement-level triggers parse but the executor refuses them. WHEN (cond) clauses are out of scope; the trigger function can short-circuit on a leading IF inside its body once v7.12.5 lands IF.
CreateUserStatement
Cte
DeleteStatement
DELETE FROM <table> [WHERE cond]. v4.4 — removes matched rows from the active catalog and prunes them from every index.
ExplainStatement
ForeignKeyConstraint
v7.6.0 — A single FOREIGN KEY constraint. Both column-level REFERENCES and table-level FOREIGN KEY (...) REFERENCES ... parse into this shape — the column-level form has a single-entry columns / parent_columns.
FromClause
FROM clause shape. v1.10 accepts a primary table plus a flat list of joined peers — FROM a [, b]* [INNER|LEFT] JOIN c ON expr .... The joins evaluate left-associatively in nested-loop order.
FromJoin
FunctionArg
v7.12.4 — one positional argument to a CREATE FUNCTION.
InsertStatement
OnConflictClause
v7.9.7 — INSERT upsert clause: ON CONFLICT (target) DO action.
OrderBy
PlPgSqlBlock
v7.12.4 — PL/pgSQL BEGIN ... END; block. v7.12.6 widens from assignment + return to a real-PL/pgSQL surface: DECLARE-block local variables, IF/ELSIF/ELSE/END IF control flow, RAISE diagnostics, and embedded SQL statements that execute through the regular engine path. The remaining v7.12.x carve-out is loops (LOOP/WHILE/FOR), which mailrs’s trigger doesn’t need but other PG customers may; deferred to a future minor release.
PlPgSqlDeclare
v7.12.6 — single DECLARE entry: variable name + declared type + optional initialiser. Variables default to SQL NULL when no init is given (matches PG).
SelectStatement
TableRef
UpdateStatement
UPDATE <table> SET col = expr [, ...] [WHERE cond]. v4.4 — the engine evaluates expr per matched row in the table’s row order and rewrites cells in place. Indexed columns are dropped + re- inserted into the affected B-tree on each row change.
WindowFrame
v4.20 explicit window frame: ROWS|RANGE BETWEEN <bound> AND <bound>. end is None for the shorthand “ROWS ” where end implicitly = CURRENT ROW.

Enums§

AlterIndexTarget
AlterTableTarget
AssignTarget
BinOp
CastTarget
ColumnTypeName
SQL-level type names. The mapping to the storage runtime’s DataType happens in spg-engine — keeping spg-sql free of storage deps.
Expr
ExtractField
FkAction
v7.6.0 — Referential action for ON DELETE / ON UPDATE.
FrameBound
FrameKind
FunctionArgMode
FunctionArgType
FunctionBody
FunctionReturn
IndexMethod
JoinKind
LimitExpr
v7.9.24 — LIMIT / OFFSET value. Integer literal at parse time or a placeholder $N resolved during extended-query Bind. mailrs migration follow-up H2.
Literal
NullTreatment
v6.4.2 — null treatment on LAG / LEAD / FIRST_VALUE / LAST_VALUE. PG / ANSI default is Respect — NULLs participate in the offset walk. Ignore causes the function to skip NULL values in the argument expression, returning the next non-NULL.
OnConflictAction
v7.9.7 — action on conflict.
PlPgSqlStmt
PublicationScope
v6.1.2 — Which tables a publication covers. v6.1.3 (this commit) flips the parser gate for the ForTables / AllTablesExcept variants — the on-disk shape, snapshot serialisation, and the AST round-trip Display path were already in place in v6.1.2 so this is a parser-only widening.
RaiseLevel
ReturnTarget
SelectItem
SetValue
v7.12.1 — payload of a SET right-hand side. PG syntax accepts a string literal, an identifier (often a config name), an integer/float, or the bare DEFAULT keyword.
Statement
TableConstraint
v7.9.18 — table-level constraint at the end of a CREATE TABLE column list. Either a composite PRIMARY KEY or a UNIQUE (single- or multi-column).
TriggerEvent
TriggerForEach
TriggerTiming
UnOp
UnionKind
VecEncoding
In-cell encoding for a VECTOR(N) column. v6.0.1 added the optional USING <encoding> clause; omitting it keeps the pre-v6 F32 default. Sq8 quantises each cell to a per-vector affine (min, max, [u8; dim]) triple (4× compression). F16 (v6.0.3, DDL keyword HALF) stores each element as IEEE-754 binary16 (2× compression, ~3 decimal digits of precision).