From 0afbbb9d44907bf6bb96f3c01bbcdc06f649cb78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Dziepak?= Date: Thu, 13 Aug 2015 10:45:27 +0200 Subject: [PATCH] cql3: fix empty IN () restriction MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Values inside IN () restrictions may be either in a vector _in_values or a marker (_in_marker or _value). To determine which one is appropriate we check whether _in_values is empty, which is wrong because IN clause can be empty (and there is no marker in such case). This is fixed by using the presence of a marker to determine whether a vector of values or a marker should be used. Signed-off-by: Paweł Dziepak --- cql3/multi_column_relation.hh | 2 +- cql3/single_column_relation.cc | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cql3/multi_column_relation.hh b/cql3/multi_column_relation.hh index bbb494ab9b..01c1478356 100644 --- a/cql3/multi_column_relation.hh +++ b/cql3/multi_column_relation.hh @@ -138,7 +138,7 @@ protected: std::transform(rs.begin(), rs.end(), col_specs.begin(), [] (auto cs) { return cs->column_specification; }); - if (_in_values.empty()) { + if (_in_marker) { auto t = to_term(col_specs, get_value(), db, schema->ks_name(), bound_names); auto as_abstract_marker = static_pointer_cast(t); return ::make_shared(schema, rs, as_abstract_marker); diff --git a/cql3/single_column_relation.cc b/cql3/single_column_relation.cc index 787116a084..09d3a798bc 100644 --- a/cql3/single_column_relation.cc +++ b/cql3/single_column_relation.cc @@ -63,11 +63,12 @@ single_column_relation::new_EQ_restriction(database& db, schema_ptr schema, ::sh single_column_relation::new_IN_restriction(database& db, schema_ptr schema, ::shared_ptr bound_names) { const column_definition& column_def = to_column_definition(schema, _entity); auto receivers = to_receivers(schema, column_def); - auto terms = to_terms(receivers, _in_values, db, schema->ks_name(), bound_names); - if (terms.empty()) { + assert(_in_values.empty() || !_value); + if (_value) { auto term = to_term(receivers, _value, db, schema->ks_name(), bound_names); return make_shared(column_def, dynamic_pointer_cast(term)); } + auto terms = to_terms(receivers, _in_values, db, schema->ks_name(), bound_names); return ::make_shared(column_def, std::move(terms)); }