Improve MySQL CREATE TRIGGER parsing (#1998)
Some checks are pending
license / Release Audit Tool (RAT) (push) Waiting to run
Rust / codestyle (push) Waiting to run
Rust / lint (push) Waiting to run
Rust / benchmark-lint (push) Waiting to run
Rust / compile (push) Waiting to run
Rust / docs (push) Waiting to run
Rust / compile-no-std (push) Waiting to run
Rust / test (beta) (push) Waiting to run
Rust / test (nightly) (push) Waiting to run
Rust / test (stable) (push) Waiting to run

This commit is contained in:
Michael Victor Zink 2025-08-07 22:02:59 -07:00 committed by GitHub
parent 698154d0e0
commit 183bc7c5ff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 62 additions and 19 deletions

View file

@ -5593,9 +5593,13 @@ impl<'a> Parser<'a> {
.then(|| self.parse_expr())
.transpose()?;
self.expect_keyword_is(Keyword::EXECUTE)?;
let exec_body = self.parse_trigger_exec_body()?;
let mut exec_body = None;
let mut statements = None;
if self.parse_keyword(Keyword::EXECUTE) {
exec_body = Some(self.parse_trigger_exec_body()?);
} else {
statements = Some(self.parse_conditional_statements(&[Keyword::END])?);
}
Ok(Statement::CreateTrigger {
or_alter,
@ -5603,6 +5607,7 @@ impl<'a> Parser<'a> {
is_constraint,
name,
period,
period_before_table: true,
events,
table_name,
referenced_table_name,
@ -5610,8 +5615,9 @@ impl<'a> Parser<'a> {
trigger_object,
include_each,
condition,
exec_body: Some(exec_body),
statements: None,
exec_body,
statements_as: false,
statements,
characteristics,
})
}
@ -6537,7 +6543,7 @@ impl<'a> Parser<'a> {
let args = if self.consume_token(&Token::LParen) {
if self.consume_token(&Token::RParen) {
None
Some(vec![])
} else {
let args = self.parse_comma_separated(Parser::parse_function_arg)?;
self.expect_token(&Token::RParen)?;
@ -9307,10 +9313,10 @@ impl<'a> Parser<'a> {
}),
}))
} else {
return self.expected_ref(
self.expected_ref(
"{RENAME TO | { RENAME | ADD } VALUE}",
self.peek_token_ref(),
);
)
}
}