File tree Expand file tree Collapse file tree 4 files changed +47
-4
lines changed Expand file tree Collapse file tree 4 files changed +47
-4
lines changed Original file line number Diff line number Diff line change @@ -4059,6 +4059,12 @@ pub enum Statement {
4059
4059
immediate : bool ,
4060
4060
into : Vec < Ident > ,
4061
4061
using : Vec < ExprWithAlias > ,
4062
+ /// Whether the last parameter is the return value of the procedure
4063
+ /// MSSQL: <https://learn.microsoft.com/en-us/sql/t-sql/language-elements/execute-transact-sql?view=sql-server-ver17#output>
4064
+ output : bool ,
4065
+ /// Whether to invoke the procedure with the default parameter values
4066
+ /// MSSQL: <https://learn.microsoft.com/en-us/sql/t-sql/language-elements/execute-transact-sql?view=sql-server-ver17#default>
4067
+ default : bool ,
4062
4068
} ,
4063
4069
/// ```sql
4064
4070
/// PREPARE name [ ( data_type [, ...] ) ] AS statement
@@ -5815,6 +5821,8 @@ impl fmt::Display for Statement {
5815
5821
immediate,
5816
5822
into,
5817
5823
using,
5824
+ output,
5825
+ default,
5818
5826
} => {
5819
5827
let ( open, close) = if * has_parentheses {
5820
5828
( "(" , ")" )
@@ -5835,6 +5843,12 @@ impl fmt::Display for Statement {
5835
5843
if !using. is_empty ( ) {
5836
5844
write ! ( f, " USING {}" , display_comma_separated( using) ) ?;
5837
5845
} ;
5846
+ if * output {
5847
+ write ! ( f, " OUTPUT" ) ?;
5848
+ }
5849
+ if * default {
5850
+ write ! ( f, " DEFAULT" ) ?;
5851
+ }
5838
5852
Ok ( ( ) )
5839
5853
}
5840
5854
Statement :: Prepare {
Original file line number Diff line number Diff line change @@ -15734,10 +15734,11 @@ impl<'a> Parser<'a> {
15734
15734
15735
15735
let has_parentheses = self.consume_token(&Token::LParen);
15736
15736
15737
+ let end_kws = &[Keyword::USING, Keyword::OUTPUT, Keyword::DEFAULT];
15737
15738
let end_token = match (has_parentheses, self.peek_token().token) {
15738
15739
(true, _) => Token::RParen,
15739
15740
(false, Token::EOF) => Token::EOF,
15740
- (false, Token::Word(w)) if w.keyword == Keyword::USING => Token::Word(w),
15741
+ (false, Token::Word(w)) if end_kws.contains(& w.keyword) => Token::Word(w),
15741
15742
(false, _) => Token::SemiColon,
15742
15743
};
15743
15744
@@ -15759,13 +15760,19 @@ impl<'a> Parser<'a> {
15759
15760
vec![]
15760
15761
};
15761
15762
15763
+ let output = self.parse_keyword(Keyword::OUTPUT);
15764
+
15765
+ let default = self.parse_keyword(Keyword::DEFAULT);
15766
+
15762
15767
Ok(Statement::Execute {
15763
15768
immediate: name.is_none(),
15764
15769
name,
15765
15770
parameters,
15766
15771
has_parentheses,
15767
15772
into,
15768
15773
using,
15774
+ output,
15775
+ default,
15769
15776
})
15770
15777
}
15771
15778
Original file line number Diff line number Diff line change @@ -11393,6 +11393,8 @@ fn parse_execute_stored_procedure() {
11393
11393
immediate: false,
11394
11394
using: vec![],
11395
11395
into: vec![],
11396
+ output: false,
11397
+ default: false,
11396
11398
};
11397
11399
assert_eq!(
11398
11400
// Microsoft SQL Server does not use parentheses around arguments for EXECUTE
@@ -11407,6 +11409,18 @@ fn parse_execute_stored_procedure() {
11407
11409
),
11408
11410
expected
11409
11411
);
11412
+ match ms_and_generic().verified_stmt("EXECUTE dbo.proc1 @ReturnVal = @X OUTPUT") {
11413
+ Statement::Execute { output, .. } => {
11414
+ assert!(output);
11415
+ }
11416
+ _ => unreachable!(),
11417
+ }
11418
+ match ms_and_generic().verified_stmt("EXECUTE dbo.proc1 DEFAULT") {
11419
+ Statement::Execute { default, .. } => {
11420
+ assert!(default);
11421
+ }
11422
+ _ => unreachable!(),
11423
+ }
11410
11424
}
11411
11425
11412
11426
#[test]
@@ -11425,6 +11439,8 @@ fn parse_execute_immediate() {
11425
11439
into: vec![Ident::new("a")],
11426
11440
name: None,
11427
11441
has_parentheses: false,
11442
+ output: false,
11443
+ default: false,
11428
11444
};
11429
11445
11430
11446
let stmt = dialects.verified_stmt("EXECUTE IMMEDIATE 'SELECT 1' INTO a USING 1 AS b");
Original file line number Diff line number Diff line change @@ -1666,7 +1666,9 @@ fn parse_execute() {
1666
1666
has_parentheses: false ,
1667
1667
using: vec![ ] ,
1668
1668
immediate: false ,
1669
- into: vec![ ]
1669
+ into: vec![ ] ,
1670
+ output: false ,
1671
+ default : false ,
1670
1672
}
1671
1673
) ;
1672
1674
@@ -1682,7 +1684,9 @@ fn parse_execute() {
1682
1684
has_parentheses: true ,
1683
1685
using: vec![ ] ,
1684
1686
immediate: false ,
1685
- into: vec![ ]
1687
+ into: vec![ ] ,
1688
+ output: false ,
1689
+ default : false ,
1686
1690
}
1687
1691
) ;
1688
1692
@@ -1719,7 +1723,9 @@ fn parse_execute() {
1719
1723
} ,
1720
1724
] ,
1721
1725
immediate: false ,
1722
- into: vec![ ]
1726
+ into: vec![ ] ,
1727
+ output: false ,
1728
+ default : false ,
1723
1729
}
1724
1730
) ;
1725
1731
}
You can’t perform that action at this time.
0 commit comments