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
6 changes: 5 additions & 1 deletion src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20707,7 +20707,11 @@ impl<'a> Parser<'a> {
return self.expected_ref(" another option or EOF", self.peek_token_ref());
}
}
Token::EOF | Token::SemiColon => break,
Token::EOF => break,
Token::SemiColon => {
self.prev_token();
break;
}
Token::Comma => {
delimiter = KeyValueOptionsDelimiter::Comma;
continue;
Expand Down
16 changes: 16 additions & 0 deletions tests/sqlparser_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17942,6 +17942,22 @@ fn parse_create_user() {
}
}

#[test]
fn key_value_option_statements_do_not_swallow_following_statement() {
// An unparenthesized key-value option list must not swallow the statement
// terminator, otherwise any following statement fails to parse. This covers
// every unparenthesized caller of `parse_key_value_options`: `CREATE USER`
// and both `ALTER USER ... SET` forms.
for sql in [
"CREATE USER user1; SELECT 1",
"ALTER USER user1 SET x = 'y'; SELECT 1",
"ALTER USER user1 SET TAG t = 'v'; SELECT 1",
] {
let statements = Parser::parse_sql(&GenericDialect {}, sql).unwrap();
assert_eq!(statements.len(), 2, "{sql}");
}
}

#[test]
fn parse_drop_stream() {
let sql = "DROP STREAM s1";
Expand Down
Loading