Two more fixes for PVS-Studio

This commit is contained in:
Alexey Milovidov 2019-07-08 05:14:32 +03:00
parent 6577ecec90
commit f40b70884f
22 changed files with 24 additions and 3 deletions

View File

@ -61,6 +61,8 @@ public:
randomize(randomize_), max_iterations(max_iterations_), max_time(max_time_),
json_path(json_path_), settings(settings_), global_context(Context::createGlobal()), pool(concurrency)
{
global_context.makeGlobalContext();
std::cerr << std::fixed << std::setprecision(3);
/// This is needed to receive blocks with columns of AggregateFunction data type

View File

@ -218,6 +218,7 @@ private:
configReadClient(config(), home_path);
global_context.makeGlobalContext();
context.setApplicationType(Context::ApplicationType::CLIENT);
/// settings and limits could be specified in config file, but passed settings has higher priority

View File

@ -2171,6 +2171,7 @@ void ClusterCopierApp::mainImpl()
<< "revision " << ClickHouseRevision::get() << ")");
auto context = std::make_unique<Context>(Context::createGlobal());
context->makeGlobalContext();
SCOPE_EXIT(context->shutdown());
context->setConfig(loaded_config.configuration);

View File

@ -131,6 +131,7 @@ try
context = std::make_unique<Context>(Context::createGlobal());
context->makeGlobalContext();
context->setApplicationType(Context::ApplicationType::LOCAL);
tryInitPath();

View File

@ -1024,6 +1024,7 @@ try
}
Context context = Context::createGlobal();
context->makeGlobalContext();
ReadBufferFromFileDescriptor file_in(STDIN_FILENO);
WriteBufferFromFileDescriptor file_out(STDOUT_FILENO);

View File

@ -160,6 +160,7 @@ int ODBCBridge::main(const std::vector<std::string> & /*args*/)
http_params->setKeepAliveTimeout(keep_alive_timeout);
context = std::make_shared<Context>(Context::createGlobal());
context->makeGlobalContext();
auto server = Poco::Net::HTTPServer(
new HandlerFactory("ODBCRequestHandlerFactory-factory", keep_alive_timeout, context), server_pool, socket, http_params);

View File

@ -127,6 +127,7 @@ private:
std::unordered_map<std::string, std::vector<size_t>> query_indexes;
Context global_context = Context::createGlobal();
global_context.makeGlobalContext();
std::shared_ptr<ReportBuilder> report_builder;
std::string server_version;

View File

@ -187,6 +187,7 @@ int Server::main(const std::vector<std::string> & /*args*/)
* settings, available functions, data types, aggregate functions, databases...
*/
global_context = std::make_unique<Context>(Context::createGlobal());
global_context->makeGlobalContext();
global_context->setApplicationType(Context::ApplicationType::SERVER);
bool has_zookeeper = config().has("zookeeper");

View File

@ -68,6 +68,7 @@ try
CollapsingFinalBlockInputStream collapsed(inputs, descr, "Sign");
Context context = Context::createGlobal();
context.makeGlobalContext();
WriteBufferFromFileDescriptor out_buf(STDERR_FILENO);
BlockOutputStreamPtr output = context.getOutputFormat("TabSeparated", out_buf, block1);

View File

@ -35,6 +35,7 @@ try
ASTPtr ast = parseQuery(parser, input.data(), input.data() + input.size(), "", 0);
Context context = Context::createGlobal();
context.makeGlobalContext();
NamesAndTypesList source_columns = {{"number", std::make_shared<DataTypeUInt64>()}};
auto syntax_result = SyntaxAnalyzer(context, {}).analyze(ast, source_columns);

View File

@ -40,6 +40,7 @@ try
std::cerr << std::endl;
Context context = Context::createGlobal();
context.makeGlobalContext();
NamesAndTypesList source_columns = {{"number", std::make_shared<DataTypeUInt64>()}};
auto syntax_result = SyntaxAnalyzer(context, {}).analyze(ast, source_columns);

View File

@ -23,6 +23,7 @@ int main(int, char **)
try
{
Context context = Context::createGlobal();
context.makeGlobalContext();
Settings settings = context.getSettings();
context.setPath("./");

View File

@ -305,7 +305,6 @@ Context Context::createGlobal(std::unique_ptr<IRuntimeComponentsFactory> runtime
Context res;
res.shared = std::make_shared<ContextShared>(std::move(runtime_components_factory));
res.quota = std::make_shared<QuotaForIntervals>();
res.global_context = &res;
return res;
}

View File

@ -347,6 +347,7 @@ public:
void makeQueryContext() { query_context = this; }
void makeSessionContext() { session_context = this; }
void makeGlobalContext() { global_context = this; }
const Settings & getSettingsRef() const { return settings; }
Settings & getSettingsRef() { return settings; }

View File

@ -79,6 +79,7 @@ try
ASTPtr ast = parseQuery(parser, input.data(), input.data() + input.size(), "", 0);
Context context = Context::createGlobal();
context.makeGlobalContext();
context.setPath("./");
auto database = std::make_shared<DatabaseOrdinary>("test", "./metadata/test/", context);

View File

@ -47,6 +47,7 @@ int main(int argc, char ** argv)
std::cerr << std::endl;
Context context = Context::createGlobal();
context.makeGlobalContext();
NamesAndTypesList columns
{
{"x", std::make_shared<DataTypeInt16>()},

View File

@ -97,6 +97,7 @@ int main()
};
Context context = Context::createGlobal();
context.makeGlobalContext();
auto system_database = std::make_shared<DatabaseMemory>("system");
context.addDatabase("system", system_database);

View File

@ -1158,6 +1158,7 @@ bool run()
TestResult check(const TestEntry & entry)
{
static DB::Context context = DB::Context::createGlobal();
context.makeGlobalContext();
try
{

View File

@ -31,6 +31,7 @@ try
DateLUT::instance();
Context context = Context::createGlobal();
context.makeGlobalContext();
context.setPath("./");

View File

@ -29,6 +29,7 @@ struct State
registerFunctions();
DatabasePtr database = std::make_shared<DatabaseMemory>("test");
database->attachTable("table", StorageMemory::create("table", ColumnsDescription{columns}));
context.makeGlobalContext();
context.addDatabase("test", database);
context.setCurrentDatabase("test");
}

View File

@ -29,6 +29,7 @@ try
table->startup();
auto context = Context::createGlobal();
context.makeGlobalContext();
/// write into it
{

View File

@ -26,9 +26,10 @@ try
WriteBufferFromOStream out_buf(std::cout);
QueryProcessingStage::Enum stage = table->getQueryProcessingStage(Context::createGlobal());
auto context = Context::createGlobal();
context.makeGlobalContext();
QueryProcessingStage::Enum stage = table->getQueryProcessingStage(context);
LimitBlockInputStream input(table->read(column_names, {}, context, stage, 10, 1)[0], 10, 96);
BlockOutputStreamPtr out = FormatFactory::instance().getOutput("TabSeparated", out_buf, sample, context);