diff --git a/cql3/statements/delete_statement.cc b/cql3/statements/delete_statement.cc index 33bf161d19..e3b6300189 100644 --- a/cql3/statements/delete_statement.cc +++ b/cql3/statements/delete_statement.cc @@ -41,6 +41,7 @@ #include "delete_statement.hh" #include "raw/delete_statement.hh" +#include "database.hh" namespace cql3 { @@ -102,9 +103,11 @@ delete_statement::prepare_internal(database& db, schema_ptr schema, shared_ptrprocess_where_clause(db, _where_clause, std::move(bound_names)); - if (!stmt->restrictions()->get_clustering_columns_restrictions()->has_bound(bound::START) - || !stmt->restrictions()->get_clustering_columns_restrictions()->has_bound(bound::END)) { - throw exceptions::invalid_request_exception("A range deletion operation needs to specify both bounds"); + if (!db.supports_infinite_bound_range_deletions()) { + if (!stmt->restrictions()->get_clustering_columns_restrictions()->has_bound(bound::START) + || !stmt->restrictions()->get_clustering_columns_restrictions()->has_bound(bound::END)) { + throw exceptions::invalid_request_exception("A range deletion operation needs to specify both bounds for clusters without sstable mc format support"); + } } if (!schema->is_compound() && stmt->restrictions()->get_clustering_columns_restrictions()->is_slice()) { throw exceptions::invalid_request_exception("Range deletions on \"compact storage\" schemas are not supported"); diff --git a/tests/cql_query_test.cc b/tests/cql_query_test.cc index 263ce86195..85c7a52d02 100644 --- a/tests/cql_query_test.cc +++ b/tests/cql_query_test.cc @@ -1064,18 +1064,12 @@ SEASTAR_TEST_CASE(test_range_deletion_scenarios) { e.execute_cql(format("insert into cf (p, c, v) values (1, {:d}, 'abc');", i)).get(); } - try { - e.execute_cql("delete from cf where p = 1 and c <= 3").get(); - BOOST_FAIL("should've thrown"); - } catch (...) { } - try { - e.execute_cql("delete from cf where p = 1 and c >= 0").get(); - BOOST_FAIL("should've thrown"); - } catch (...) { } + e.execute_cql("delete from cf where p = 1 and c <= 3").get(); + e.execute_cql("delete from cf where p = 1 and c >= 8").get(); - e.execute_cql("delete from cf where p = 1 and c >= 0 and c <= 3").get(); + e.execute_cql("delete from cf where p = 1 and c >= 0 and c <= 5").get(); auto msg = e.execute_cql("select * from cf").get0(); - assert_that(msg).is_rows().with_size(6); + assert_that(msg).is_rows().with_size(2); e.execute_cql("delete from cf where p = 1 and c > 3 and c < 10").get(); msg = e.execute_cql("select * from cf").get0(); assert_that(msg).is_rows().with_size(0);