cql3: expr: Add is_empty_restriction

Add a function to check whether
an expression restricts anything at all.

Signed-off-by: Jan Ciolek <jan.ciolek@scylladb.com>
This commit is contained in:
Jan Ciolek
2022-06-28 08:09:34 +02:00
parent 228b344d9c
commit 177ba9b9db
2 changed files with 12 additions and 0 deletions

View File

@@ -2407,5 +2407,14 @@ single_column_restrictions_map get_single_column_restrictions_map(const expressi
return result;
}
bool is_empty_restriction(const expression& e) {
bool contains_non_conjunction = recurse_until(e, [&](const expression& e) -> bool {
return !is<conjunction>(e);
});
return !contains_non_conjunction;
}
} // namespace expr
} // namespace cql3

View File

@@ -759,6 +759,9 @@ using single_column_restrictions_map = std::map<const column_definition*, expres
// Extracts map of single column restrictions for each column from expression
single_column_restrictions_map get_single_column_restrictions_map(const expression&);
// Checks whether this expression is empty - doesn't restrict anything
bool is_empty_restriction(const expression&);
} // namespace expr
} // namespace cql3