#pragma once #include #include #include #include #include #include #include #include namespace DB { /// Lightweight Application for clickhouse-local /// No networking, no extra configs and working directories, no pid and status files, no dictionaries, no logging. /// Quiet mode by default class LocalServer : public Poco::Util::Application, public Loggers { public: LocalServer(); void initialize(Poco::Util::Application & self) override; int main(const std::vector & args) override; void init(int argc, char ** argv); ~LocalServer() override; private: /** Composes CREATE subquery based on passed arguments (--structure --file --table and --input-format) * This query will be executed first, before queries passed through --query argument * Returns empty string if it cannot compose that query. */ std::string getInitialCreateTableQuery(); void tryInitPath(); void applyCmdOptions(ContextMutablePtr context); void applyCmdSettings(ContextMutablePtr context); void setupUsers(); void cleanup(); protected: SharedContextHolder shared_context; ContextMutablePtr global_context; /// Settings specified via command line args Settings cmd_settings; bool need_render_progress = false; bool written_first_block = false; ProgressIndication progress_indication; std::optional temporary_directory_to_delete; }; } int mainEntryClickHouseLocal(int argc, char ** argv);