Fix details

This commit is contained in:
kssenii 2021-07-12 00:54:41 +03:00
parent 82dc284f4e
commit d58a5537c2
4 changed files with 18 additions and 11 deletions

View File

@ -1340,8 +1340,11 @@ private:
if (is_interactive)
{
std::cout << std::endl << processed_rows << " rows in set. Elapsed: " << progress_indication.elapsedSeconds() << " sec. ";
/// Write final progress if it makes sense to do so.
writeFinalProgress();
std::cout << std::endl << std::endl;
}
else if (print_time_to_stderr)
{

View File

@ -338,7 +338,6 @@ int LocalServer::childMainImpl()
/// Use the same query_id (and thread group) for all queries
CurrentThread::QueryScope query_scope_holder(query_context);
std::function<void()> finalize_progress;
if (need_render_progress)
{
/// Set progress callback, which can be run from multiple threads.
@ -349,12 +348,6 @@ int LocalServer::childMainImpl()
progress_indication.writeProgress();
});
/// Set finalizing callback for progress, which is called right before finalizing query output.
finalize_progress = [&]()
{
progress_indication.clearProgressOutput();
};
/// Set callback for file processing progress.
progress_indication.setFileProgressCallback(query_context);
}
@ -414,10 +407,19 @@ void LocalServer::processQuery(const String & query, std::exception_ptr exceptio
write_buf.next();
}
std::function<void()> finalize_progress;
if (need_render_progress)
{
/// Set finalizing callback for progress, which is called right before finalizing query output.
finalize_progress = [&]()
{
progress_indication.clearProgressOutput();
};
}
try
{
std::cerr << "executing query\n";
executeQuery(read_buf, write_buf, /* allow_into_outfile = */ true, context, {}, finalize_progress);
executeQuery(read_buf, write_buf, /* allow_into_outfile = */ true, query_context, {}, finalize_progress);
}
catch (...)
{

View File

@ -54,11 +54,12 @@ protected:
bool processQueryFromInteractive(const String & input) override
{
if (exit_strings.end() != exit_strings.find(trim(input, [](char c) { return isWhitespaceASCII(c) || c == ';'; })))
return false;
std::exception_ptr e;
processQuery(input, e);
/// For clickhouse local it is ok, to return true here - i.e. interactive
/// mode will only be stopped by exit command.
return true;
}

View File

@ -130,6 +130,7 @@ void IClient::highlight(const String & query, std::vector<replxx::Replxx::Color>
{TokenType::ClosingRoundBracket, Replxx::Color::BROWN},
{TokenType::OpeningSquareBracket, Replxx::Color::BROWN},
{TokenType::ClosingSquareBracket, Replxx::Color::BROWN},
{TokenType::DoubleColon, Replxx::Color::BROWN},
{TokenType::OpeningCurlyBrace, Replxx::Color::INTENSE},
{TokenType::ClosingCurlyBrace, Replxx::Color::INTENSE},