From 0a85fc6524788692ee5ddfe8c0cdd4a2b53dfee3 Mon Sep 17 00:00:00 2001 From: Sema Checherinda Date: Wed, 4 Dec 2024 20:05:46 +0100 Subject: [PATCH] fix clickhouse_driver inserts --- src/Server/TCPHandler.cpp | 6 ++++++ .../0_stateless/03279_with_clickhouse_driver.py | 15 +++++++++++++++ .../03279_with_clickhouse_driver.reference | 1 + .../0_stateless/03279_with_clickhouse_driver.sh | 8 ++++++++ 4 files changed, 30 insertions(+) create mode 100644 tests/queries/0_stateless/03279_with_clickhouse_driver.py create mode 100644 tests/queries/0_stateless/03279_with_clickhouse_driver.reference create mode 100755 tests/queries/0_stateless/03279_with_clickhouse_driver.sh diff --git a/src/Server/TCPHandler.cpp b/src/Server/TCPHandler.cpp index 6d96905462a..5dd31b8af98 100644 --- a/src/Server/TCPHandler.cpp +++ b/src/Server/TCPHandler.cpp @@ -37,6 +37,7 @@ #include #include #include +#include "Common/StackTrace.h" #include #include #include @@ -1110,8 +1111,13 @@ void TCPHandler::processInsertQuery(QueryState & state) startInsertQuery(state); while (receivePacketsExpectDataConcurrentWithExecutor(state)) + { executor.push(std::move(state.block_for_insert)); + sendLogs(state); + sendInsertProfileEvents(state); + } + state.read_all_data = true; executor.finish(); diff --git a/tests/queries/0_stateless/03279_with_clickhouse_driver.py b/tests/queries/0_stateless/03279_with_clickhouse_driver.py new file mode 100644 index 00000000000..15c97436854 --- /dev/null +++ b/tests/queries/0_stateless/03279_with_clickhouse_driver.py @@ -0,0 +1,15 @@ +import sys +from clickhouse_driver import Client + + +def run(database): + client = Client("localhost",user="default",password="") + client.execute(f"CREATE TABLE IF NOT EXISTS {database}.test (x Int32) ENGINE = Memory") + client.execute(f"INSERT INTO {database}.test (x) VALUES", [{"x": 100}]) + result = client.execute(f"SELECT * FROM {database}.test") + print(result) + + +if __name__ == "__main__": + database = sys.argv[1] + run(database) diff --git a/tests/queries/0_stateless/03279_with_clickhouse_driver.reference b/tests/queries/0_stateless/03279_with_clickhouse_driver.reference new file mode 100644 index 00000000000..5ba0bbef3dc --- /dev/null +++ b/tests/queries/0_stateless/03279_with_clickhouse_driver.reference @@ -0,0 +1 @@ +[(100,)] diff --git a/tests/queries/0_stateless/03279_with_clickhouse_driver.sh b/tests/queries/0_stateless/03279_with_clickhouse_driver.sh new file mode 100755 index 00000000000..40493441d0d --- /dev/null +++ b/tests/queries/0_stateless/03279_with_clickhouse_driver.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +# Tags: no-fasttest + +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +# shellcheck source=../shell_config.sh +. "$CURDIR"/../shell_config.sh + +python3 03279_with_clickhouse_driver.py $CLICKHOUSE_DATABASE \ No newline at end of file