mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-16 19:32:07 +00:00
33 lines
643 B
C++
33 lines
643 B
C++
#pragma once
|
|
|
|
#include <Interpreters/Context.h>
|
|
|
|
struct ContextHolder
|
|
{
|
|
DB::SharedContextHolder shared_context;
|
|
DB::ContextMutablePtr context;
|
|
|
|
ContextHolder()
|
|
: shared_context(DB::Context::createShared())
|
|
, context(DB::Context::createGlobal(shared_context.get()))
|
|
{
|
|
context->makeGlobalContext();
|
|
context->setPath("./");
|
|
}
|
|
|
|
ContextHolder(ContextHolder &&) = default;
|
|
|
|
void destroy()
|
|
{
|
|
context->shutdown();
|
|
context.reset();
|
|
shared_context.reset();
|
|
}
|
|
};
|
|
|
|
const ContextHolder & getContext();
|
|
|
|
ContextHolder & getMutableContext();
|
|
|
|
void destroyContext();
|