diff --git a/cql3/statements/cas_request.cc b/cql3/statements/cas_request.cc index 5d1df9214a5a..94d1915dda63 100644 --- a/cql3/statements/cas_request.cc +++ b/cql3/statements/cas_request.cc @@ -123,6 +123,9 @@ std::optional cas_request::apply(foreign_ptrvalue().key().value(); // We must ignore statement clustering column restriction when // choosing a row to check the conditions. If there is no @@ -134,6 +137,9 @@ cas_request::old_row cas_request::find_old_row(const cas_row_update& op) const { // CREATE TABLE t(p int, c int, s int static, v int, PRIMARY KEY(p, c)); // INSERT INTO t(p, s) VALUES(1, 1); // UPDATE t SET v=1 WHERE p=1 AND c=1 IF s=1; + if (op.ranges.empty()) { + throw exceptions::invalid_request_exception("Empty clustering range"); + } const clustering_key& ckey = op.ranges.front().start() ? op.ranges.front().start()->value() : empty_ckey; auto row = _rows.find_row(pkey, ckey); auto ckey_ptr = &ckey; diff --git a/cql3/statements/modification_statement.cc b/cql3/statements/modification_statement.cc index 6c60555c87b5..057653beb7e4 100644 --- a/cql3/statements/modification_statement.cc +++ b/cql3/statements/modification_statement.cc @@ -318,6 +318,10 @@ modification_statement::execute_with_condition(query_processor& qp, service::que throw exceptions::invalid_request_exception(format("Unrestricted partition key in a conditional {}", type.is_update() ? "update" : "deletion")); } + if (ranges.empty()) { + throw exceptions::invalid_request_exception(format("Unrestricted clustering key in a conditional {}", + type.is_update() ? "update" : "deletion")); + } auto request = seastar::make_shared(s, std::move(keys)); // cas_request can be used for batches as well single statements; Here we have just a single diff --git a/test/cql-pytest/test_lwt.py b/test/cql-pytest/test_lwt.py index c9a8c1bcf30f..cad3fe031482 100644 --- a/test/cql-pytest/test_lwt.py +++ b/test/cql-pytest/test_lwt.py @@ -73,7 +73,6 @@ def test_lwt_empty_partition_range(cql, table1): # Generate an LWT update where there is no value for the clustering key, # as the WHERE restricts it using `c = 2 AND c = 3`. # Such queries are rejected. -@pytest.mark.skip(reason="crashes scylla, see issue #13129") def test_lwt_empty_clustering_range(cql, table1): with pytest.raises(InvalidRequest): cql.execute(f"UPDATE {table1} SET r = 9000 WHERE p = 1 AND c = 2 AND c = 2000 IF r = 3")