| 1328 | |
| 1329 | |
| 1330 | AsynchronousInsertQueue::PushResult TCPHandler::processAsyncInsertQuery(QueryState & state, AsynchronousInsertQueue & insert_queue) |
| 1331 | { |
| 1332 | using PushResult = AsynchronousInsertQueue::PushResult; |
| 1333 | |
| 1334 | startInsertQuery(state); |
| 1335 | Squashing squashing(std::make_shared<const Block>(state.input_header), 0, state.query_context->getSettingsRef()[Setting::async_insert_max_data_size]); |
| 1336 | |
| 1337 | while (receivePacketsExpectDataConcurrentWithExecutor(state)) |
| 1338 | { |
| 1339 | squashing.setHeader(state.block_for_insert.cloneEmpty()); |
| 1340 | |
| 1341 | squashing.add({state.block_for_insert.getColumns(), state.block_for_insert.rows()}); |
| 1342 | auto result_chunk = Squashing::squash(squashing.generate(/*flush_if_enough_size*/ true), squashing.getHeader()); |
| 1343 | |
| 1344 | { |
| 1345 | std::lock_guard lock(*callback_mutex); |
| 1346 | sendLogs(state); |
| 1347 | sendInsertProfileEvents(state); |
| 1348 | } |
| 1349 | |
| 1350 | if (result_chunk) |
| 1351 | { |
| 1352 | auto result = squashing.getHeader()->cloneWithColumns(result_chunk.detachColumns()); |
| 1353 | return PushResult |
| 1354 | { |
| 1355 | .status = PushResult::TOO_MUCH_DATA, |
| 1356 | .insert_block = std::move(result), |
| 1357 | }; |
| 1358 | } |
| 1359 | } |
| 1360 | |
| 1361 | Chunk result_chunk = Squashing::squash( |
| 1362 | squashing.flush(), |
| 1363 | squashing.getHeader()); |
| 1364 | if (!result_chunk) |
| 1365 | { |
| 1366 | return insert_queue.pushQueryWithBlock(state.parsed_query, squashing.getHeader()->cloneWithoutColumns(), state.query_context); |
| 1367 | } |
| 1368 | |
| 1369 | auto result = squashing.getHeader()->cloneWithColumns(result_chunk.detachColumns()); |
| 1370 | return insert_queue.pushQueryWithBlock(state.parsed_query, std::move(result), state.query_context); |
| 1371 | } |
| 1372 | |
| 1373 | |
| 1374 | void TCPHandler::processInsertQuery(QueryState & state) |
nothing calls this directly
no test coverage detected