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:
visitor::ExpressionVisitor: Read-only expression traversalvisitor::ExpressionMutVisitor: Expression transformationvisitor::StatementVisitor: Statement traversal
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§
- AddColumn
Stmt - ADD COLUMN operation
- AddConstraint
Stmt - ADD CONSTRAINT operation
- Alter
Cron Stmt - ALTER CRON statement - modify a cron job
- Alter
Sequence Stmt - ALTER SEQUENCE statement
- Alter
Trigger Stmt - ALTER TRIGGER statement
- Analyze
Stmt - ANALYZE statement
- Assignment
- Column assignment (column = value)
- Begin
Stmt - BEGIN TRANSACTION statement
- Call
Stmt - CALL statement (execute a procedure)
- Cancel
Schedule Stmt - CANCEL SCHEDULE statement - remove a scheduled task
- Case
When - 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’
- Change
Column Stmt - CHANGE COLUMN operation (MySQL-style - rename and modify)
- Close
Cursor Stmt - CLOSE CURSOR statement (SQL:1999 Feature E121)
- Column
Constraint - Column-level constraint
- Column
Def - Column definition
- Column
Identifier - A SQL column identifier with proper case handling per SQL:1999.
- Commit
Stmt - COMMIT statement
- Common
Table Expr - Common Table Expression (CTE) definition
- Constraint
Deferral - Constraint deferral mode for foreign key constraints (SQL:1999)
- Create
Assertion Stmt - CREATE ASSERTION statement
- Create
Character SetStmt - CREATE CHARACTER SET statement
- Create
Collation Stmt - CREATE COLLATION statement
- Create
Cron Stmt - CREATE CRON statement - create a recurring cron job
- Create
Domain Stmt - CREATE DOMAIN statement
- Create
Function Stmt - CREATE FUNCTION statement
- Create
Index Stmt - CREATE INDEX statement
- Create
Procedure Stmt - CREATE PROCEDURE statement
- Create
Role Stmt - CREATE ROLE statement
- Create
Schema Stmt - CREATE SCHEMA statement
- Create
Sequence Stmt - CREATE SEQUENCE statement
- Create
Table Stmt - CREATE TABLE statement
- Create
Translation Stmt - CREATE TRANSLATION statement
- Create
Trigger Stmt - CREATE TRIGGER statement
- Create
Type Stmt - CREATE TYPE statement
- Create
View Stmt - CREATE VIEW statement
- Deallocate
Stmt - DEALLOCATE statement for removing a prepared statement
- Declare
Cursor Stmt - DECLARE CURSOR statement (SQL:1999 Feature E121)
- Delete
Stmt - DELETE statement
- Describe
Stmt - DESCRIBE statement (synonym for SHOW COLUMNS)
- Domain
Constraint - Domain constraint (CHECK constraint on domain values)
- Drop
Assertion Stmt - DROP ASSERTION statement
- Drop
Character SetStmt - DROP CHARACTER SET statement
- Drop
Collation Stmt - DROP COLLATION statement
- Drop
Column Stmt - DROP COLUMN operation
- Drop
Constraint Stmt - DROP CONSTRAINT operation
- Drop
Cron Stmt - DROP CRON statement - remove a cron job
- Drop
Domain Stmt - DROP DOMAIN statement
- Drop
Function Stmt - DROP FUNCTION statement
- Drop
Index Stmt - DROP INDEX statement
- Drop
Procedure Stmt - DROP PROCEDURE statement
- Drop
Role Stmt - DROP ROLE statement
- Drop
Schema Stmt - DROP SCHEMA statement
- Drop
Sequence Stmt - DROP SEQUENCE statement
- Drop
Table Stmt - DROP TABLE statement
- Drop
Translation Stmt - DROP TRANSLATION statement
- Drop
Trigger Stmt - DROP TRIGGER statement
- Drop
Type Stmt - DROP TYPE statement
- Drop
View Stmt - DROP VIEW statement
- Execute
Stmt - EXECUTE statement for executing a prepared statement
- Explain
Stmt - EXPLAIN statement
- Fetch
Stmt - FETCH statement (SQL:1999 Feature E121)
- Function
Identifier - A SQL function identifier with proper case handling.
- Function
Parameter - Parameter in a function definition (functions typically only have IN parameters)
- Grant
Stmt - GRANT statement - assigns privileges to roles/users.
- Grouping
Set - A single grouping set within GROUPING SETS
- Insert
Stmt - INSERT statement
- Modify
Column Stmt - MODIFY COLUMN operation (MySQL-style)
- OnConflict
Clause - ON CONFLICT clause for INSERT statements (SQLite upsert)
- Open
Cursor Stmt - OPEN CURSOR statement (SQL:1999 Feature E121)
- Order
ByItem - ORDER BY item
- Pragma
Stmt - PRAGMA statement
- Prepare
Stmt - PREPARE statement for creating a prepared statement
- Procedure
Parameter - Parameter in a procedure definition (MySQL-style)
- Reindex
Stmt - REINDEX statement
- Release
Savepoint Stmt - RELEASE SAVEPOINT statement
- Rename
Table Stmt - RENAME TABLE operation
- Revoke
Stmt - REVOKE statement - removes privileges from roles/users.
- Rollback
Stmt - ROLLBACK statement
- Rollback
ToSavepoint Stmt - ROLLBACK TO SAVEPOINT statement
- Savepoint
Stmt - SAVEPOINT statement
- Schedule
After Stmt - SCHEDULE AFTER statement - schedule a task to run after a time interval
- Schedule
AtStmt - SCHEDULE AT statement - schedule a task to run at a specific time
- Select
Stmt - SELECT statement structure
- SetCatalog
Stmt - SET CATALOG statement
- SetNames
Stmt - SET NAMES statement
- SetOperation
- Set operation combining two SELECT statements
- SetSchema
Stmt - SET SCHEMA statement
- SetTime
Zone Stmt - SET TIME ZONE statement
- SetTransaction
Stmt - SET TRANSACTION statement (SQL:1999 Feature E152)
- SetVariable
Stmt - SET variable statement (MySQL/PostgreSQL extension) Handles: SET [GLOBAL | SESSION] variable_name = value
- Show
Columns Stmt - SHOW COLUMNS statement
- Show
Create Table Stmt - SHOW CREATE TABLE statement
- Show
Databases Stmt - SHOW DATABASES statement
- Show
Index Stmt - SHOW INDEX statement
- Show
Tables Stmt - SHOW TABLES statement
- Table
Constraint - Table-level constraint
- Table
Identifier - A SQL identifier with proper case handling per SQL:1999.
- Table
Ref - A reference to a table name with case-sensitivity information.
- Truncate
Table Stmt - TRUNCATE TABLE statement
- Type
Attribute - Attribute in a structured type
- Update
Stmt - UPDATE statement
- Window
Frame - Window frame specification
- Window
Spec - Window specification (OVER clause)
Enums§
- Alter
Column Stmt - ALTER COLUMN operation
- Alter
Table Stmt - ALTER TABLE statement
- Alter
Trigger Action - ALTER TRIGGER action
- Binary
Operator - Binary operators for SQL expressions
- Cascade
Option - CASCADE or RESTRICT option for REVOKE statement.
- Character
Unit - Character measurement unit for string functions SQL:1999 Section 6.29: String value functions Used in USING clause for CHARACTER_LENGTH, SUBSTRING, POSITION
- Column
Constraint Kind - Column constraint types
- Conflict
Clause - Conflict resolution strategy for INSERT and UPDATE statements (SQLite extension)
- CteMaterialization
- CTE materialization hint for optimizer control
- Cursor
Updatability - Cursor updatability specification
- Deallocate
Target - Target for DEALLOCATE statement
- Drop
Behavior - Drop behavior for CASCADE/RESTRICT
- Durability
Hint - Durability hint for a transaction
- Explain
Format - EXPLAIN statement output format
- Expression
- SQL Expression (can appear in SELECT, WHERE, etc.)
- Fetch
Orientation - Fetch orientation specification
- Frame
Bound - Frame boundary specification
- Frame
Exclude - Frame exclusion specification (SQL:2011) Determines which rows to exclude from the frame
- Frame
Unit - Frame unit type
- From
Clause - FROM clause
- Fulltext
Mode - Full-text search mode specification
- Group
ByClause - GROUP BY clause structure supporting OLAP extensions
- Grouping
Element - A single grouping element within ROLLUP or CUBE
- Index
Column - Index column specification - can be either a simple column reference or an expression
- Index
Type - Index type specification
- Insert
Method - MySQL INSERT_METHOD values
- Insert
Source - Source of data for INSERT statement
- Interval
Unit - Interval unit for INTERVAL expressions SQL:1999 Section 6.12: Interval literal Used in INTERVAL ‘5’ DAY, DATE_ADD(), etc.
- Isolation
Level - Transaction isolation level
- Join
Type - JOIN types
- Mixed
Grouping Item - An item in a mixed GROUP BY clause
- Nulls
Order - NULL ordering in ORDER BY clause (SQL:2003 extension) Specifies whether NULL values sort before or after non-NULL values
- Object
Type - Types of database objects that can have privileges granted on them.
- OnConflict
Action - Action to take when a conflict occurs (SQLite upsert clause)
- Order
Direction - Sort direction
- Parameter
Mode - Parameter mode: IN, OUT, or INOUT
- Pragma
Value - Value for a PRAGMA statement
- Prepared
Statement Body - The body of a prepared statement
- Privilege
Type - Privilege types that can be granted on database objects.
- Procedural
Statement - A statement within a procedural block
- Procedure
Body - Body of a procedure or function
- Pseudo
Table - Pseudo-table reference for trigger context Used in OLD.column and NEW.column expressions
- Quantifier
- Quantifier for quantified comparisons
- Referential
Action - Referential action for foreign key constraints
- RowFormat
- MySQL ROW_FORMAT values
- Schema
Element - Schema element that can be included in CREATE SCHEMA
- Select
Item - 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
- Storage
Format - Storage format for tables
- Table
Constraint Kind - Table constraint types
- Table
Option - MySQL table options for CREATE TABLE
- Time
Zone Spec - Time zone specification for SET TIME ZONE
- Transaction
Access Mode - Transaction access mode
- Trigger
Action - Triggered action (procedural SQL)
- Trigger
Event - Trigger event: INSERT | UPDATE | DELETE
- Trigger
Granularity - Trigger granularity: FOR EACH ROW | FOR EACH STATEMENT
- Trigger
Timing - Trigger timing: BEFORE | AFTER | INSTEAD OF
- Trim
Position - TRIM position specification Determines which side(s) to trim characters from
- Truncate
Cascade Option - CASCADE option for TRUNCATE TABLE
- Truth
Value - Truth value for IS TRUE/IS FALSE/IS UNKNOWN predicates (SQL:1999)
- Type
Definition - Type definition (distinct, structured, or forward)
- Unary
Operator - Unary operators for SQL expressions
- Variable
Scope - Variable scope for SET statements
- Vector
Distance Metric - Distance metric for vector index operations
- Where
Clause - WHERE clause for positioned UPDATE/DELETE
- Window
Function Spec - Window function specification
Type Aliases§
- Identifier
- A general SQL identifier (for indexes, views, etc.)