1use vibesql_types::DataType;
13
14use crate::Expression;
15
16#[derive(Debug, Clone, PartialEq)]
22pub struct CreateDomainStmt {
23 pub domain_name: String,
24 pub data_type: DataType,
25 pub default: Option<Box<Expression>>,
26 pub constraints: Vec<DomainConstraint>,
27}
28
29#[derive(Debug, Clone, PartialEq)]
31pub struct DomainConstraint {
32 pub name: Option<String>,
33 pub check: Box<Expression>,
34}
35
36#[derive(Debug, Clone, PartialEq)]
38pub struct DropDomainStmt {
39 pub domain_name: String,
40 pub cascade: bool, }
42
43#[derive(Debug, Clone, PartialEq)]
49pub struct CreateSequenceStmt {
50 pub sequence_name: String,
51 pub start_with: Option<i64>,
52 pub increment_by: i64, pub min_value: Option<i64>,
54 pub max_value: Option<i64>,
55 pub cycle: bool, }
57
58#[derive(Debug, Clone, PartialEq)]
60pub struct DropSequenceStmt {
61 pub sequence_name: String,
62 pub cascade: bool, }
64
65#[derive(Debug, Clone, PartialEq)]
67pub struct AlterSequenceStmt {
68 pub sequence_name: String,
69 pub restart_with: Option<i64>,
70 pub increment_by: Option<i64>,
71 pub min_value: Option<Option<i64>>, pub max_value: Option<Option<i64>>, pub cycle: Option<bool>,
76}
77
78#[derive(Debug, Clone, PartialEq)]
84pub struct CreateTypeStmt {
85 pub type_name: String,
86 pub definition: TypeDefinition,
87}
88
89#[derive(Debug, Clone, PartialEq)]
91pub enum TypeDefinition {
92 Distinct { base_type: DataType },
93 Structured { attributes: Vec<TypeAttribute> },
94 Forward, }
96
97#[derive(Debug, Clone, PartialEq)]
99pub struct TypeAttribute {
100 pub name: String,
101 pub data_type: DataType,
102}
103
104#[derive(Debug, Clone, PartialEq)]
106pub struct DropTypeStmt {
107 pub type_name: String,
108 pub behavior: DropBehavior,
109}
110
111#[derive(Debug, Clone, PartialEq)]
113pub enum DropBehavior {
114 Cascade,
115 Restrict,
116}
117
118#[derive(Debug, Clone, PartialEq)]
130pub struct CreateCollationStmt {
131 pub collation_name: String,
132 pub character_set: Option<String>, pub source_collation: Option<String>, pub pad_space: Option<bool>, }
136
137#[derive(Debug, Clone, PartialEq)]
139pub struct DropCollationStmt {
140 pub collation_name: String,
141}
142
143#[derive(Debug, Clone, PartialEq)]
154pub struct CreateCharacterSetStmt {
155 pub charset_name: String,
156 pub source: Option<String>, pub collation: Option<String>, }
159
160#[derive(Debug, Clone, PartialEq)]
162pub struct DropCharacterSetStmt {
163 pub charset_name: String,
164}
165
166#[derive(Debug, Clone, PartialEq)]
177pub struct CreateTranslationStmt {
178 pub translation_name: String,
179 pub source_charset: Option<String>, pub target_charset: Option<String>, pub translation_source: Option<String>, }
183
184#[derive(Debug, Clone, PartialEq)]
186pub struct DropTranslationStmt {
187 pub translation_name: String,
188}
189
190#[derive(Debug, Clone, PartialEq)]
196pub struct CreateAssertionStmt {
197 pub assertion_name: String,
198 pub check_condition: Box<Expression>,
199}
200
201#[derive(Debug, Clone, PartialEq)]
203pub struct DropAssertionStmt {
204 pub assertion_name: String,
205 pub cascade: bool, }
207
208#[derive(Debug, Clone, PartialEq)]
214pub struct CreateProcedureStmt {
215 pub procedure_name: String,
216 pub parameters: Vec<ProcedureParameter>,
217 pub body: ProcedureBody,
218 pub sql_security: Option<SqlSecurity>,
220 pub comment: Option<String>,
221 pub language: Option<String>,
222}
223
224#[derive(Debug, Clone, PartialEq)]
226pub struct CreateFunctionStmt {
227 pub function_name: String,
228 pub parameters: Vec<FunctionParameter>,
229 pub return_type: vibesql_types::DataType,
230 pub body: ProcedureBody,
231 pub deterministic: Option<bool>,
233 pub sql_security: Option<SqlSecurity>,
234 pub comment: Option<String>,
235 pub language: Option<String>,
236}
237
238#[derive(Debug, Clone, PartialEq)]
240pub enum SqlSecurity {
241 Definer,
242 Invoker,
243}
244
245#[derive(Debug, Clone, PartialEq)]
247pub struct ProcedureParameter {
248 pub mode: ParameterMode,
249 pub name: String,
250 pub data_type: vibesql_types::DataType,
251}
252
253#[derive(Debug, Clone, PartialEq)]
255pub enum ParameterMode {
256 In,
257 Out,
258 InOut,
259}
260
261#[derive(Debug, Clone, PartialEq)]
263pub struct FunctionParameter {
264 pub name: String,
265 pub data_type: vibesql_types::DataType,
266}
267
268#[derive(Debug, Clone, PartialEq)]
270pub enum ProcedureBody {
271 BeginEnd(Vec<ProceduralStatement>),
273 RawSql(String),
275}
276
277#[derive(Debug, Clone, PartialEq)]
279pub enum ProceduralStatement {
280 Sql(Box<crate::Statement>),
282 Declare {
284 name: String,
285 data_type: vibesql_types::DataType,
286 default_value: Option<Box<Expression>>,
287 },
288 Set { name: String, value: Box<Expression> },
290 If {
292 condition: Box<Expression>,
293 then_statements: Vec<ProceduralStatement>,
294 else_statements: Option<Vec<ProceduralStatement>>,
295 },
296 While { condition: Box<Expression>, statements: Vec<ProceduralStatement> },
298 Loop { statements: Vec<ProceduralStatement> },
300 Repeat { statements: Vec<ProceduralStatement>, condition: Box<Expression> },
302 Return(Box<Expression>),
304 Leave(String), Iterate(String), }
309
310#[derive(Debug, Clone, PartialEq)]
312pub struct DropProcedureStmt {
313 pub procedure_name: String,
314 pub if_exists: bool,
315}
316
317#[derive(Debug, Clone, PartialEq)]
319pub struct DropFunctionStmt {
320 pub function_name: String,
321 pub if_exists: bool,
322}
323
324#[derive(Debug, Clone, PartialEq)]
326pub struct CallStmt {
327 pub procedure_name: String,
328 pub arguments: Vec<Expression>,
329}