Skip to content

Commit 06ab5ff

Browse files
Merge branch 'scope-expect-panic' into fuzzing
2 parents 56fd042 + 1a69b59 commit 06ab5ff

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/parser/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14516,8 +14516,13 @@ impl<'a> Parser<'a> {
1451614516
let value = self.parse_identifier()?;
1451714517
SetSessionAuthorizationParamKind::User(value)
1451814518
};
14519+
let scope = scope.ok_or_else(|| {
14520+
ParserError::ParserError(
14521+
"Expected a scope modifier (e.g. SESSION) before AUTHORIZATION".to_string(),
14522+
)
14523+
})?;
1451914524
return Ok(Set::SetSessionAuthorization(SetSessionAuthorizationParam {
14520-
scope: scope.expect("SET ... AUTHORIZATION must have a scope"),
14525+
scope,
1452114526
kind: auth_value,
1452214527
})
1452314528
.into());

tests/sqlparser_common.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18280,6 +18280,18 @@ fn test_parse_set_session_authorization() {
1828018280
);
1828118281
}
1828218282

18283+
#[test]
18284+
fn test_set_authorization_without_scope_errors() {
18285+
// This should return a parser error, not panic.
18286+
let res = parse_sql_statements(
18287+
"\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"
18288+
);
18289+
assert!(
18290+
res.is_err(),
18291+
"SET AUTHORIZATION without a scope modifier (e.g. SESSION) should error"
18292+
);
18293+
}
18294+
1828318295
#[test]
1828418296
fn parse_select_parenthesized_wildcard() {
1828518297
// Test SELECT DISTINCT(*) which uses a parenthesized wildcard

0 commit comments

Comments
 (0)