mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:28:12 +00:00
LibSQL: Report a syntax error for unsupported LIMIT clause syntax
Rather than aborting when a LIMIT clause of the form 'LIMIT expr, expr' is encountered, fail the parser with a syntax error. This will be nicer for the user and fixes the following fuzzer bug: https://crbug.com/oss-fuzz/34837
This commit is contained in:
parent
0ff09d4f74
commit
a870eac0eb
2 changed files with 3 additions and 2 deletions
|
@ -321,11 +321,11 @@ NonnullRefPtr<Select> Parser::parse_select_statement(RefPtr<CommonTableExpressio
|
|||
RefPtr<Expression> offset_expression;
|
||||
if (consume_if(TokenType::Offset)) {
|
||||
offset_expression = parse_expression();
|
||||
} else {
|
||||
} else if (consume_if(TokenType::Comma)) {
|
||||
// Note: The limit clause may instead be defined as "offset-expression, limit-expression", effectively reversing the
|
||||
// order of the expressions. SQLite notes "this is counter-intuitive" and "to avoid confusion, programmers are strongly
|
||||
// encouraged to ... avoid using a LIMIT clause with a comma-separated offset."
|
||||
VERIFY(!consume_if(TokenType::Comma));
|
||||
syntax_error("LIMIT clauses of the form 'LIMIT <expr>, <expr>' are not supported");
|
||||
}
|
||||
|
||||
limit_clause = create_ast_node<LimitClause>(move(limit_expression), move(offset_expression));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue