#pragma once #include #include #include #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 ClientBase, public Loggers { public: LocalServer() = default; void initialize(Poco::Util::Application & self) override; int main(const std::vector & /*args*/) override; protected: bool executeMultiQuery(const String & all_queries_text) override; void connect() override; void processError(const String & query) const override; String getName() const override { return "local"; } String getQueryTextPrefix() override; void printHelpMessage(const OptionsDescription & options_description) override; void addAndCheckOptions(OptionsDescription & options_description, po::variables_map & options, Arguments & arguments) override; void processOptions(const OptionsDescription & options_description, const CommandLineOptions & options, const std::vector &) override; void processConfig() 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 setupUsers(); void cleanup(); void applyCmdOptions(ContextMutablePtr context); void applyCmdSettings(ContextMutablePtr context); std::optional status; std::optional temporary_directory_to_delete; }; }