1pub mod arena;
38pub mod pretty_print;
39pub mod visitor;
40
41#[derive(Debug, Clone, PartialEq)]
65pub struct TableRef {
66 pub schema_name: Option<String>,
68 pub schema_quoted: bool,
70 pub name: String,
72 pub quoted: bool,
76}
77
78impl TableRef {
79 pub fn new(name: String, quoted: bool) -> Self {
81 Self { schema_name: None, schema_quoted: false, name, quoted }
82 }
83
84 pub fn qualified(
86 schema_name: String,
87 schema_quoted: bool,
88 table_name: String,
89 table_quoted: bool,
90 ) -> Self {
91 Self {
92 schema_name: Some(schema_name),
93 schema_quoted,
94 name: table_name,
95 quoted: table_quoted,
96 }
97 }
98
99 pub fn unquoted(name: String) -> Self {
101 Self::new(name, false)
102 }
103
104 pub fn quoted_ref(name: String) -> Self {
106 Self::new(name, true)
107 }
108
109 pub fn full_name(&self) -> String {
111 match &self.schema_name {
112 Some(schema) => format!("{}.{}", schema, self.name),
113 None => self.name.clone(),
114 }
115 }
116
117 pub fn is_any_quoted(&self) -> bool {
119 self.quoted || self.schema_quoted
120 }
121}
122
123impl From<String> for TableRef {
124 fn from(name: String) -> Self {
126 Self::unquoted(name)
127 }
128}
129
130impl From<&str> for TableRef {
131 fn from(name: &str) -> Self {
133 Self::unquoted(name.to_string())
134 }
135}
136
137impl std::fmt::Display for TableRef {
138 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
139 if self.quoted {
140 write!(f, "\"{}\"", self.name.replace('"', "\"\""))
142 } else {
143 write!(f, "{}", self.name)
144 }
145 }
146}
147
148mod ddl;
149mod dml;
150mod expression;
151mod grant;
152mod identifier;
153mod introspection;
154mod operators;
155mod revoke;
156mod select;
157mod statement;
158
159pub use ddl::{
160 AddColumnStmt, AddConstraintStmt, AlterColumnStmt, AlterCronStmt, AlterSequenceStmt,
161 AlterTableStmt, AlterTriggerAction, AlterTriggerStmt, AnalyzeStmt, BeginStmt, CallStmt,
162 CancelScheduleStmt, ChangeColumnStmt, CloseCursorStmt, ColumnConstraint, ColumnConstraintKind,
163 ColumnDef, CommitStmt, ConstraintDeferral, CreateAssertionStmt, CreateCharacterSetStmt,
164 CreateCollationStmt, CreateCronStmt, CreateDomainStmt, CreateFunctionStmt, CreateIndexStmt,
165 CreateProcedureStmt, CreateRoleStmt, CreateSchemaStmt, CreateSequenceStmt, CreateTableStmt,
166 CreateTranslationStmt, CreateTriggerStmt, CreateTypeStmt, CreateViewStmt, CursorUpdatability,
167 DeallocateStmt, DeallocateTarget, DeclareCursorStmt, DomainConstraint, DropAssertionStmt,
168 DropBehavior, DropCharacterSetStmt, DropCollationStmt, DropColumnStmt, DropConstraintStmt,
169 DropCronStmt, DropDomainStmt, DropFunctionStmt, DropIndexStmt, DropProcedureStmt, DropRoleStmt,
170 DropSchemaStmt, DropSequenceStmt, DropTableStmt, DropTranslationStmt, DropTriggerStmt,
171 DropTypeStmt, DropViewStmt, DurabilityHint, ExecuteStmt, FetchOrientation, FetchStmt,
172 FunctionParameter, IndexColumn, IndexType, InsertMethod, IsolationLevel, ModifyColumnStmt,
173 OpenCursorStmt, ParameterMode, PragmaStmt, PragmaValue, PrepareStmt, PreparedStatementBody,
174 ProceduralStatement, ProcedureBody, ProcedureParameter, ReferentialAction, ReindexStmt,
175 ReleaseSavepointStmt, RenameTableStmt, RollbackStmt, RollbackToSavepointStmt, RowFormat,
176 SavepointStmt, ScheduleAfterStmt, ScheduleAtStmt, SchemaElement, SetCatalogStmt, SetNamesStmt,
177 SetSchemaStmt, SetTimeZoneStmt, SetTransactionStmt, SetVariableStmt, SqlSecurity,
178 StorageFormat, TableConstraint, TableConstraintKind, TableOption, TimeZoneSpec,
179 TransactionAccessMode, TriggerAction, TriggerEvent, TriggerGranularity, TriggerTiming,
180 TruncateCascadeOption, TruncateTableStmt, TypeAttribute, TypeDefinition, VariableScope,
181 VectorDistanceMetric,
182};
183pub use dml::{
184 Assignment, ConflictClause, DeleteStmt, InsertSource, InsertStmt, OnConflictAction,
185 OnConflictClause, UpdateStmt, WhereClause,
186};
187pub use expression::{
188 CaseWhen, CharacterUnit, Expression, FrameBound, FrameExclude, FrameUnit, FulltextMode,
189 IntervalUnit, PseudoTable, Quantifier, TrimPosition, TruthValue, WindowFrame,
190 WindowFunctionSpec, WindowSpec,
191};
192pub use grant::{GrantStmt, ObjectType, PrivilegeType};
193pub use introspection::{
194 DescribeStmt, ExplainFormat, ExplainStmt, ShowColumnsStmt, ShowCreateTableStmt,
195 ShowDatabasesStmt, ShowIndexStmt, ShowTablesStmt,
196};
197pub use operators::{BinaryOperator, UnaryOperator};
198pub use revoke::{CascadeOption, RevokeStmt};
199pub use select::{
200 CommonTableExpr, CteMaterialization, FromClause, GroupByClause, GroupingElement, GroupingSet,
201 JoinType, MixedGroupingItem, NullsOrder, OrderByItem, OrderDirection, SelectItem, SelectStmt,
202 SetOperation, SetOperator,
203};
204pub use statement::Statement;
205
206pub use identifier::{ColumnIdentifier, FunctionIdentifier, Identifier, TableIdentifier};