From 69cf881947bcf43afa2009f571211e480527c280 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Tue, 1 Jun 2021 08:54:28 +0300 Subject: [PATCH] clickhouse-client: add echoOn/echoOff hints --- programs/client/Client.cpp | 3 +-- programs/client/TestHint.h | 10 +++++++--- tests/queries/0_stateless/01891_echo.reference | 4 ++++ tests/queries/0_stateless/01891_echo.sql | 4 ++++ 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/programs/client/Client.cpp b/programs/client/Client.cpp index 97d9f081dea..e2fe7921b8c 100644 --- a/programs/client/Client.cpp +++ b/programs/client/Client.cpp @@ -1110,8 +1110,7 @@ private: // Echo all queries if asked; makes for a more readable reference // file. - if (test_hint.echoQueries()) - echo_queries_ = true; + echo_queries_ = test_hint.echoQueries().value_or(echo_queries_); try { diff --git a/programs/client/TestHint.h b/programs/client/TestHint.h index 32dc1f0bc17..bffc9efbce5 100644 --- a/programs/client/TestHint.h +++ b/programs/client/TestHint.h @@ -59,13 +59,13 @@ public: int serverError() const { return server_error; } int clientError() const { return client_error; } - bool echoQueries() const { return echo; } + std::optional echoQueries() const { return echo; } private: const String & query; int server_error = 0; int client_error = 0; - bool echo = false; + std::optional echo; void parse(const String & hint, bool is_leading_hint) { @@ -88,7 +88,11 @@ private: } if (item == "echo") - echo = true; + echo.emplace(true); + if (item == "echoOn") + echo.emplace(true); + if (item == "echoOff") + echo.emplace(false); } } diff --git a/tests/queries/0_stateless/01891_echo.reference b/tests/queries/0_stateless/01891_echo.reference index 19c9b793902..1593069f395 100644 --- a/tests/queries/0_stateless/01891_echo.reference +++ b/tests/queries/0_stateless/01891_echo.reference @@ -2,3 +2,7 @@ -- { echo } select 1; 1 +2 +-- { echoOn } +select 2; +2 diff --git a/tests/queries/0_stateless/01891_echo.sql b/tests/queries/0_stateless/01891_echo.sql index 58f575a8f1a..fc46b64dc6b 100644 --- a/tests/queries/0_stateless/01891_echo.sql +++ b/tests/queries/0_stateless/01891_echo.sql @@ -1,3 +1,7 @@ select 1; -- { echo } select 1; +-- { echoOff } +select 2; +-- { echoOn } +select 2;