ClickHouse/tests/queries/0_stateless/02930_client_file_log_comment.sh
Azat Khuzhin 699d11628a Fix adjusting log_comment in case of multiple files passed
Previously, due to adjusting global_context and checking it as well, in
case of multiple files the log_comment will be adjusted only the first
time. Fix this by caching does user passed the log_comment explicitly or
not.

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2023-12-04 10:02:24 +01:00

25 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# reset --log_comment
CLICKHOUSE_LOG_COMMENT=
# shellcheck source=../shell_config.sh
. "$CUR_DIR"/../shell_config.sh
file1="$CUR_DIR/clickhouse.${CLICKHOUSE_DATABASE}-1.sql"
echo -n 'select 42' >> "$file1"
file2="$CUR_DIR/clickhouse.${CLICKHOUSE_DATABASE}-2.sql"
echo -n 'select 4242' >> "$file2"
$CLICKHOUSE_CLIENT --queries-file "$file1" "$file2" <<<'select 42'
$CLICKHOUSE_CLIENT --log_comment foo --queries-file /dev/stdin <<<'select 424242'
$CLICKHOUSE_CLIENT -nm -q "
system flush logs;
select query, log_comment from system.query_log where current_database = '$CLICKHOUSE_DATABASE' and event_date >= yesterday() and query = 'select 42' and type != 'QueryStart';
select query, log_comment from system.query_log where current_database = '$CLICKHOUSE_DATABASE' and event_date >= yesterday() and query = 'select 4242' and type != 'QueryStart';
select query, log_comment from system.query_log where current_database = '$CLICKHOUSE_DATABASE' and event_date >= yesterday() and query = 'select 424242\n' and type != 'QueryStart';
" | sed "s#$CUR_DIR/##"
rm "$file1" "$file2"