Try make full compatibility

This commit is contained in:
Alexey Boykov 2021-09-02 16:28:17 +03:00
parent 24f47e9e3a
commit dbb697491e

View File

@ -215,11 +215,11 @@ try
std::optional<StatusFile> status; std::optional<StatusFile> status;
// Non-fuzzer mode: main function runs only one time, #ifdef FUZZING_MODE
// so first_time clauses does not affect anything
static bool first_time = true; static bool first_time = true;
if (first_time) if (first_time)
{ {
#endif
shared_context = Context::createShared(); shared_context = Context::createShared();
global_context = Context::createGlobal(shared_context.get()); global_context = Context::createGlobal(shared_context.get());
global_context->makeGlobalContext(); global_context->makeGlobalContext();
@ -315,15 +315,19 @@ try
{ {
attachSystemTables(global_context); attachSystemTables(global_context);
} }
#ifdef FUZZING_MODE
} }
#endif
/// processing queries /// processing queries
String initial_create_query = getInitialCreateTableQuery(); String initial_create_query = getInitialCreateTableQuery();
String queries_str = initial_create_query; String queries_str = initial_create_query;
#ifdef FUZZING_MODE
if (first_time) if (first_time)
{ {
#endif
if (config().has("query")) if (config().has("query"))
queries_str += config().getRawString("query"); queries_str += config().getRawString("query");
else else
@ -333,13 +337,19 @@ try
readStringUntilEOF(queries_from_file, in); readStringUntilEOF(queries_from_file, in);
queries_str += queries_from_file; queries_str += queries_from_file;
} }
#ifdef FUZZING_MODE
} }
#endif
const auto & settings = global_context->getSettingsRef(); const auto & settings = global_context->getSettingsRef();
#ifdef FUZZING_MODE
static std::vector<String> queries; static std::vector<String> queries;
if (first_time) if (first_time)
{ {
#else
std::vector<String> queries;
#endif
std::pair<const char *, bool> parse_res; std::pair<const char *, bool> parse_res;
#ifdef FUZZING_MODE #ifdef FUZZING_MODE
try try
@ -362,9 +372,11 @@ try
if (!parse_res.second) if (!parse_res.second)
throw Exception("Cannot parse and execute the following part of query: " + String(parse_res.first), ErrorCodes::SYNTAX_ERROR); throw Exception("Cannot parse and execute the following part of query: " + String(parse_res.first), ErrorCodes::SYNTAX_ERROR);
#ifdef FUZZING_MODE
} }
first_time = false; first_time = false;
#endif
/// Authenticate and create a context to execute queries. /// Authenticate and create a context to execute queries.
Session session{global_context, ClientInfo::Interface::LOCAL}; Session session{global_context, ClientInfo::Interface::LOCAL};
session.authenticate("default", "", {}); session.authenticate("default", "", {});
@ -445,6 +457,7 @@ try
status.reset(); status.reset();
cleanup(); cleanup();
#endif #endif
return Application::EXIT_OK; return Application::EXIT_OK;
} }
catch (const Exception & e) catch (const Exception & e)