File tree Expand file tree Collapse file tree 3 files changed +22
-0
lines changed Expand file tree Collapse file tree 3 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -956,6 +956,8 @@ pub enum Statement {
956
956
/// A SQL query that specifies what to explain
957
957
statement : Box < Statement > ,
958
958
} ,
959
+ /// SAVEPOINT -- define a new savepoint within the current transaction
960
+ Savepoint { name : Ident } ,
959
961
// MERGE INTO statement, based on Snowflake. See <https://docs.snowflake.com/en/sql-reference/sql/merge.html>
960
962
Merge {
961
963
// Specifies the table to merge
@@ -1619,6 +1621,10 @@ impl fmt::Display for Statement {
1619
1621
write ! ( f, "NULL" )
1620
1622
}
1621
1623
}
1624
+ Statement :: Savepoint { name } => {
1625
+ write ! ( f, "SAVEPOINT " ) ?;
1626
+ write ! ( f, "{}" , name)
1627
+ }
1622
1628
Statement :: Merge {
1623
1629
table,
1624
1630
source,
Original file line number Diff line number Diff line change @@ -179,6 +179,7 @@ impl<'a> Parser<'a> {
179
179
// standard `START TRANSACTION` statement. It is supported
180
180
// by at least PostgreSQL and MySQL.
181
181
Keyword :: BEGIN => Ok ( self . parse_begin ( ) ?) ,
182
+ Keyword :: SAVEPOINT => Ok ( self . parse_savepoint ( ) ?) ,
182
183
Keyword :: COMMIT => Ok ( self . parse_commit ( ) ?) ,
183
184
Keyword :: ROLLBACK => Ok ( self . parse_rollback ( ) ?) ,
184
185
Keyword :: ASSERT => Ok ( self . parse_assert ( ) ?) ,
@@ -367,6 +368,11 @@ impl<'a> Parser<'a> {
367
368
Ok ( Statement :: Assert { condition, message } )
368
369
}
369
370
371
+ pub fn parse_savepoint ( & mut self ) -> Result < Statement , ParserError > {
372
+ let name = self . parse_identifier ( ) ?;
373
+ Ok ( Statement :: Savepoint { name } )
374
+ }
375
+
370
376
/// Parse an expression prefix
371
377
pub fn parse_prefix ( & mut self ) -> Result < Expr , ParserError > {
372
378
// PostgreSQL allows any string literal to be preceded by a type name, indicating that the
Original file line number Diff line number Diff line change @@ -871,6 +871,16 @@ fn test_transaction_statement() {
871
871
) ;
872
872
}
873
873
874
+ #[ test]
875
+ fn test_savepoint ( ) {
876
+ match pg ( ) . verified_stmt ( "SAVEPOINT test1" ) {
877
+ Statement :: Savepoint { name } => {
878
+ assert_eq ! ( Ident :: new( "test1" ) , name) ;
879
+ }
880
+ _ => unreachable ! ( ) ,
881
+ }
882
+ }
883
+
874
884
#[ test]
875
885
fn parse_comments ( ) {
876
886
match pg ( ) . verified_stmt ( "COMMENT ON COLUMN tab.name IS 'comment'" ) {
You can’t perform that action at this time.
0 commit comments