Add support for MS-SQL BEGIN/END TRY/CATCH (#1649)

This commit is contained in:
Yoav Cohen 2025-01-08 19:31:24 +01:00 committed by GitHub
parent 397bceb241
commit 687ce2d5f4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 112 additions and 25 deletions

View file

@ -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,
})
}