mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-12-23 11:12:51 +00:00
Add support for MS-SQL BEGIN/END TRY/CATCH (#1649)
This commit is contained in:
parent
397bceb241
commit
687ce2d5f4
9 changed files with 112 additions and 25 deletions
|
|
@ -12800,6 +12800,10 @@ impl<'a> Parser<'a> {
|
|||
Some(TransactionModifier::Immediate)
|
||||
} else if self.parse_keyword(Keyword::EXCLUSIVE) {
|
||||
Some(TransactionModifier::Exclusive)
|
||||
} else if self.parse_keyword(Keyword::TRY) {
|
||||
Some(TransactionModifier::Try)
|
||||
} else if self.parse_keyword(Keyword::CATCH) {
|
||||
Some(TransactionModifier::Catch)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
|
@ -12817,8 +12821,19 @@ impl<'a> Parser<'a> {
|
|||
}
|
||||
|
||||
pub fn parse_end(&mut self) -> Result<Statement, ParserError> {
|
||||
let modifier = if !self.dialect.supports_end_transaction_modifier() {
|
||||
None
|
||||
} else if self.parse_keyword(Keyword::TRY) {
|
||||
Some(TransactionModifier::Try)
|
||||
} else if self.parse_keyword(Keyword::CATCH) {
|
||||
Some(TransactionModifier::Catch)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
Ok(Statement::Commit {
|
||||
chain: self.parse_commit_rollback_chain()?,
|
||||
end: true,
|
||||
modifier,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -12861,6 +12876,8 @@ impl<'a> Parser<'a> {
|
|||
pub fn parse_commit(&mut self) -> Result<Statement, ParserError> {
|
||||
Ok(Statement::Commit {
|
||||
chain: self.parse_commit_rollback_chain()?,
|
||||
end: false,
|
||||
modifier: None,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue