cql3: lift infinite bound check if it's supported
If the database supports infinite bound range deletions, CQL layer will no longer throw an error indicating that both ranges need to be specified. [bhalevy] Update test_range_deletion_scenarios unit test accordingly. Fixes #432 Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
This commit is contained in:
committed by
Benny Halevy
parent
c19fdc4c90
commit
add40d4e59
@@ -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_ptr<v
|
||||
}
|
||||
|
||||
stmt->process_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");
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user