You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datafusion.apache.org by gi...@apache.org on 2026/02/10 11:14:10 UTC
(datafusion-sqlparser-rs) branch main updated: Fix panic in `SET AUTHORIZATION` parsing when scope modifier is missing (#2201)
This is an automated email from the ASF dual-hosted git repository.
github-bot pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion-sqlparser-rs.git
The following commit(s) were added to refs/heads/main by this push:
new 03f00cdb Fix panic in `SET AUTHORIZATION` parsing when scope modifier is missing (#2201)
03f00cdb is described below
commit 03f00cdb2724d482ac7f909c9e79080942b8bce3
Author: Luca Cappelletti <ca...@gmail.com>
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: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org