2016-10-25 13:49:07 +00:00
|
|
|
#pragma once
|
|
|
|
|
2018-04-20 19:31:19 +00:00
|
|
|
#include <Interpreters/Settings.h>
|
2016-10-25 12:14:27 +00:00
|
|
|
#include <Poco/Util/Application.h>
|
|
|
|
#include <memory>
|
|
|
|
|
2018-04-20 15:32:40 +00:00
|
|
|
|
2016-10-25 12:14:27 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
class Context;
|
|
|
|
|
|
|
|
/// 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:
|
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
LocalServer();
|
2016-10-25 12:14:27 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
void initialize(Poco::Util::Application & self) override;
|
2016-10-25 12:14:27 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
int main(const std::vector<std::string> & args) override;
|
2016-10-25 12:14:27 +00:00
|
|
|
|
2018-04-20 19:31:19 +00:00
|
|
|
void init(int argc, char ** argv);
|
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
~LocalServer();
|
2016-10-25 12:14:27 +00:00
|
|
|
|
2016-10-28 17:38:32 +00:00
|
|
|
private:
|
|
|
|
|
2017-04-01 07:20:54 +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();
|
2016-10-28 17:38:32 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
void tryInitPath();
|
2018-04-20 15:32:40 +00:00
|
|
|
void applyCmdSettings(Context & context);
|
2017-04-01 07:20:54 +00:00
|
|
|
void attachSystemTables();
|
|
|
|
void processQueries();
|
|
|
|
void setupUsers();
|
2018-04-20 19:31:19 +00:00
|
|
|
|
|
|
|
std::string getHelpHeader() const;
|
|
|
|
std::string getHelpFooter() const;
|
2016-10-31 14:31:26 +00:00
|
|
|
|
2016-10-28 17:38:32 +00:00
|
|
|
protected:
|
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
std::unique_ptr<Context> context;
|
2018-04-20 19:31:19 +00:00
|
|
|
|
|
|
|
/// Settings specified via command line args
|
|
|
|
Settings cmd_settings;
|
2016-10-25 12:14:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|