cql3: Replace parition_key_restrictions->empty()

To remove partition_key_restrictions all of its
methods have to be implemented using the new expression
representation.

The first to go is empty() as it's easy to implement.

Signed-off-by: Jan Ciolek <jan.ciolek@scylladb.com>
This commit is contained in:
Jan Ciolek
2022-06-28 08:09:43 +02:00
parent e6e502e6e8
commit 7f620cfa29
3 changed files with 9 additions and 3 deletions

View File

@@ -754,7 +754,7 @@ void statement_restrictions::add_single_column_parition_key_restriction(const ex
}
void statement_restrictions::add_token_partition_key_restriction(const expr::binary_operator& restr) {
if (!expr::is_empty_restriction(_new_partition_key_restrictions) && !has_token(_new_partition_key_restrictions)) {
if (!partition_key_restrictions_is_empty() && !has_token(_new_partition_key_restrictions)) {
throw exceptions::invalid_request_exception(
format("Columns \"{}\" cannot be restricted by both a normal relation and a token relation",
join(", ", expr::get_sorted_column_defs(_new_partition_key_restrictions))));
@@ -863,7 +863,7 @@ void statement_restrictions::process_partition_key_restrictions(bool for_view, b
// components must have a EQ. Only the last partition key component can be in IN relation.
if (has_token(_partition_key_restrictions->expression)) {
_is_key_range = true;
} else if (_partition_key_restrictions->empty()) {
} else if (expr::is_empty_restriction(_new_partition_key_restrictions)) {
_is_key_range = true;
_uses_secondary_indexing = _has_queriable_pk_index;
}
@@ -884,6 +884,10 @@ bool statement_restrictions::has_partition_key_unrestricted_components() const {
return _partition_key_restrictions->has_unrestricted_components(*_schema);
}
bool statement_restrictions::partition_key_restrictions_is_empty() const {
return expr::is_empty_restriction(_new_partition_key_restrictions);
}
bool statement_restrictions::has_unrestricted_clustering_columns() const {
return _clustering_columns_restrictions->has_unrestricted_components(*_schema);
}

View File

@@ -223,6 +223,8 @@ public:
*/
bool has_partition_key_unrestricted_components() const;
bool partition_key_restrictions_is_empty() const;
/**
* Checks if the clustering key has some unrestricted components.
* @return <code>true</code> if the clustering key has some unrestricted components, <code>false</code> otherwise.

View File

@@ -858,7 +858,7 @@ primary_key_select_statement::primary_key_select_statement(schema_ptr schema, ui
{
if (_ks_sel == ks_selector::NONSYSTEM) {
if (_restrictions->need_filtering() ||
_restrictions->get_partition_key_restrictions()->empty() ||
_restrictions->partition_key_restrictions_is_empty() ||
(has_token(_restrictions->get_partition_key_restrictions()->expression) &&
!find(_restrictions->get_partition_key_restrictions()->expression, expr::oper_t::EQ))) {
_range_scan = true;