/* * Copyright (C) 2019-present ScyllaDB */ /* * SPDX-License-Identifier: AGPL-3.0-or-later */ #pragma once #include "cql3/statements/schema_altering_statement.hh" #include "cql3/functions/function_name.hh" #include "cql3/cql3_type.hh" namespace cql3 { namespace functions { class function; } // namespace functions namespace statements { class function_statement : public schema_altering_statement { protected: virtual future<> check_access(query_processor& qp, const service::client_state& state) const override; virtual void prepare_keyspace(const service::client_state& state) override; functions::function_name _name; std::vector> _raw_arg_types; mutable std::vector _arg_types; static shared_ptr create_schema_change( const functions::function& func, bool created); function_statement(functions::function_name name, std::vector> raw_arg_types); void create_arg_types(query_processor& qp) const; data_type prepare_type(query_processor& qp, cql3_type::raw &t) const; virtual shared_ptr validate_while_executing(query_processor&) const = 0; }; // common logic for creating UDF and UDA 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 create(query_processor& qp, functions::function* old) const = 0; virtual shared_ptr validate_while_executing(query_processor&) const override; bool _or_replace; bool _if_not_exists; create_function_statement_base(functions::function_name name, std::vector> raw_arg_types, bool or_replace, bool if_not_exists); }; // common logic for dropping UDF and UDA class drop_function_statement_base : public function_statement { protected: virtual void validate(query_processor&, const service::client_state& state) const override; virtual shared_ptr validate_while_executing(query_processor&) const override; bool _args_present; bool _if_exists; drop_function_statement_base(functions::function_name name, std::vector> arg_types, bool args_present, bool if_exists); }; } }