cql3: expr: Remove shape_type from bind_variable
shape_type was used in prepare_expression to differentiate between a few cases and create the correct receivers. This was used by the relation class. Now creating the correct receiver has been delegated to the caller of prepare_expression and all bind_variables can be handled in the same simple way. shape_type is not needed anymore. Not having it is better because it simplifies things. Signed-off-by: cvybhu <jan.ciolek@scylladb.com>
This commit is contained in:
33
cql3/Cql.g
33
cql3/Cql.g
@@ -153,30 +153,11 @@ struct uninitialized {
|
||||
|
||||
bind_variable new_bind_variables(shared_ptr<cql3::column_identifier> name)
|
||||
{
|
||||
auto marker = bind_variable{bind_variable::shape_type::scalar, _bind_variables.size()};
|
||||
auto marker = bind_variable{_bind_variables.size()};
|
||||
_bind_variables.push_back(name);
|
||||
return marker;
|
||||
}
|
||||
|
||||
bind_variable new_in_bind_variables(shared_ptr<cql3::column_identifier> name) {
|
||||
auto marker = bind_variable{bind_variable::shape_type::scalar_in, _bind_variables.size()};
|
||||
_bind_variables.push_back(std::move(name));
|
||||
return marker;
|
||||
}
|
||||
|
||||
bind_variable new_tuple_bind_variables(shared_ptr<cql3::column_identifier> name)
|
||||
{
|
||||
auto marker = bind_variable{bind_variable::shape_type::tuple, _bind_variables.size()};
|
||||
_bind_variables.push_back(std::move(name));
|
||||
return marker;
|
||||
}
|
||||
|
||||
bind_variable new_tuple_in_bind_variables(shared_ptr<cql3::column_identifier> name)
|
||||
{
|
||||
auto marker = bind_variable{bind_variable::shape_type::tuple_in, _bind_variables.size()};
|
||||
_bind_variables.push_back(std::move(name));
|
||||
return marker;
|
||||
}
|
||||
|
||||
void set_error_listener(listener_type& listener) {
|
||||
this->listener = &listener;
|
||||
@@ -1726,8 +1707,8 @@ relation[std::vector<expression>& clauses]
|
||||
;
|
||||
|
||||
inMarker returns [expression marker]
|
||||
: QMARK { $marker = new_in_bind_variables(nullptr); }
|
||||
| ':' name=ident { $marker = new_in_bind_variables(name); }
|
||||
: QMARK { $marker = new_bind_variables(nullptr); }
|
||||
| ':' name=ident { $marker = new_bind_variables(name); }
|
||||
;
|
||||
|
||||
tupleOfIdentifiers returns [tuple_constructor tup]
|
||||
@@ -1747,8 +1728,8 @@ tupleOfTupleLiterals returns [std::vector<expression> literals]
|
||||
;
|
||||
|
||||
markerForTuple returns [expression marker]
|
||||
: QMARK { $marker = new_tuple_bind_variables(nullptr); }
|
||||
| ':' name=ident { $marker = new_tuple_bind_variables(name); }
|
||||
: QMARK { $marker = new_bind_variables(nullptr); }
|
||||
| ':' name=ident { $marker = new_bind_variables(name); }
|
||||
;
|
||||
|
||||
tupleOfMarkersForTuples returns [std::vector<expression> markers]
|
||||
@@ -1756,8 +1737,8 @@ tupleOfMarkersForTuples returns [std::vector<expression> markers]
|
||||
;
|
||||
|
||||
inMarkerForTuple returns [expression marker]
|
||||
: QMARK { $marker = new_tuple_in_bind_variables(nullptr); }
|
||||
| ':' name=ident { $marker = new_tuple_in_bind_variables(name); }
|
||||
: QMARK { $marker = new_bind_variables(nullptr); }
|
||||
| ':' name=ident { $marker = new_bind_variables(name); }
|
||||
;
|
||||
|
||||
// The comparator_type rule is used for users' queries (internal=false)
|
||||
|
||||
@@ -321,9 +321,6 @@ struct null {
|
||||
};
|
||||
|
||||
struct bind_variable {
|
||||
enum class shape_type { scalar, scalar_in, tuple, tuple_in };
|
||||
// FIXME: infer shape from expression rather than from grammar
|
||||
shape_type shape;
|
||||
int32_t bind_index;
|
||||
|
||||
// Describes where this bound value will be assigned.
|
||||
|
||||
@@ -613,7 +613,6 @@ bind_variable
|
||||
bind_variable_scalar_prepare_expression(const bind_variable& bv, data_dictionary::database db, const sstring& keyspace, lw_shared_ptr<column_specification> receiver)
|
||||
{
|
||||
return bind_variable {
|
||||
.shape = bind_variable::shape_type::scalar,
|
||||
.bind_index = bv.bind_index,
|
||||
.receiver = receiver
|
||||
};
|
||||
@@ -876,7 +875,6 @@ test_assignment(const expression& expr, data_dictionary::database db, const sstr
|
||||
return null_test_assignment(db, keyspace, receiver);
|
||||
},
|
||||
[&] (const bind_variable& bv) -> test_result {
|
||||
// Same for all bind_variable::shape:s
|
||||
return bind_variable_test_assignment(bv, db, keyspace, receiver);
|
||||
},
|
||||
[&] (const untyped_constant& uc) -> test_result {
|
||||
|
||||
@@ -21,7 +21,6 @@ using namespace cql3::expr;
|
||||
|
||||
bind_variable new_bind_variable(int bind_index) {
|
||||
return bind_variable {
|
||||
.shape = bind_variable::shape_type::scalar,
|
||||
.bind_index = bind_index,
|
||||
.receiver = nullptr
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user