ClickHouse/programs/local/LocalServer.h

66 lines
1.9 KiB
C++
Raw Normal View History

#pragma once
2021-07-29 12:48:07 +00:00
#include <Client/ClientBase.h>
2021-08-17 19:59:51 +00:00
#include <Client/LocalConnection.h>
2021-07-23 20:54:49 +00:00
#include <Common/ProgressIndication.h>
#include <Common/StatusFile.h>
2021-08-01 22:12:15 +00:00
#include <Common/InterruptListener.h>
2021-07-29 12:48:07 +00:00
#include <loggers/Loggers.h>
#include <Core/Settings.h>
#include <Interpreters/Context.h>
2021-07-29 12:48:07 +00:00
#include <filesystem>
#include <memory>
#include <optional>
2021-07-23 20:54:49 +00:00
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
2021-07-22 21:27:26 +00:00
class LocalServer : public ClientBase, public Loggers
{
public:
2021-07-23 20:56:47 +00:00
LocalServer() = default;
2021-09-11 11:34:22 +00:00
2021-07-23 20:56:47 +00:00
void initialize(Poco::Util::Application & self) override;
2021-09-11 11:34:22 +00:00
2021-09-04 18:19:01 +00:00
int main(const std::vector<String> & /*args*/) override;
2021-07-23 20:56:47 +00:00
protected:
2021-09-04 18:19:01 +00:00
bool executeMultiQuery(const String & all_queries_text) override;
2021-08-21 10:55:54 +00:00
2021-09-04 18:19:01 +00:00
void connect() override;
2021-08-19 11:07:47 +00:00
void processError(const String & query) const override;
2021-09-19 21:42:28 +00:00
String getName() const override { return "local"; }
2021-08-23 08:50:12 +00:00
2021-07-29 12:48:07 +00:00
void printHelpMessage(const OptionsDescription & options_description) override;
2021-07-28 12:56:11 +00:00
void addOptions(OptionsDescription & options_description) override;
2021-08-23 08:50:12 +00:00
void processOptions(const OptionsDescription & options_description, const CommandLineOptions & options,
2021-07-29 12:48:07 +00:00
const std::vector<Arguments> &) override;
void processConfig() override;
2021-07-11 23:17:14 +00:00
private:
2021-07-23 20:56:47 +00:00
/** 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();
2021-08-19 11:07:47 +00:00
void applyCmdOptions(ContextMutablePtr context);
void applyCmdSettings(ContextMutablePtr context);
2021-02-07 17:32:45 +00:00
2021-07-23 20:54:49 +00:00
std::optional<StatusFile> status;
std::optional<std::filesystem::path> temporary_directory_to_delete;
};
}