mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-19 16:15:07 +00:00
With this it is possible to create user defined functions and aggregates and they are saved to disk and the schema change is propagated. It is just not possible to call them yet. Signed-off-by: Rafael Ávila de Espíndola <espindola@scylladb.com>
73 lines
2.6 KiB
C++
73 lines
2.6 KiB
C++
/*
|
|
* Copyright (C) 2019 ScyllaDB
|
|
*/
|
|
|
|
/*
|
|
* This file is part of Scylla.
|
|
*
|
|
* Scylla is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* Scylla is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with Scylla. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "cql3/statements/schema_altering_statement.hh"
|
|
#include "cql3/functions/user_function.hh"
|
|
|
|
namespace cql3 {
|
|
namespace statements {
|
|
|
|
class function_statement : public schema_altering_statement {
|
|
protected:
|
|
virtual future<> check_access(const service::client_state& state) override;
|
|
virtual void prepare_keyspace(const service::client_state& state) override;
|
|
functions::function_name _name;
|
|
std::vector<shared_ptr<cql3_type::raw>> _raw_arg_types;
|
|
std::vector<data_type> _arg_types;
|
|
static shared_ptr<cql_transport::event::schema_change> create_schema_change(
|
|
const functions::function& func, bool created);
|
|
function_statement(functions::function_name name, std::vector<shared_ptr<cql3_type::raw>> raw_arg_types);
|
|
void create_arg_types(service::storage_proxy& proxy);
|
|
data_type prepare_type(service::storage_proxy& proxy, cql3_type::raw &t);
|
|
};
|
|
|
|
// common logic for creating UDF and UDA
|
|
class create_function_statement_base : public function_statement {
|
|
protected:
|
|
virtual void validate(service::storage_proxy& proxy, const service::client_state& state) override;
|
|
virtual void create(service::storage_proxy& proxy, functions::function* old) = 0;
|
|
|
|
bool _or_replace;
|
|
bool _if_not_exists;
|
|
|
|
create_function_statement_base(functions::function_name name, std::vector<shared_ptr<cql3_type::raw>> 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(service::storage_proxy&, const service::client_state& state) override;
|
|
|
|
bool _args_present;
|
|
bool _if_exists;
|
|
|
|
shared_ptr<functions::function> _func{};
|
|
|
|
drop_function_statement_base(functions::function_name name, std::vector<shared_ptr<cql3_type::raw>> arg_types,
|
|
bool args_present, bool if_exists);
|
|
};
|
|
|
|
}
|
|
}
|