11import { ColumnDef , ColumnOption , CommentDef , DataType , GeneratedAs , NullsDistinctOption , SqlOption } from "./data-type" ;
22import type { Expr , ExprWithAlias , OneOrManyWithParens } from "./expr" ;
33import { FunctionArg , SQLFunction } from "./function" ;
4- import type { Ident , ObjectName } from "./ident" ;
4+ import type { Ident , ObjectName , ObjectType } from "./ident" ;
55import type { AttachedToken , Value , ValueWithSpan } from "./token" ;
66
77/**
@@ -50,7 +50,16 @@ export type Statement = {
5050 CreateServer ?: unknown ;
5151 CreatePolicy ?: unknown ;
5252 CreateConnector ?: unknown ;
53- AlterTable ?: unknown ;
53+ AlterTable ?: {
54+ name : ObjectName ,
55+ if_exists : boolean ,
56+ only : boolean ,
57+ operations : AlterTableOperation [ ] ,
58+ location ?: unknown ,
59+ on_cluster ?: Ident ,
60+ iceberg : boolean ,
61+ end_token : AttachedToken ,
62+ } ;
5463 AlterSchema ?: unknown ;
5564 AlterIndex ?: unknown ;
5665 AlterView ?: unknown ;
@@ -62,7 +71,16 @@ export type Statement = {
6271 AttachDatabase ?: unknown ;
6372 AttachDuckDBDatabase ?: unknown ;
6473 DetachDuckDBDatabase ?: unknown ;
65- Drop ?: unknown ;
74+ Drop ?: {
75+ object_type : ObjectType ,
76+ if_exists : boolean ,
77+ names : ObjectName [ ] ,
78+ cascade : boolean ,
79+ restrict : boolean ,
80+ purge : boolean ,
81+ temporary : boolean ,
82+ table ?: ObjectName ,
83+ } ;
6684 DropFunction ?: unknown ;
6785 DropDomain ?: unknown ;
6886 DropProcedure ?: unknown ;
@@ -89,10 +107,25 @@ export type Statement = {
89107 ShowViews ?: unknown ;
90108 ShowCollation ?: unknown ;
91109 Use ?: unknown ;
92- StartTransaction ?: unknown ;
110+ StartTransaction ?: {
111+ modes : TransactionMode [ ] ,
112+ begin : boolean ,
113+ transaction ?: BeginTransactionKind ,
114+ modifier ?: TransactionModifier ,
115+ statements : Statement [ ] ,
116+ exception ?: unknown [ ] ,
117+ has_end_keyword : boolean ,
118+ } ;
93119 Comment ?: unknown ;
94- Commit ?: unknown ;
95- Rollback ?: unknown ;
120+ Commit ?: {
121+ chain : boolean ,
122+ end : boolean ,
123+ modifier ?: TransactionModifier ,
124+ } ;
125+ Rollback ?: {
126+ chain : boolean ,
127+ savepoint ?: Ident ,
128+ } ;
96129 CreateSchema ?: unknown ;
97130 CreateDatabase ?: unknown ;
98131 CreateFunction ?: unknown ;
@@ -139,6 +172,55 @@ export type Statement = {
139172 Vacuum ?: unknown ;
140173}
141174
175+ /**
176+ * @see https://docs.rs/sqlparser/latest/sqlparser/ast/enum.TransactionMode.html
177+ */
178+ export type TransactionMode = {
179+ AccessMode ?: TransactionAccessMode ,
180+ IsolationLevel ?: TransactionIsolationLevel ,
181+ }
182+
183+ /**
184+ * @see https://docs.rs/sqlparser/latest/sqlparser/ast/enum.TransactionAccessMode.html
185+ */
186+ export type TransactionAccessMode =
187+ | 'ReadOnly'
188+ | 'ReadWrite' ;
189+
190+ /**
191+ * @see https://docs.rs/sqlparser/latest/sqlparser/ast/enum.TransactionIsolationLevel.html
192+ */
193+ export type TransactionIsolationLevel =
194+ | 'ReadUncommitted'
195+ | 'ReadCommitted'
196+ | 'RepeatableRead'
197+ | 'Serializable'
198+ | 'Snapshot' ;
199+
200+ /**
201+ * Transaction started with `[ TRANSACTION | WORK ]`
202+ *
203+ * @see https://docs.rs/sqlparser/latest/sqlparser/ast/enum.BeginTransactionKind.html
204+ */
205+ export type BeginTransactionKind =
206+ | 'Transaction'
207+ | 'Work' ;
208+
209+ /**
210+ * Modifier for the transaction in the `BEGIN` syntax.
211+ *
212+ * SQLite: https://sqlite.org/lang_transaction.html
213+ * MS-SQL: https://learn.microsoft.com/en-us/sql/t-sql/language-elements/try-catch-transact-sql
214+ *
215+ * @see https://docs.rs/sqlparser/latest/sqlparser/ast/enum.TransactionModifier.html
216+ */
217+ export type TransactionModifier =
218+ | 'Deferred'
219+ | 'Immediate'
220+ | 'Exclusive'
221+ | 'Try'
222+ | 'Catch' ;
223+
142224/**
143225 * A SQL `CREATE INDEX` statement.
144226 *
0 commit comments