Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
7 changes: 6 additions & 1 deletion src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14515,8 +14515,13 @@ impl<'a> Parser<'a> {
let value = self.parse_identifier()?;
SetSessionAuthorizationParamKind::User(value)
};
let scope = scope.ok_or_else(|| {
ParserError::ParserError(
"Expected a scope modifier (e.g. SESSION) before AUTHORIZATION".to_string(),
)
Comment thread
LucaCappelletti94 marked this conversation as resolved.
Outdated
})?;
return Ok(Set::SetSessionAuthorization(SetSessionAuthorizationParam {
scope: scope.expect("SET ... AUTHORIZATION must have a scope"),
scope,
kind: auth_value,
})
.into());
Expand Down
12 changes: 12 additions & 0 deletions tests/sqlparser_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18273,6 +18273,18 @@ 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(
"\tSET\t\t\t\t\t\t\t\t\t\tAUTHORIZATION\tTIME\t\t\t\t\t\tTIME\u{fffd}\u{fffd}v\u{1}\0\0\t74843EUTI>\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0USER_RNCLUDE_NULL\0\0\0\0\0\0\0\0\0\t\t\t\t^^^^^^^^\tWHI\t\tIN"
Comment thread
LucaCappelletti94 marked this conversation as resolved.
Outdated
);
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