cql3: Make .validate_while_executing() accept query_processor
The schema_altering_statement declares this pure virtual method. This patch changes its first argument from proxy into query processor and fixes what compiler errors about. Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
This commit is contained in:
@@ -74,7 +74,7 @@ create_aggregate_statement::prepare_schema_mutations(query_processor& qp) const
|
||||
::shared_ptr<cql_transport::event::schema_change> ret;
|
||||
std::vector<mutation> m;
|
||||
|
||||
auto aggregate = dynamic_pointer_cast<functions::user_aggregate>(validate_while_executing(qp.proxy()));
|
||||
auto aggregate = dynamic_pointer_cast<functions::user_aggregate>(validate_while_executing(qp));
|
||||
if (aggregate) {
|
||||
m = co_await qp.get_migration_manager().prepare_new_aggregate_announcement(aggregate);
|
||||
ret = create_schema_change(*aggregate, true);
|
||||
|
||||
@@ -81,7 +81,7 @@ create_function_statement::prepare_schema_mutations(query_processor& qp) const {
|
||||
::shared_ptr<cql_transport::event::schema_change> ret;
|
||||
std::vector<mutation> m;
|
||||
|
||||
auto func = dynamic_pointer_cast<functions::user_function>(validate_while_executing(qp.proxy()));
|
||||
auto func = dynamic_pointer_cast<functions::user_function>(validate_while_executing(qp));
|
||||
|
||||
if (func) {
|
||||
m = co_await qp.get_migration_manager().prepare_new_function_announcement(func);
|
||||
|
||||
@@ -92,8 +92,8 @@ create_index_statement::validate(query_processor& qp, const service::client_stat
|
||||
_properties->validate();
|
||||
}
|
||||
|
||||
std::vector<::shared_ptr<index_target>> create_index_statement::validate_while_executing(service::storage_proxy& proxy) const {
|
||||
auto db = proxy.data_dictionary();
|
||||
std::vector<::shared_ptr<index_target>> create_index_statement::validate_while_executing(query_processor& qp) const {
|
||||
auto db = qp.proxy().data_dictionary();
|
||||
auto schema = validation::validate_column_family(db.real_database(), keyspace(), column_family());
|
||||
|
||||
if (schema->is_counter()) {
|
||||
@@ -279,7 +279,7 @@ void create_index_statement::validate_targets_for_multi_column_index(std::vector
|
||||
}
|
||||
|
||||
schema_ptr create_index_statement::build_index_schema(query_processor& qp) const {
|
||||
auto targets = validate_while_executing(qp.proxy());
|
||||
auto targets = validate_while_executing(qp);
|
||||
|
||||
data_dictionary::database db = qp.db();
|
||||
auto schema = db.find_schema(keyspace(), column_family());
|
||||
|
||||
@@ -94,7 +94,7 @@ private:
|
||||
const sstring& name,
|
||||
index_metadata_kind kind,
|
||||
const index_options_map& options);
|
||||
std::vector<::shared_ptr<index_target>> validate_while_executing(service::storage_proxy& proxy) const;
|
||||
std::vector<::shared_ptr<index_target>> validate_while_executing(query_processor& qp) const;
|
||||
schema_ptr build_index_schema(query_processor& qp) const;
|
||||
};
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ drop_aggregate_statement::prepare_schema_mutations(query_processor& qp) const {
|
||||
::shared_ptr<cql_transport::event::schema_change> ret;
|
||||
std::vector<mutation> m;
|
||||
|
||||
auto func = validate_while_executing(qp.proxy());
|
||||
auto func = validate_while_executing(qp);
|
||||
if (func) {
|
||||
auto user_aggr = dynamic_pointer_cast<functions::user_aggregate>(func);
|
||||
if (!user_aggr) {
|
||||
|
||||
@@ -41,7 +41,7 @@ drop_function_statement::prepare_schema_mutations(query_processor& qp) const {
|
||||
::shared_ptr<cql_transport::event::schema_change> ret;
|
||||
std::vector<mutation> m;
|
||||
|
||||
auto func = validate_while_executing(qp.proxy());
|
||||
auto func = validate_while_executing(qp);
|
||||
|
||||
if (func) {
|
||||
auto user_func = dynamic_pointer_cast<functions::user_function>(func);
|
||||
|
||||
@@ -77,9 +77,9 @@ void drop_type_statement::validate(query_processor& qp, const service::client_st
|
||||
// validation is done at execution time
|
||||
}
|
||||
|
||||
void drop_type_statement::validate_while_executing(service::storage_proxy& proxy) const {
|
||||
void drop_type_statement::validate_while_executing(query_processor& qp) const {
|
||||
try {
|
||||
auto&& ks = proxy.data_dictionary().find_keyspace(keyspace());
|
||||
auto&& ks = qp.proxy().data_dictionary().find_keyspace(keyspace());
|
||||
auto&& all_types = ks.metadata()->user_types().get_all_types();
|
||||
auto old = all_types.find(_name.get_user_type_name());
|
||||
if (old == all_types.end()) {
|
||||
@@ -153,7 +153,7 @@ const sstring& drop_type_statement::keyspace() const
|
||||
|
||||
future<std::pair<::shared_ptr<cql_transport::event::schema_change>, std::vector<mutation>>>
|
||||
drop_type_statement::prepare_schema_mutations(query_processor& qp) const {
|
||||
validate_while_executing(qp.proxy());
|
||||
validate_while_executing(qp);
|
||||
|
||||
data_dictionary::database db = qp.db();
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
|
||||
virtual std::unique_ptr<prepared_statement> prepare(data_dictionary::database db, cql_stats& stats) override;
|
||||
private:
|
||||
void validate_while_executing(service::storage_proxy&) const;
|
||||
void validate_while_executing(query_processor&) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "data_dictionary/data_dictionary.hh"
|
||||
#include "gms/feature_service.hh"
|
||||
#include "service/storage_proxy.hh"
|
||||
#include "cql3/query_processor.hh"
|
||||
|
||||
namespace cql3 {
|
||||
namespace statements {
|
||||
@@ -94,11 +95,11 @@ void create_function_statement_base::validate(query_processor& qp, const service
|
||||
// validation happens during execution
|
||||
}
|
||||
|
||||
shared_ptr<functions::function> create_function_statement_base::validate_while_executing(service::storage_proxy& proxy) const {
|
||||
create_arg_types(proxy);
|
||||
shared_ptr<functions::function> create_function_statement_base::validate_while_executing(query_processor& qp) const {
|
||||
create_arg_types(qp.proxy());
|
||||
auto old = functions::functions::find(_name, _arg_types);
|
||||
if (!old || _or_replace) {
|
||||
return create(proxy, old.get());
|
||||
return create(qp.proxy(), old.get());
|
||||
}
|
||||
if (!_if_not_exists) {
|
||||
throw exceptions::invalid_request_exception(format("The function '{}' already exists", old));
|
||||
@@ -114,8 +115,8 @@ void drop_function_statement_base::validate(query_processor& qp, const service::
|
||||
// validation happens during execution
|
||||
}
|
||||
|
||||
shared_ptr<functions::function> drop_function_statement_base::validate_while_executing(service::storage_proxy& proxy) const {
|
||||
create_arg_types(proxy);
|
||||
shared_ptr<functions::function> drop_function_statement_base::validate_while_executing(query_processor& qp) const {
|
||||
create_arg_types(qp.proxy());
|
||||
shared_ptr<functions::function> func;
|
||||
if (_args_present) {
|
||||
func = functions::functions::find(_name, _arg_types);
|
||||
|
||||
@@ -45,7 +45,7 @@ protected:
|
||||
function_statement(functions::function_name name, std::vector<shared_ptr<cql3_type::raw>> raw_arg_types);
|
||||
void create_arg_types(service::storage_proxy& proxy) const;
|
||||
data_type prepare_type(service::storage_proxy& proxy, cql3_type::raw &t) const;
|
||||
virtual shared_ptr<functions::function> validate_while_executing(service::storage_proxy&) const = 0;
|
||||
virtual shared_ptr<functions::function> validate_while_executing(query_processor&) const = 0;
|
||||
};
|
||||
|
||||
// common logic for creating UDF and UDA
|
||||
@@ -53,7 +53,7 @@ class create_function_statement_base : public function_statement {
|
||||
protected:
|
||||
virtual void validate(query_processor& qp, const service::client_state& state) const override;
|
||||
virtual shared_ptr<functions::function> create(service::storage_proxy& proxy, functions::function* old) const = 0;
|
||||
virtual shared_ptr<functions::function> validate_while_executing(service::storage_proxy&) const override;
|
||||
virtual shared_ptr<functions::function> validate_while_executing(query_processor&) const override;
|
||||
|
||||
bool _or_replace;
|
||||
bool _if_not_exists;
|
||||
@@ -66,7 +66,7 @@ protected:
|
||||
class drop_function_statement_base : public function_statement {
|
||||
protected:
|
||||
virtual void validate(query_processor&, const service::client_state& state) const override;
|
||||
virtual shared_ptr<functions::function> validate_while_executing(service::storage_proxy&) const override;
|
||||
virtual shared_ptr<functions::function> validate_while_executing(query_processor&) const override;
|
||||
|
||||
bool _args_present;
|
||||
bool _if_exists;
|
||||
|
||||
Reference in New Issue
Block a user