2011-08-28 05:13:24 +00:00
|
|
|
#include <iostream>
|
|
|
|
#include <iomanip>
|
|
|
|
|
2017-05-23 18:58:38 +00:00
|
|
|
#include <common/DateLUT.h>
|
|
|
|
|
2013-06-17 13:35:05 +00:00
|
|
|
#include <Poco/ConsoleChannel.h>
|
2011-08-28 05:13:24 +00:00
|
|
|
|
2017-07-12 03:03:56 +00:00
|
|
|
#include <IO/ReadBufferFromFileDescriptor.h>
|
|
|
|
#include <IO/WriteBufferFromFileDescriptor.h>
|
2011-08-28 05:13:24 +00:00
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Storages/StorageLog.h>
|
2017-06-18 05:43:29 +00:00
|
|
|
#include <Storages/System/attachSystemTables.h>
|
2011-08-28 05:13:24 +00:00
|
|
|
|
2017-05-23 18:58:38 +00:00
|
|
|
#include <Interpreters/Context.h>
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Interpreters/loadMetadata.h>
|
|
|
|
#include <Interpreters/executeQuery.h>
|
|
|
|
#include <Databases/IDatabase.h>
|
|
|
|
#include <Databases/DatabaseOrdinary.h>
|
2011-08-28 05:13:24 +00:00
|
|
|
|
|
|
|
|
2016-03-19 01:18:49 +00:00
|
|
|
using namespace DB;
|
2011-08-28 05:13:24 +00:00
|
|
|
|
2017-12-02 02:47:12 +00:00
|
|
|
int main(int, char **)
|
2016-03-19 01:18:49 +00:00
|
|
|
try
|
2011-08-28 05:13:24 +00:00
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
Poco::AutoPtr<Poco::ConsoleChannel> channel = new Poco::ConsoleChannel(std::cerr);
|
|
|
|
Logger::root().setChannel(channel);
|
|
|
|
Logger::root().setLevel("trace");
|
2014-07-01 01:03:16 +00:00
|
|
|
|
2017-04-02 17:37:49 +00:00
|
|
|
/// Pre-initialize the `DateLUT` so that the first initialization does not affect the measured execution speed.
|
2017-04-01 07:20:54 +00:00
|
|
|
DateLUT::instance();
|
2014-07-01 01:03:16 +00:00
|
|
|
|
2017-06-19 20:31:23 +00:00
|
|
|
Context context = Context::createGlobal();
|
2019-07-08 02:14:32 +00:00
|
|
|
context.makeGlobalContext();
|
2011-08-28 05:13:24 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
context.setPath("./");
|
2014-07-01 01:03:16 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
loadMetadata(context);
|
2011-09-25 03:37:09 +00:00
|
|
|
|
2018-02-02 17:29:45 +00:00
|
|
|
DatabasePtr system = std::make_shared<DatabaseOrdinary>("system", "./metadata/system/", context);
|
2020-02-10 13:10:17 +00:00
|
|
|
DatabaseCatalog::instance().attachDatabase("system", system);
|
2019-10-10 20:47:47 +00:00
|
|
|
system->loadStoredObjects(context, false);
|
2020-02-10 13:10:17 +00:00
|
|
|
attachSystemTablesLocal(*DatabaseCatalog::instance().getSystemDatabase());
|
2017-04-01 07:20:54 +00:00
|
|
|
context.setCurrentDatabase("default");
|
2014-07-01 01:03:16 +00:00
|
|
|
|
2017-07-12 03:03:56 +00:00
|
|
|
ReadBufferFromFileDescriptor in(STDIN_FILENO);
|
|
|
|
WriteBufferFromFileDescriptor out(STDOUT_FILENO);
|
2011-10-31 06:37:12 +00:00
|
|
|
|
2020-03-03 15:32:41 +00:00
|
|
|
executeQuery(in, out, /* allow_into_outfile = */ false, context, {});
|
2011-08-28 05:13:24 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
return 0;
|
2011-08-28 05:13:24 +00:00
|
|
|
}
|
2016-03-19 01:18:49 +00:00
|
|
|
catch (const Exception & e)
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
std::cerr << e.what() << ", " << e.displayText() << std::endl
|
|
|
|
<< std::endl
|
|
|
|
<< "Stack trace:" << std::endl
|
2020-01-02 06:56:53 +00:00
|
|
|
<< e.getStackTraceString();
|
2017-04-01 07:20:54 +00:00
|
|
|
return 1;
|
2016-03-19 01:18:49 +00:00
|
|
|
}
|