2021-09-07 23:55:17 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Interpreters/Context_fwd.h>
|
|
|
|
#include <Parsers/IAST.h>
|
|
|
|
|
|
|
|
#include <boost/noncopyable.hpp>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
enum class UserDefinedSQLObjectType
|
|
|
|
{
|
|
|
|
Function
|
|
|
|
};
|
|
|
|
|
|
|
|
class UserDefinedSQLObjectsLoader : private boost::noncopyable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static UserDefinedSQLObjectsLoader & instance();
|
|
|
|
UserDefinedSQLObjectsLoader();
|
|
|
|
|
|
|
|
void loadObjects(ContextPtr context);
|
2021-10-20 13:04:02 +00:00
|
|
|
void storeObject(ContextPtr context, UserDefinedSQLObjectType object_type, const String & object_name, const IAST & ast, bool replace);
|
2021-09-07 23:55:17 +00:00
|
|
|
void removeObject(ContextPtr context, UserDefinedSQLObjectType object_type, const String & object_name);
|
|
|
|
|
2021-10-14 13:15:39 +00:00
|
|
|
/// For ClickHouse local if path is not set we can disable loader.
|
|
|
|
void enable(bool enable_persistence);
|
|
|
|
|
2021-09-07 23:55:17 +00:00
|
|
|
private:
|
|
|
|
|
|
|
|
void loadUserDefinedObject(ContextPtr context, UserDefinedSQLObjectType object_type, const std::string_view & object_name, const String & file_path);
|
|
|
|
Poco::Logger * log;
|
2021-10-14 13:15:39 +00:00
|
|
|
bool enable_persistence = true;
|
2021-09-07 23:55:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|