Crate vibesql_ast

Crate vibesql_ast 

Source
Expand description

Abstract Syntax Tree (AST) for SQL:1999

This crate defines the structure of SQL statements and expressions as parsed from SQL text. The AST is a tree representation that preserves the semantic structure of SQL queries.

§Arena-allocated Types

For performance-critical code paths, this crate provides arena-allocated versions of AST types in the arena module. These use bump allocation for improved cache locality and reduced allocation overhead.

§Visitor Pattern

The visitor module provides traits for traversing and transforming AST nodes without duplicating traversal logic:

See the module documentation for usage examples.

§SQL Pretty-Printing

The pretty_print module provides the pretty_print::ToSql trait for converting AST nodes back to valid SQL strings:

use vibesql_ast::pretty_print::ToSql;
use vibesql_ast::BinaryOperator;

let op = BinaryOperator::Plus;
assert_eq!(op.to_sql(), "+");

Modules§

arena
Arena-allocated AST types for improved parsing performance.
pretty_print
SQL pretty-printer for AST nodes
visitor
Visitor pattern for AST traversal

Structs§

AddColumnStmt
ADD COLUMN operation
AddConstraintStmt
ADD CONSTRAINT operation
AlterCronStmt
ALTER CRON statement - modify a cron job
AlterSequenceStmt
ALTER SEQUENCE statement
AlterTriggerStmt
ALTER TRIGGER statement
AnalyzeStmt
ANALYZE statement
Assignment
Column assignment (column = value)
BeginStmt
BEGIN TRANSACTION statement
CallStmt
CALL statement (execute a procedure)
CancelScheduleStmt
CANCEL SCHEDULE statement - remove a scheduled task
CaseWhen
CASE WHEN clause structure Supports multiple conditions (OR’d together) per WHEN clause Example: WHEN 1, 2, 3 THEN ‘low’ means: WHEN x=1 OR x=2 OR x=3 THEN ‘low’
ChangeColumnStmt
CHANGE COLUMN operation (MySQL-style - rename and modify)
CloseCursorStmt
CLOSE CURSOR statement (SQL:1999 Feature E121)
ColumnConstraint
Column-level constraint
ColumnDef
Column definition
ColumnIdentifier
A SQL column identifier with proper case handling per SQL:1999.
CommitStmt
COMMIT statement
CommonTableExpr
Common Table Expression (CTE) definition
ConstraintDeferral
Constraint deferral mode for foreign key constraints (SQL:1999)
CreateAssertionStmt
CREATE ASSERTION statement
CreateCharacterSetStmt
CREATE CHARACTER SET statement
CreateCollationStmt
CREATE COLLATION statement
CreateCronStmt
CREATE CRON statement - create a recurring cron job
CreateDomainStmt
CREATE DOMAIN statement
CreateFunctionStmt
CREATE FUNCTION statement
CreateIndexStmt
CREATE INDEX statement
CreateProcedureStmt
CREATE PROCEDURE statement
CreateRoleStmt
CREATE ROLE statement
CreateSchemaStmt
CREATE SCHEMA statement
CreateSequenceStmt
CREATE SEQUENCE statement
CreateTableStmt
CREATE TABLE statement
CreateTranslationStmt
CREATE TRANSLATION statement
CreateTriggerStmt
CREATE TRIGGER statement
CreateTypeStmt
CREATE TYPE statement
CreateViewStmt
CREATE VIEW statement
DeallocateStmt
DEALLOCATE statement for removing a prepared statement
DeclareCursorStmt
DECLARE CURSOR statement (SQL:1999 Feature E121)
DeleteStmt
DELETE statement
DescribeStmt
DESCRIBE statement (synonym for SHOW COLUMNS)
DomainConstraint
Domain constraint (CHECK constraint on domain values)
DropAssertionStmt
DROP ASSERTION statement
DropCharacterSetStmt
DROP CHARACTER SET statement
DropCollationStmt
DROP COLLATION statement
DropColumnStmt
DROP COLUMN operation
DropConstraintStmt
DROP CONSTRAINT operation
DropCronStmt
DROP CRON statement - remove a cron job
DropDomainStmt
DROP DOMAIN statement
DropFunctionStmt
DROP FUNCTION statement
DropIndexStmt
DROP INDEX statement
DropProcedureStmt
DROP PROCEDURE statement
DropRoleStmt
DROP ROLE statement
DropSchemaStmt
DROP SCHEMA statement
DropSequenceStmt
DROP SEQUENCE statement
DropTableStmt
DROP TABLE statement
DropTranslationStmt
DROP TRANSLATION statement
DropTriggerStmt
DROP TRIGGER statement
DropTypeStmt
DROP TYPE statement
DropViewStmt
DROP VIEW statement
ExecuteStmt
EXECUTE statement for executing a prepared statement
ExplainStmt
EXPLAIN statement
FetchStmt
FETCH statement (SQL:1999 Feature E121)
FunctionIdentifier
A SQL function identifier with proper case handling.
FunctionParameter
Parameter in a function definition (functions typically only have IN parameters)
GrantStmt
GRANT statement - assigns privileges to roles/users.
GroupingSet
A single grouping set within GROUPING SETS
InsertStmt
INSERT statement
ModifyColumnStmt
MODIFY COLUMN operation (MySQL-style)
OnConflictClause
ON CONFLICT clause for INSERT statements (SQLite upsert)
OpenCursorStmt
OPEN CURSOR statement (SQL:1999 Feature E121)
OrderByItem
ORDER BY item
PragmaStmt
PRAGMA statement
PrepareStmt
PREPARE statement for creating a prepared statement
ProcedureParameter
Parameter in a procedure definition (MySQL-style)
ReindexStmt
REINDEX statement
ReleaseSavepointStmt
RELEASE SAVEPOINT statement
RenameTableStmt
RENAME TABLE operation
RevokeStmt
REVOKE statement - removes privileges from roles/users.
RollbackStmt
ROLLBACK statement
RollbackToSavepointStmt
ROLLBACK TO SAVEPOINT statement
SavepointStmt
SAVEPOINT statement
ScheduleAfterStmt
SCHEDULE AFTER statement - schedule a task to run after a time interval
ScheduleAtStmt
SCHEDULE AT statement - schedule a task to run at a specific time
SelectStmt
SELECT statement structure
SetCatalogStmt
SET CATALOG statement
SetNamesStmt
SET NAMES statement
SetOperation
Set operation combining two SELECT statements
SetSchemaStmt
SET SCHEMA statement
SetTimeZoneStmt
SET TIME ZONE statement
SetTransactionStmt
SET TRANSACTION statement (SQL:1999 Feature E152)
SetVariableStmt
SET variable statement (MySQL/PostgreSQL extension) Handles: SET [GLOBAL | SESSION] variable_name = value
ShowColumnsStmt
SHOW COLUMNS statement
ShowCreateTableStmt
SHOW CREATE TABLE statement
ShowDatabasesStmt
SHOW DATABASES statement
ShowIndexStmt
SHOW INDEX statement
ShowTablesStmt
SHOW TABLES statement
TableConstraint
Table-level constraint
TableIdentifier
A SQL identifier with proper case handling per SQL:1999.
TableRef
A reference to a table name with case-sensitivity information.
TruncateTableStmt
TRUNCATE TABLE statement
TypeAttribute
Attribute in a structured type
UpdateStmt
UPDATE statement
WindowFrame
Window frame specification
WindowSpec
Window specification (OVER clause)

Enums§

AlterColumnStmt
ALTER COLUMN operation
AlterTableStmt
ALTER TABLE statement
AlterTriggerAction
ALTER TRIGGER action
BinaryOperator
Binary operators for SQL expressions
CascadeOption
CASCADE or RESTRICT option for REVOKE statement.
CharacterUnit
Character measurement unit for string functions SQL:1999 Section 6.29: String value functions Used in USING clause for CHARACTER_LENGTH, SUBSTRING, POSITION
ColumnConstraintKind
Column constraint types
ConflictClause
Conflict resolution strategy for INSERT and UPDATE statements (SQLite extension)
CteMaterialization
CTE materialization hint for optimizer control
CursorUpdatability
Cursor updatability specification
DeallocateTarget
Target for DEALLOCATE statement
DropBehavior
Drop behavior for CASCADE/RESTRICT
DurabilityHint
Durability hint for a transaction
ExplainFormat
EXPLAIN statement output format
Expression
SQL Expression (can appear in SELECT, WHERE, etc.)
FetchOrientation
Fetch orientation specification
FrameBound
Frame boundary specification
FrameExclude
Frame exclusion specification (SQL:2011) Determines which rows to exclude from the frame
FrameUnit
Frame unit type
FromClause
FROM clause
FulltextMode
Full-text search mode specification
GroupByClause
GROUP BY clause structure supporting OLAP extensions
GroupingElement
A single grouping element within ROLLUP or CUBE
IndexColumn
Index column specification - can be either a simple column reference or an expression
IndexType
Index type specification
InsertMethod
MySQL INSERT_METHOD values
InsertSource
Source of data for INSERT statement
IntervalUnit
Interval unit for INTERVAL expressions SQL:1999 Section 6.12: Interval literal Used in INTERVAL ‘5’ DAY, DATE_ADD(), etc.
IsolationLevel
Transaction isolation level
JoinType
JOIN types
MixedGroupingItem
An item in a mixed GROUP BY clause
NullsOrder
NULL ordering in ORDER BY clause (SQL:2003 extension) Specifies whether NULL values sort before or after non-NULL values
ObjectType
Types of database objects that can have privileges granted on them.
OnConflictAction
Action to take when a conflict occurs (SQLite upsert clause)
OrderDirection
Sort direction
ParameterMode
Parameter mode: IN, OUT, or INOUT
PragmaValue
Value for a PRAGMA statement
PreparedStatementBody
The body of a prepared statement
PrivilegeType
Privilege types that can be granted on database objects.
ProceduralStatement
A statement within a procedural block
ProcedureBody
Body of a procedure or function
PseudoTable
Pseudo-table reference for trigger context Used in OLD.column and NEW.column expressions
Quantifier
Quantifier for quantified comparisons
ReferentialAction
Referential action for foreign key constraints
RowFormat
MySQL ROW_FORMAT values
SchemaElement
Schema element that can be included in CREATE SCHEMA
SelectItem
Item in the SELECT list
SetOperator
Set operators for combining SELECT statements
SqlSecurity
SQL SECURITY characteristic for procedures and functions
Statement
A complete SQL statement
StorageFormat
Storage format for tables
TableConstraintKind
Table constraint types
TableOption
MySQL table options for CREATE TABLE
TimeZoneSpec
Time zone specification for SET TIME ZONE
TransactionAccessMode
Transaction access mode
TriggerAction
Triggered action (procedural SQL)
TriggerEvent
Trigger event: INSERT | UPDATE | DELETE
TriggerGranularity
Trigger granularity: FOR EACH ROW | FOR EACH STATEMENT
TriggerTiming
Trigger timing: BEFORE | AFTER | INSTEAD OF
TrimPosition
TRIM position specification Determines which side(s) to trim characters from
TruncateCascadeOption
CASCADE option for TRUNCATE TABLE
TruthValue
Truth value for IS TRUE/IS FALSE/IS UNKNOWN predicates (SQL:1999)
TypeDefinition
Type definition (distinct, structured, or forward)
UnaryOperator
Unary operators for SQL expressions
VariableScope
Variable scope for SET statements
VectorDistanceMetric
Distance metric for vector index operations
WhereClause
WHERE clause for positioned UPDATE/DELETE
WindowFunctionSpec
Window function specification

Type Aliases§

Identifier
A general SQL identifier (for indexes, views, etc.)