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-04-01 09:19:00 +00:00
|
|
|
#include <IO/ReadBufferFromIStream.h>
|
|
|
|
#include <IO/WriteBufferFromOStream.h>
|
2011-08-28 05:13:24 +00:00
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Storages/StorageLog.h>
|
|
|
|
#include <Storages/System/StorageSystemNumbers.h>
|
|
|
|
#include <Storages/System/StorageSystemOne.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
|
|
|
|
|
|
|
int main(int argc, char ** argv)
|
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-04-01 07:20:54 +00:00
|
|
|
Context context;
|
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
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
DatabasePtr system = std::make_shared<DatabaseOrdinary>("system", "./metadata/system/");
|
|
|
|
context.addDatabase("system", system);
|
|
|
|
system->loadTables(context, nullptr, false);
|
2017-06-06 17:06:14 +00:00
|
|
|
system->attachTable("one", StorageSystemOne::create("one"));
|
2017-04-01 07:20:54 +00:00
|
|
|
system->attachTable("numbers", StorageSystemNumbers::create("numbers"));
|
|
|
|
context.setCurrentDatabase("default");
|
2014-07-01 01:03:16 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
ReadBufferFromIStream in(std::cin);
|
|
|
|
WriteBufferFromOStream out(std::cout);
|
2011-10-31 06:37:12 +00:00
|
|
|
|
2017-04-01 07:20:54 +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
|
|
|
|
<< e.getStackTrace().toString();
|
|
|
|
return 1;
|
2016-03-19 01:18:49 +00:00
|
|
|
}
|