mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
clickhouse-client: echo queries only after "{ echo }" hint
Before this patch clickhouse-client interprets the whole queries and if "{ echo }" found, it starts echoing queries, but this will make it impossible to skip some of lines.
This commit is contained in:
parent
ddbdf68814
commit
1c595c127f
@ -965,13 +965,10 @@ private:
|
||||
TestHint test_hint(test_mode, all_queries_text);
|
||||
if (test_hint.clientError() || test_hint.serverError())
|
||||
processTextAsSingleQuery("SET send_logs_level = 'fatal'");
|
||||
|
||||
// Echo all queries if asked; makes for a more readable reference
|
||||
// file.
|
||||
if (test_hint.echoQueries())
|
||||
echo_queries = true;
|
||||
}
|
||||
|
||||
bool echo_queries_ = echo_queries;
|
||||
|
||||
/// Several queries separated by ';'.
|
||||
/// INSERT data is ended by the end of line, not ';'.
|
||||
/// An exception is VALUES format where we also support semicolon in
|
||||
@ -1104,9 +1101,21 @@ private:
|
||||
continue;
|
||||
}
|
||||
|
||||
// Now we know for sure where the query ends.
|
||||
// Look for the hint in the text of query + insert data + trailing
|
||||
// comments,
|
||||
// e.g. insert into t format CSV 'a' -- { serverError 123 }.
|
||||
// Use the updated query boundaries we just calculated.
|
||||
TestHint test_hint(test_mode, std::string(this_query_begin, this_query_end - this_query_begin));
|
||||
|
||||
// Echo all queries if asked; makes for a more readable reference
|
||||
// file.
|
||||
if (test_hint.echoQueries())
|
||||
echo_queries_ = true;
|
||||
|
||||
try
|
||||
{
|
||||
processParsedSingleQuery();
|
||||
processParsedSingleQuery(echo_queries_);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
@ -1128,13 +1137,6 @@ private:
|
||||
adjustQueryEnd(this_query_end, all_queries_end, context->getSettingsRef().max_parser_depth);
|
||||
}
|
||||
|
||||
// Now we know for sure where the query ends.
|
||||
// Look for the hint in the text of query + insert data + trailing
|
||||
// comments,
|
||||
// e.g. insert into t format CSV 'a' -- { serverError 123 }.
|
||||
// Use the updated query boundaries we just calculated.
|
||||
TestHint test_hint(test_mode, std::string(this_query_begin, this_query_end - this_query_begin));
|
||||
|
||||
// Check whether the error (or its absence) matches the test hints
|
||||
// (or their absence).
|
||||
bool error_matches_hint = true;
|
||||
@ -1545,14 +1547,14 @@ private:
|
||||
// 'query_to_send' -- the query text that is sent to server,
|
||||
// 'full_query' -- for INSERT queries, contains the query and the data that
|
||||
// follow it. Its memory is referenced by ASTInsertQuery::begin, end.
|
||||
void processParsedSingleQuery()
|
||||
void processParsedSingleQuery(std::optional<bool> echo_queries_ = {})
|
||||
{
|
||||
resetOutput();
|
||||
client_exception.reset();
|
||||
server_exception.reset();
|
||||
have_error = false;
|
||||
|
||||
if (echo_queries)
|
||||
if (echo_queries_.value_or(echo_queries))
|
||||
{
|
||||
writeString(full_query, std_out);
|
||||
writeChar('\n', std_out);
|
||||
|
4
tests/queries/0_stateless/01891_echo.reference
Normal file
4
tests/queries/0_stateless/01891_echo.reference
Normal file
@ -0,0 +1,4 @@
|
||||
1
|
||||
-- { echo }
|
||||
select 1;
|
||||
1
|
3
tests/queries/0_stateless/01891_echo.sql
Normal file
3
tests/queries/0_stateless/01891_echo.sql
Normal file
@ -0,0 +1,3 @@
|
||||
select 1;
|
||||
-- { echo }
|
||||
select 1;
|
Loading…
Reference in New Issue
Block a user