Skip to content

Commit ca74be0

Browse files
upgrade protocol 54456
1 parent 6530d56 commit ca74be0

3 files changed

Lines changed: 39 additions & 8 deletions

File tree

asynch/proto/connection.py

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -828,30 +828,49 @@ async def process_insert_query(
828828
await self.send_query(query_without_data, query_id=query_id)
829829
await self.send_external_tables(external_tables, types_check=types_check)
830830

831-
sample_block = await self.receive_sample_block()
831+
sample_block = await self._receive_sample_block()
832832
if sample_block:
833833
rv = await self.send_data(
834834
sample_block, data, types_check=types_check, columnar=columnar
835835
)
836-
packet = await self._receive_packet()
837-
if packet.exception:
838-
raise packet.exception
836+
await self._receive_end_of_stream()
837+
839838
return rv
840839

841-
async def receive_sample_block(self):
840+
async def _receive_sample_block(self):
842841
while True:
843842
packet = await self._receive_packet()
844843

845844
if packet.type == ServerPacket.DATA:
846845
return packet.block
847-
848846
elif packet.type == ServerPacket.EXCEPTION:
849847
raise packet.exception
850848
elif packet.type == ServerPacket.LOG:
851-
self.log_block(packet.block)
849+
pass
852850
elif packet.type == ServerPacket.TABLE_COLUMNS:
853851
pass
852+
else:
853+
message = self.unexpected_packet_message(
854+
"Data, Exception or TableColumns", packet.type
855+
)
856+
raise UnexpectedPacketFromServerError(message)
854857

858+
async def _receive_end_of_stream(self):
859+
while True:
860+
packet = await self._receive_packet()
861+
862+
if packet.type == ServerPacket.END_OF_STREAM:
863+
return
864+
elif packet.type == ServerPacket.EXCEPTION:
865+
raise packet.exception
866+
elif packet.type == ServerPacket.LOG:
867+
pass
868+
elif packet.type == ServerPacket.PROFILE_INFO:
869+
pass
870+
elif packet.type == ServerPacket.PROFILE_EVENTS:
871+
pass
872+
elif packet.type == ServerPacket.PROGRESS:
873+
pass
855874
else:
856875
message = self.unexpected_packet_message(
857876
"Data, Exception or TableColumns", packet.type

asynch/proto/constants.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
DBMS_MIN_PROTOCOL_VERSION_WITH_INCREMENTAL_PROFILE_EVENTS = 54451
3333
DBMS_MIN_REVISION_WITH_PARALLEL_REPLICAS = 54453
3434
DBMS_MIN_REVISION_WITH_CUSTOM_SERIALIZATION = 54454
35+
DBMS_MIN_PROTOCOL_VERSION_WITH_PROFILE_EVENTS_IN_INSERT = 54456
3536

3637
# Timeouts
3738
DBMS_DEFAULT_CONNECT_TIMEOUT_SEC = 10
@@ -47,7 +48,7 @@
4748
CLIENT_VERSION_MAJOR = 20
4849
CLIENT_VERSION_MINOR = 10
4950
CLIENT_VERSION_PATCH = 2
50-
CLIENT_REVISION = 54454
51+
CLIENT_REVISION = 54456
5152

5253
BUFFER_SIZE = 1048576
5354

tests/test_proto/test_proto_connection.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,17 @@ async def test_execute_with_missing_arg(proto_conn: ProtoConnection):
103103
await proto_conn.execute(query, args={"foo": 1})
104104

105105

106+
@pytest.mark.asyncio
107+
async def test_large_insert(proto_conn: ProtoConnection):
108+
data = [(1,)] * 10_000
109+
async with create_table(proto_conn, "a Int64"):
110+
await proto_conn.execute(
111+
"INSERT INTO test.test (a) VALUES", data, settings={"insert_block_size": 1000}
112+
)
113+
rv = await proto_conn.execute("SELECT * FROM test.test")
114+
assert rv == data
115+
116+
106117
@asynccontextmanager
107118
async def create_table(connection, spec):
108119
await connection.execute("DROP TABLE IF EXISTS test.test")

0 commit comments

Comments
 (0)