1 | #pragma once |
---|---|
2 | |
3 | #include <Core/Settings.h> |
4 | #include <Poco/Util/Application.h> |
5 | #include <memory> |
6 | #include <loggers/Loggers.h> |
7 | |
8 | |
9 | namespace DB |
10 | { |
11 | |
12 | class Context; |
13 | |
14 | /// Lightweight Application for clickhouse-local |
15 | /// No networking, no extra configs and working directories, no pid and status files, no dictionaries, no logging. |
16 | /// Quiet mode by default |
17 | class LocalServer : public Poco::Util::Application, public Loggers |
18 | { |
19 | public: |
20 | LocalServer(); |
21 | |
22 | void initialize(Poco::Util::Application & self) override; |
23 | |
24 | int main(const std::vector<std::string> & args) override; |
25 | |
26 | void init(int argc, char ** argv); |
27 | |
28 | ~LocalServer() override; |
29 | |
30 | private: |
31 | /** Composes CREATE subquery based on passed arguments (--structure --file --table and --input-format) |
32 | * This query will be executed first, before queries passed through --query argument |
33 | * Returns empty string if it cannot compose that query. |
34 | */ |
35 | std::string getInitialCreateTableQuery(); |
36 | |
37 | void tryInitPath(); |
38 | void applyCmdOptions(); |
39 | void applyCmdSettings(); |
40 | void attachSystemTables(); |
41 | void processQueries(); |
42 | void setupUsers(); |
43 | |
44 | std::string getHelpHeader() const; |
45 | std::string getHelpFooter() const; |
46 | |
47 | protected: |
48 | std::unique_ptr<Context> context; |
49 | |
50 | /// Settings specified via command line args |
51 | Settings cmd_settings; |
52 | }; |
53 | |
54 | } |
55 |