提交 c2559805 编写于 作者: A Alexey Milovidov

dbms: development [#CONV-2944].

上级 d9a68ccf
......@@ -40,10 +40,11 @@ struct Context
StorageFactoryPtr storage_factory; /// Движки таблиц.
NamesAndTypesList columns; /// Столбцы текущей обрабатываемой таблицы.
Settings settings; /// Настройки выполнения запроса.
Logger * log; /// Логгер.
mutable SharedPtr<Poco::FastMutex> mutex; /// Для доступа и модификации разделяемых объектов.
Context() : databases(new Databases), functions(new Functions), mutex(new Poco::FastMutex) {}
Context() : databases(new Databases), functions(new Functions), log(&Logger::get("Context")), mutex(new Poco::FastMutex) {}
/** В сервере есть глобальный контекст.
* При соединении, он копируется в контекст сессии.
......@@ -63,6 +64,7 @@ struct Context
storage_factory = rhs.storage_factory;
columns = rhs.columns;
settings = rhs.settings;
log = rhs.log;
mutex = rhs.mutex;
}
};
......
......@@ -18,8 +18,7 @@
#include <DB/DataTypes/DataTypesNumberFixed.h>
#include <DB/Functions/FunctionsArithmetic.h>
#include <DB/Functions/FunctionsComparison.h>
#include <DB/Functions/FunctionsLibrary.h>
#include <DB/Parsers/ParserSelectQuery.h>
#include <DB/Parsers/formatAST.h>
......@@ -56,9 +55,7 @@ int main(int argc, char ** argv)
DB::Context context;
context.columns.push_back(DB::NameAndTypePair("number", new DB::DataTypeUInt64));
(*context.functions)["modulo"] = new DB::FunctionModulo;
(*context.functions)["equals"] = new DB::FunctionEquals;
(*context.functions)["notEquals"] = new DB::FunctionNotEquals;
context.functions = DB::FunctionsLibrary::get();
Poco::SharedPtr<DB::Expression> expression = new DB::Expression(ast, context);
......
......@@ -52,11 +52,18 @@ void loadMetadata(Context & context)
if (!it->isDirectory())
continue;
/// Для директории .svn
if (it.name().at(0) == '.')
continue;
executeCreateQuery("ATTACH DATABASE " + it.name(), context, it.name(), it->path());
/// Цикл по таблицам
for (Poco::DirectoryIterator jt(it->path()); jt != dir_end; ++jt)
{
if (jt->isDirectory())
continue;
/// Файлы имеют имена вида table_name.sql
if (jt.name().compare(jt.name().size() - 4, 4, ".sql"))
throw Exception("Incorrect file extension: " + jt.name() + " in metadata directory " + it->path(), ErrorCodes::INCORRECT_FILE_NAME);
......
......@@ -5,7 +5,10 @@
#include <DB/IO/WriteBufferFromOStream.h>
#include <DB/Columns/ColumnString.h>
#include <DB/DataTypes/DataTypesNumberFixed.h>
#include <DB/DataTypes/DataTypeString.h>
#include <DB/Functions/FunctionsLibrary.h>
......
#include <Poco/URI.h>
#include <Poco/NumberParser.h>
#include <DB/Core/ErrorCodes.h>
......@@ -34,6 +35,16 @@ void HTTPRequestHandler::processQuery(Poco::Net::NameValueCollection & params, s
WriteBufferFromOStream out(ostr);
Context context = server.global_context;
/// Некоторые настройки могут быть переопределены в запросе.
if (params.has("asynchronous"))
context.settings.asynchronous = 0 != Poco::NumberParser::parseUnsigned(params.get("asynchronous"));
if (params.has("max_block_size"))
context.settings.max_block_size = Poco::NumberParser::parseUnsigned(params.get("max_block_size"));
if (params.has("max_query_size"))
context.settings.max_query_size = Poco::NumberParser::parseUnsigned(params.get("max_query_size"));
if (params.has("max_threads"))
context.settings.max_threads = Poco::NumberParser::parseUnsigned(params.get("max_threads"));
executeQuery(in, out, context, query_plan);
if (query_plan)
......
......@@ -51,7 +51,10 @@ int Server::main(const std::vector<std::string> & args)
{
/// Заранее инициализируем DateLUT, чтобы первая инициализация потом не влияла на измеряемую скорость выполнения.
Yandex::DateLUTSingleton::instance();
/** Контекст содержит всё, что влияет на обработку запроса:
* настройки, набор функций, типов данных, агрегатных функций, баз данных...
*/
global_context.path = config.getString("path");
global_context.functions = FunctionsLibrary::get();
global_context.aggregate_function_factory = new AggregateFunctionFactory;
......@@ -64,6 +67,11 @@ int Server::main(const std::vector<std::string> & args)
(*global_context.databases)["system"]["numbers"] = new StorageSystemNumbers("numbers");
global_context.current_database = config.getString("default_database", "default");
global_context.settings.asynchronous = config.getBool("asynchronous", global_context.settings.asynchronous);
global_context.settings.max_block_size = config.getInt("max_block_size", global_context.settings.max_block_size);
global_context.settings.max_query_size = config.getInt("max_query_size", global_context.settings.max_query_size);
global_context.settings.max_threads = config.getInt("max_threads", global_context.settings.max_threads);
Poco::Net::ServerSocket socket(Poco::Net::SocketAddress("[::]:" + config.getString("http_port")));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册