This is an automated email from the ASF dual-hosted git repository. github-bot pushed a commit to branch gh-readonly-queue/main/pr-2201-d52681969e43cf0d66ea9c4e09fc32beb8d17ad2 in repository https://gitbox.apache.org/repos/asf/datafusion-sqlparser-rs.git
commit 03f00cdb2724d482ac7f909c9e79080942b8bce3 Author: Luca Cappelletti <[email protected]> AuthorDate: Tue Feb 10 12:09:18 2026 +0100 Fix panic in `SET AUTHORIZATION` parsing when scope modifier is missing (#2201) --- src/parser/mod.rs | 11 ++++++++++- tests/sqlparser_common.rs | 10 ++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/parser/mod.rs b/src/parser/mod.rs index c40ed427..8f3ae38f 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs @@ -14546,6 +14546,15 @@ impl<'a> Parser<'a> { } .into()); } else if self.parse_keyword(Keyword::AUTHORIZATION) { + let scope = match scope { + Some(s) => s, + None => { + return self.expected_at( + "SESSION, LOCAL, or other scope modifier before AUTHORIZATION", + self.get_current_index(), + ) + } + }; let auth_value = if self.parse_keyword(Keyword::DEFAULT) { SetSessionAuthorizationParamKind::Default } else { @@ -14553,7 +14562,7 @@ impl<'a> Parser<'a> { SetSessionAuthorizationParamKind::User(value) }; return Ok(Set::SetSessionAuthorization(SetSessionAuthorizationParam { - scope: scope.expect("SET ... AUTHORIZATION must have a scope"), + scope, kind: auth_value, }) .into()); diff --git a/tests/sqlparser_common.rs b/tests/sqlparser_common.rs index 3c32e627..899dba8d 100644 --- a/tests/sqlparser_common.rs +++ b/tests/sqlparser_common.rs @@ -18333,6 +18333,16 @@ fn test_parse_set_session_authorization() { ); } +#[test] +fn test_set_authorization_without_scope_errors() { + // This should return a parser error, not panic. + let res = parse_sql_statements("SET AUTHORIZATION TIME TIME"); + assert!( + res.is_err(), + "SET AUTHORIZATION without a scope modifier (e.g. SESSION) should error" + ); +} + #[test] fn parse_select_parenthesized_wildcard() { // Test SELECT DISTINCT(*) which uses a parenthesized wildcard --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
