Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14546,14 +14546,23 @@ 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 {
let value = self.parse_identifier()?;
SetSessionAuthorizationParamKind::User(value)
};
return Ok(Set::SetSessionAuthorization(SetSessionAuthorizationParam {
scope: scope.expect("SET ... AUTHORIZATION must have a scope"),
scope,
kind: auth_value,
})
.into());
Expand Down
10 changes: 10 additions & 0 deletions tests/sqlparser_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading