mirror of
https://github.com/scylladb/scylladb.git
synced 2026-06-05 06:23:03 +00:00
test/cqlpy: add tests for WHERE clause relation count limit
Add tests that verify the CQL parser rejects WHERE clauses with too many relations (e.g. WHERE a=1 AND b=1 AND ... repeated 200 times), and that a reasonable number of relations (50) is still accepted.
This commit is contained in:
@@ -106,3 +106,26 @@ def test_lots_of_opening_paren_not_closed(cql, table1, scylla_only):
|
||||
"""An opening parenthesis with no closing parenthesis must be rejected."""
|
||||
with pytest.raises(SyntaxException):
|
||||
cql.execute(f"SELECT * FROM {table1} WHERE " + "(" * DEPTH)
|
||||
|
||||
# The default max_relations_in_where_clause is 100.
|
||||
OVER_LIMIT = 200
|
||||
|
||||
def make_where_clause(n):
|
||||
"""Build a WHERE clause with n relations: p = 1 AND v = 1 AND v = 1 ..."""
|
||||
return "p = 1" + " AND v = 1" * (n - 1)
|
||||
|
||||
|
||||
@pytest.mark.skip_bug("https://scylladb.atlassian.net/browse/SCYLLADB-1002")
|
||||
def test_too_many_relations_in_where_clause(cql, table1, scylla_only):
|
||||
"""A WHERE clause with too many relations must be rejected."""
|
||||
where = make_where_clause(OVER_LIMIT)
|
||||
with pytest.raises(SyntaxException):
|
||||
cql.execute(f"SELECT * FROM {table1} WHERE {where} ALLOW FILTERING")
|
||||
|
||||
|
||||
def test_reasonable_number_of_relations_allowed(cql, table1, scylla_only):
|
||||
"""A WHERE clause within the limit should be accepted."""
|
||||
where = make_where_clause(50)
|
||||
# Should not raise - we just need it to parse successfully.
|
||||
# The query itself may return no rows, that's fine.
|
||||
cql.execute(f"SELECT * FROM {table1} WHERE {where} ALLOW FILTERING")
|
||||
|
||||
Reference in New Issue
Block a user