Skip to content

Commit

Permalink
Merge pull request ClickHouse#54190 from azat/client/restart-pager
Browse files Browse the repository at this point in the history
  • Loading branch information
vdimir authored Sep 4, 2023
2 parents 973f4de + a7cc481 commit fc7a8d0
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/Client/ClientBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1147,7 +1147,18 @@ void ClientBase::onEndOfStream()
bool is_running = false;
output_format->setStartTime(
clock_gettime_ns(CLOCK_MONOTONIC) - static_cast<UInt64>(progress_indication.elapsedSeconds() * 1000000000), is_running);
output_format->finalize();

try
{
output_format->finalize();
}
catch (...)
{
/// Format should be reset to make it work for subsequent query
/// (otherwise it will throw again in resetOutput())
output_format.reset();
throw;
}
}

resetOutput();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
15 changes: 15 additions & 0 deletions tests/queries/0_stateless/02871_clickhouse_client_restart_pager.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=../shell_config.sh
. "$CUR_DIR"/../shell_config.sh

# head by default print 10 rows, but it is not enough to query 11 rows, since
# we need to overflow the default pipe size, hence just 1 million of rows (it
# should be around 6 MiB in text representation, should be definitelly enough).
$CLICKHOUSE_CLIENT --ignore-error -nm --pager head -q "
select * from numbers(1e6); -- { clientError CANNOT_WRITE_TO_FILE_DESCRIPTOR }
select * from numbers(1e6); -- { clientError CANNOT_WRITE_TO_FILE_DESCRIPTOR }
"

exit 0

0 comments on commit fc7a8d0

Please sign in to comment.