Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cql3: grammar: reject intValue with no contents
The grammar mistakenly allows nothing to be parsed as an intValue (itself accepted in LIMIT and similar clauses). Easily fixed by removing the empty alternative. A unit test is added. Fixes #14705. Closes #14707
- Loading branch information
Showing
2 changed files
with
25 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Copyright 2023-present ScyllaDB | ||
# | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
# A collection of tests for grammar that should be rejected, but wasn't at | ||
# some point in the past. | ||
|
||
import pytest | ||
from util import new_test_table | ||
from cassandra.protocol import InvalidRequest, SyntaxException | ||
|
||
|
||
# table1 is just there so we can execute bad queries against it. | ||
@pytest.fixture(scope="module") | ||
def table1(cql, test_keyspace): | ||
with new_test_table(cql, test_keyspace, "p int, c int, v int, PRIMARY KEY (p, c)") as table: | ||
yield table | ||
|
||
# LIMIT should be followed by an expression (#14705) | ||
def test_limit_empty(cql, table1): | ||
with pytest.raises(SyntaxException): | ||
cql.execute(f'SELECT * FROM {table1} LIMIT') | ||
with pytest.raises(SyntaxException): | ||
cql.execute(f'SELECT * FROM {table1} PER PARTITION LIMIT') |