Skip to content
Open
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
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 on lines +14519 to +14521
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use one of the helper functions like self.expected_at?

})?;
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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a simpler test case that reproduces the error? I'm assuming the escape sequences and null characters shouldnt be necessary based on the diff

);
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