Skip to content

Commit

Permalink
Kusto-phase2: Fixed the issue of conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
kashwy authored and bkuschel committed Jul 18, 2022
1 parent 6eaa14d commit 68ba390
Showing 1 changed file with 15 additions and 36 deletions.
51 changes: 15 additions & 36 deletions src/Client/ClientBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,6 @@ ASTPtr ClientBase::parseQuery(const char *& pos, const char * end, bool allow_mu
const auto & settings = global_context->getSettingsRef();
size_t max_length = 0;

auto begin = pos;

if (!allow_multi_statements)
max_length = settings.max_query_size;

Expand Down Expand Up @@ -336,14 +334,8 @@ ASTPtr ClientBase::parseQuery(const char *& pos, const char * end, bool allow_mu

if (!res)
{
if (sql_dialect != "kusto")
res = tryParseQuery(kql_parser, begin, end, message, true, "", allow_multi_statements, max_length, settings.max_parser_depth);

if (!res)
{
std::cerr << std::endl << message << std::endl << std::endl;
return nullptr;
}
std::cerr << std::endl << message << std::endl << std::endl;
return nullptr;
}
}
else
Expand Down Expand Up @@ -1895,21 +1887,9 @@ bool ClientBase::executeMultiQuery(const String & all_queries_text)

bool ClientBase::processQueryText(const String & text)
{
auto trimmed_input = trim(text, [](char c) { return isWhitespaceASCII(c) || c == ';'; });

if (exit_strings.end() != exit_strings.find(trimmed_input))
if (exit_strings.end() != exit_strings.find(trim(text, [](char c) { return isWhitespaceASCII(c) || c == ';'; })))
return false;

if (trimmed_input.starts_with("\\i"))
{
size_t skip_prefix_size = std::strlen("\\i");
auto file_name = trim(
trimmed_input.substr(skip_prefix_size, trimmed_input.size() - skip_prefix_size),
[](char c) { return isWhitespaceASCII(c); });

return processMultiQueryFromFile(file_name);
}

if (!is_multiquery)
{
assert(!query_fuzzer_runs);
Expand Down Expand Up @@ -2092,31 +2072,30 @@ void ClientBase::runInteractive()
}


bool ClientBase::processMultiQueryFromFile(const String & file_name)
{
String queries_from_file;

ReadBufferFromFile in(file_name);
readStringUntilEOF(queries_from_file, in);

return executeMultiQuery(queries_from_file);
}


void ClientBase::runNonInteractive()
{
if (delayed_interactive)
initQueryIdFormats();

if (!queries_files.empty())
{
auto process_multi_query_from_file = [&](const String & file)
{
String queries_from_file;

ReadBufferFromFile in(file);
readStringUntilEOF(queries_from_file, in);

return executeMultiQuery(queries_from_file);
};

for (const auto & queries_file : queries_files)
{
for (const auto & interleave_file : interleave_queries_files)
if (!processMultiQueryFromFile(interleave_file))
if (!process_multi_query_from_file(interleave_file))
return;

if (!processMultiQueryFromFile(queries_file))
if (!process_multi_query_from_file(queries_file))
return;
}

Expand Down

0 comments on commit 68ba390

Please sign in to comment.