cql3: expr: Modify list_prepare_expression to handle lists of IN values

The standard CQL list type doesn't allow for nulls inside the collection.

However lists of IN values are the exception where bind nullsare allowed,
for example in restrictions like: p IN (1, 2, null)

To be able to use list_prepare_expression with lists of IN values
a flag is added to specify whether nulls should be allowed.

Signed-off-by: cvybhu <jan.ciolek@scylladb.com>
This commit is contained in:
cvybhu
2022-05-03 22:04:16 +02:00
parent 2b5818697a
commit b99aae7d41

View File

@@ -375,7 +375,7 @@ list_test_assignment(const collection_constructor& c, data_dictionary::database
static
expression
list_prepare_expression(const collection_constructor& c, data_dictionary::database db, const sstring& keyspace, lw_shared_ptr<column_specification> receiver) {
list_prepare_expression(const collection_constructor& c, data_dictionary::database db, const sstring& keyspace, lw_shared_ptr<column_specification> receiver, bool is_in_list) {
list_validate_assignable_to(c, db, keyspace, *receiver);
// In Cassandra, an empty (unfrozen) map/set/list is equivalent to the column being null. In
@@ -404,7 +404,11 @@ list_prepare_expression(const collection_constructor& c, data_dictionary::databa
.type = receiver->type
};
if (all_terminal) {
return evaluate(value, query_options::DEFAULT);
if (is_in_list) {
return evaluate_IN_list(value, query_options::DEFAULT);
} else {
return evaluate(value, query_options::DEFAULT);
}
} else {
return value;
}
@@ -934,7 +938,7 @@ prepare_expression(const expression& expr, data_dictionary::database db, const s
},
[&] (const collection_constructor& c) -> expression {
switch (c.style) {
case collection_constructor::style_type::list: return list_prepare_expression(c, db, keyspace, receiver);
case collection_constructor::style_type::list: return list_prepare_expression(c, db, keyspace, receiver, false);
case collection_constructor::style_type::set: return set_prepare_expression(c, db, keyspace, receiver);
case collection_constructor::style_type::map: return map_prepare_expression(c, db, keyspace, receiver);
}