Skip to main content

Module ast

Module ast 

Source
Expand description

Internal SQL AST. Lifts the relevant subset of the libpg_query protobuf tree into a Rust enum the compiler walks. Statements not yet supported parse cleanly but compile to crate::SQLError::Unsupported.

Modules§

routine_estimate
Serde for a COST or ROWS estimate, a float4 that overflows to infinity and that the JSON catalog cannot hold as a number: a finite estimate is a number, and an infinite one the text PostgreSQL prints for it.

Structs§

AlterDomain
AlterEnum
ALTER TYPE name ADD VALUE ... or ALTER TYPE name RENAME VALUE ....
AlterForeignTableStmt
AlterRoleStmt
AlterRoutineOwnerStmt
AlterRoutineStmt
ALTER FUNCTION | PROCEDURE | ROUTINE name[(input_types)] ... with an optional exact declared input identity.
AlterSequence
AlterTableStmt
AlterTypeObject
One ALTER TYPE or ALTER DOMAIN lifecycle change of a user-defined type and its generated array type.
AlterViewStmt
AssignmentTarget
Target syntax is separate from the value expression. Every bound belongs to the original input row, even when repeated targets compose writes to one column.
AutoIncrement
Durable sequence provenance for a SERIAL or identity column.
AutoIncrementOwner
Durable owner of an implicit sequence. Inherited SERIAL defaults and declarative partitions copy this owner unchanged, so truncating a child cannot reset a sequence owned by its parent.
CTE
ColumnClause
One clause of a column definition.
ColumnDeclaration
The clauses a column definition writes, in written order, which transformColumnDefinition checks against each other.
ColumnDef
CompositeAttributeAddition
One ADD ATTRIBUTE declaration. Unlike CREATE TYPE, ALTER applies column declaration lowering, including SERIAL.
CompositeAttributeDefinition
One declared attribute. The type is a declaration until execution binds it through the catalog.
CompositeRowBinding
Creation-time positional binding of a stored ROW constructor. Type references use the same canonical-name lifecycle as stored casts; attribute numbers survive additions and dropped slots.
CompositeTypeReference
A composite type bound by catalog identity: a standalone composite type or the row type of a relation. The schema and name are the catalog’s current names; equality compares the type identity only.
ConstraintCatalogIdentity
CreateCompositeType
CREATE TYPE name AS (attribute type [COLLATE collation], ...) with attributes in declaration order.
CreateDomain
CreateEnum
CREATE TYPE name AS ENUM (...) with labels in declaration order.
CreateForeignServer
CreateForeignTable
CreateForeignWrapper
CreateFunction
CREATE [OR REPLACE] FUNCTION | PROCEDURE.
CreateIndex
CreateRoleStmt
CreateRule
CreateSequence
CreateTable
CreateTrigger
CteCycleClause
PostgreSQL recursive-CTE cycle detection metadata.
CteSearchClause
PostgreSQL recursive-CTE traversal-order metadata.
DeclareCursorStmt
DeferredCreateForeignTable
A syntactically valid CREATE FOREIGN TABLE whose definition is analyzed after its creation namespace, skipping an existing target only when requested.
DeferredCreateTable
A syntactically valid CREATE TABLE IF NOT EXISTS whose definition must be analyzed only after execution has established that the target relation does not already exist.
DeferredSQLError
An error a statement found while compiling, which it raises later, where PostgreSQL raises it.
DeleteStmt
DetachedPartitionConstraint
DomainCheck
DomainNotNull
DropColumnAction
DropFunctionItem
One DROP FUNCTION / DROP PROCEDURE target.
DropFunctionStmt
DROP FUNCTION [IF EXISTS] name[(argtypes)] [, ...] and the DROP PROCEDURE equivalent.
DropRoleStmt
DropRule
DropStmt
DropTrigger
EnumNeighbor
The existing label that a new label is placed before or after.
EnumTypeReference
A user-defined enum type bound by catalog identity. The schema and name are the catalog’s current names; equality compares the type identity only.
FetchCursorStmt
ForeignKey
Table-level foreign key. Compilation preserves an omitted referenced column list as empty; validation fills it from the primary key before publication.
ForeignKeyRef
REFERENCES table[(column)] reference target.
FunctionBinding
FunctionParam
One declared parameter of a user-defined function or procedure.
GeneratedColumn
GrantDatabaseStmt
GRANT or REVOKE of CONNECT, CREATE, and TEMPORARY on databases.
GrantRoleStmt
GRANT role TO member or REVOKE role FROM member.
GrantRoutineItem
GrantRoutineStmt
GrantSchemaStmt
GRANT or REVOKE of USAGE and CREATE on schemas.
GrantSequenceStmt
GRANT or REVOKE of USAGE, SELECT, and UPDATE on sequences.
GrantTableStmt
GRANT or REVOKE of privileges on ordinary tables. An empty privilege list records ALL PRIVILEGES so explicit sequence targets can expand against their own privilege set.
GrantTypeStmt
GRANT | REVOKE [GRANT OPTION FOR] privileges ON TYPE | DOMAIN names TO | FROM grantees [WITH GRANT OPTION] [GRANTED BY role] [CASCADE | RESTRICT]. An empty privilege list is ALL [PRIVILEGES].
IdentitySequenceDeclaration
The sequence options an identity column declaration writes, GENERATED ... AS IDENTITY (options). They create the column’s sequence, which keeps them; the column does not.
IdentitySequenceName
The name SEQUENCE NAME gives an identity sequence: its schema, when written, and its name.
IndexColumnOrder
InsertStmt
JoinUsing
LockTableStmt
LockTableTarget
LockingClause
One PostgreSQL row-locking clause, including optional OF targets and the NOWAIT / SKIP LOCKED wait policy.
MergeStmt
MergeTargetColumnBinding
NotNullDeclaration
A NOT NULL constraint a CREATE TABLE statement declares or implies, which AddRelationNotNullConstraints resolves against the relation’s columns once they exist.
ObjectAclEntry
One explicit ACL entry. An absent ACL keeps the object’s PostgreSQL default: the privilege for PUBLIC and the owner.
OnConflict
OperatorJoinRelations
The two independently bound catalog relations consumed by an operator-join table function.
OperatorResolutionError
OrderBy
PartitionIdentityOverride
PartitionSpec
Projection
ReferencedPartitionConstraint
The constraint PostgreSQL derives from a foreign key on one partition of the partitioned table it references, whose pg_constraint.conparentid names the constraint it derives from. It names the partition’s share of the referenced rows in pg_constraint, in errors about those rows and in DETACH PARTITION, and keeps the name chosen when the partition joined the referenced table, whatever later happens to the name of the foreign key.
RenameIndexStmt
RenameRoleStmt
RenameRoutineStmt
ALTER FUNCTION | PROCEDURE | ROUTINE name[(input_types)] RENAME TO new_name.
ReturningAliases
RoleMembershipOptions
PostgreSQL 18 options stored on one role-membership grant.
RoutineAttributeClauses
The clauses of a routine statement that compute_function_attributes and compute_common_attribute examine, and what they found that a later stage rejects. A statement carries them until registration checks them; stored definitions carry none.
RoutineColumnTypeReference
Structured relation-column identity carried by a routine %TYPE declaration until catalog binding resolves it to a concrete SQL type.
RoutineInvocationBinding
Concrete parameter and result types selected for one routine invocation.
RoutineSecurityAttributes
Execution identity and planner leakproofness attached to a routine definition.
RoutineTransformType
A type that a TRANSFORM FOR TYPE clause names.
SQLBodyParameter
An input parameter as a SQL-standard body refers to it: the name the body uses, which follows PostgreSQL’s positional naming, and where the parameter’s value arrives in a call.
SelectStmt
SequenceDeclaration
The options a CREATE SEQUENCE, or the declaration of an identity column, writes, kept as written. PostgreSQL reads their values and derives the omitted ones when it creates the sequence, in an order of its own.
SetConstraintName
SetOp
TableCheck
CHECK (expr) constraint with an optional name (CONSTRAINT <name> CHECK (...)).
TableConstraintSet
Durable table-level constraints that do not fit in ColumnDef.
TableFunction
One function inside a FromClause::FunctionGroup.
TableHierarchy
Metadata shared by ordinary inheritance and declarative partitioning.
TableKeyConstraint
A table key whose columns are compared as one tuple.
TablePrivilegeSpec
One table privilege and its optional column list. Unsupported names and column forms survive compilation so execution can preserve PostgreSQL object- and role-resolution precedence.
TransactionCharacteristics
TriggerTransitionRelation
TruncateTarget
TypeDisplayScope
The search path diagnostics use while a statement runs on this thread. Dropping the scope restores the enclosing statement’s path, so nested SQL keeps its own.
UpdateStmt
UserTypeIdentity
A parsed identity: the type’s kind and OID, and the number of array dimensions around it.
VacuumOption
One parser-normalized VACUUM option. Execution validates options before rejecting transaction blocks, then resolves relation targets, matching PostgreSQL’s diagnostic order.
VacuumStmt
VacuumTarget
One relation (and optional ANALYZE column list) named by VACUUM.
WindowCallModifiers
The aggregate modifiers written on a window call, which ParseFuncOrColumn rejects after it has resolved the function. The arguments of a call written with WITHIN GROUP include its ordering expressions.
WindowDefinition
One query-local window definition. The specification owns only its written clauses; inheritance is resolved through an earlier named definition.
WindowDefinitionSyntax
Compiler-only equality key for a raw window declaration; not part of stored SQL.
WindowFrame
WindowReference
WindowSpec

Enums§

AclRoleSpecification
AlterDomainAction
AlterEnumAction
AlterForeignTableAction
AlterRoutineKind
Routine namespace selected by ALTER FUNCTION, ALTER PROCEDURE, or ALTER ROUTINE.
AlterTableAction
AlterTypeObjectAction
AlterViewAction
AlterViewKind
AssignmentStep
AssignmentTargets
The targets of one SET item. A multiple target consumes one positional subquery result. Single targets retain the predecessor’s string or indirection-object encoding.
AutoIncrementKind
PostgreSQL syntax that supplies an omitted column value from an implicit sequence. SERIAL is a sequence-backed default, while identity columns retain a separate generation attribute and do not have a column default.
BinaryOp
ColumnClauseKind
The kind of a column definition’s clause.
ColumnType
CteBody
A CTE owns a query or a data-modifying statement. The serialized query arm retains the original SELECT-only catalog representation.
CteMaterialization
The planning fence requested for one common-table expression.
CursorDirection
DatabasePrivilege
One requested database privilege. Unsupported names survive compilation so execution can preserve PostgreSQL target- and role-resolution precedence.
DatabaseRevokeBehavior
Dependency behavior for database privilege revocation.
DeclaredCheck
Where a CHECK that a CREATE TABLE statement declares is held.
DeclaredElement
An element of a CREATE TABLE statement that transformCreateStmt examines in written order.
DeclaredForeignKey
A foreign key written as a column clause or a table constraint.
DiscardTarget
DISCARD target. Mirrors PostgreSQL’s DiscardMode.
DropKind
EnumFunctionOperation
Operation selected for one call of an anyenum support function. The bound call carries the concrete enum type, because enum_first, enum_last and enum_range read only their argument’s type.
EventEnableMode
Expr
Scalar expression nodes the compiler handles.
ForeignKeyAction
ForeignKeyMatch
ForeignWrapperFunctionOption
FrameBound
FrameExclusion
The frame exclusion clause: the rows of the frame that a window function or aggregate does not see.
FrameMode
FromClause
FunctionBody
Body of a user-defined routine.
FunctionCallSyntax
The written function-call form, retained independently of overload binding. The durable order_syntax field keeps its original name for stored-expression compatibility.
FunctionDispatch
Structural identity for parser-owned expressions and overload-specific built-in implementations. These variants occupy no SQL function-name namespace.
FunctionParallel
PARALLEL UNSAFE, PARALLEL RESTRICTED, or PARALLEL SAFE routine metadata.
FunctionParamMode
Parameter mode of a CREATE FUNCTION / CREATE PROCEDURE argument. Mirrors PostgreSQL’s FunctionParameterMode.
FunctionResolutionError
Static function-call failure discovered while binding declared argument types.
FunctionReturns
Declared result shape of a user-defined function.
FunctionVolatility
IMMUTABLE / STABLE / VOLATILE marker.
GeneratedColumnKind
GrantSequenceTarget
Relation targets carried by GRANT or REVOKE for sequences.
GrantTableTarget
Relation targets carried by GRANT or REVOKE with the TABLE object class.
IndexKey
IntervalFields
The stored-field restriction in a PostgreSQL interval declaration.
JoinKind
LockStrength
PostgreSQL row-lock strength, strongest last.
LockWait
Wait policy for a row-locking clause.
MergeWhen
NullsOrder
NumericOperator
Numeric operator syntax, kept separate from ordinary calls such as mod or abs.
OnCommitAction
ON COMMIT behavior retained with a temporary table definition.
OnConflictAction
OverridingKind
Which value an INSERT writes to an identity column it supplies a value for. Without the clause a supplied value is written to a GENERATED BY DEFAULT identity column and rejected for a GENERATED ALWAYS one.
PartitionBound
PartitionRangeDatum
PartitionStrategy
RangeFunctionOperation
Operation selected for one typed range or multirange call.
RangeSubtype
RelationPersistence
PostgreSQL’s pg_class.relpersistence contract.
RoleAttribute
RoleMembershipAction
RoleSpecification
RoutineAttributeClause
One attribute clause of a routine statement.
RoutineBodyError
A body that interpret_AS_clause rejects.
RoutineConfigAction
RoutineDefaultType
The type of a stored routine default. Some NULL inputs retain a polymorphic pseudo-type without claiming that it is a concrete SQL value carrier.
RoutinePrivilege
A routine privilege clause is retained until target and recipient lookup finish.
RoutineRevokeBehavior
RoutineVariadicMode
Call syntax selected for a routine’s variadic parameter.
RuleEvent
SQLBodyForm
How a SQL-standard body was written; pg_get_function_sqlbody reproduces it.
SchemaAuthorization
SchemaPrivilege
One requested schema privilege. Unsupported names survive compilation so execution can preserve PostgreSQL target- and role-resolution precedence.
SchemaRevokeBehavior
Dependency behavior for schema privilege revocation.
SequenceBound
ALTER SEQUENCE bound action, distinguishing omission from NO MINVALUE or NO MAXVALUE.
SequenceDataType
SequenceLifecycle
Name or namespace lifecycle action carried by ALTER SEQUENCE.
SequenceOptionValue
A sequence option’s value as the parser keeps it, before it is read as a 64-bit integer.
SequenceOwnership
OWNED BY action carried by CREATE SEQUENCE and ALTER SEQUENCE.
SequencePrivilege
One requested sequence privilege. Unsupported names survive compilation so execution can preserve PostgreSQL target- and role-resolution precedence.
SequenceRestart
Physical restart action carried by ALTER SEQUENCE.
SequenceRevokeBehavior
Dependency behavior for sequence privilege revocation.
SetOpKind
Statement
TableKeyConstraintKind
TableLockMode
Explicit table-lock modes; compatibility is owned by the execution lock manager.
TablePrivilege
One requested ordinary-table privilege.
TableRevokeBehavior
Dependency behavior for ordinary-table privilege revocation.
TransactionIsolationLevel
TransactionStmt
TriggerDeferrability
TriggerEvent
TriggerTiming
TypeObjectKind
The keyword that named the target. DOMAIN statements reject types that are not domains.
TypePrivilege
A privilege named by GRANT | REVOKE ... ON TYPE | DOMAIN. Types have only USAGE; other names are rejected after the targets are resolved, as PostgreSQL does.
TypeRevokeBehavior
UserTypeKind
VacuumOptionValue
WindowReferenceKind

Functions§

is_builtin_aggregate_function
Return whether name is a built-in aggregate understood by the planner.

Type Aliases§

FunctionOrderSyntax
The original public name, preserved for callers and stored ordering metadata.
GeneratedFunctionDependency
RoutineAclEntry
One explicit EXECUTE ACL entry. None on CreateFunction::execute_acl retains PostgreSQL’s default public execution privilege.
ValueExpr
Expr restricted to value-producing forms used by INSERT rows.