| 1479 | |
| 1480 | |
| 1481 | void TCPHandler::processOrdinaryQuery(QueryState & state) |
| 1482 | { |
| 1483 | auto & pipeline = state.io.pipeline; |
| 1484 | |
| 1485 | /// Send header-block, to allow client to prepare output format for data to send. |
| 1486 | { |
| 1487 | const auto & header = pipeline.getHeader(); |
| 1488 | |
| 1489 | if (!header.empty()) |
| 1490 | { |
| 1491 | sendData(state, header); |
| 1492 | } |
| 1493 | } |
| 1494 | |
| 1495 | { |
| 1496 | PullingAsyncPipelineExecutor executor(pipeline); |
| 1497 | pipeline.setConcurrencyControl(state.query_context->getSettingsRef()[Setting::use_concurrency_control]); |
| 1498 | CurrentMetrics::Increment query_thread_metric_increment{CurrentMetrics::QueryThread}; |
| 1499 | |
| 1500 | try |
| 1501 | { |
| 1502 | Block block; |
| 1503 | while (executor.pull(block, interactive_delay / 1000)) |
| 1504 | { |
| 1505 | bool stop_read_return_partial_result = false; |
| 1506 | { |
| 1507 | std::lock_guard lock(*callback_mutex); |
| 1508 | receivePacketsExpectCancel(state); |
| 1509 | stop_read_return_partial_result = state.stop_read_return_partial_result; |
| 1510 | } |
| 1511 | |
| 1512 | if (stop_read_return_partial_result) |
| 1513 | { |
| 1514 | executor.cancelReading(); |
| 1515 | } |
| 1516 | |
| 1517 | { |
| 1518 | std::lock_guard lock(*callback_mutex); |
| 1519 | |
| 1520 | if (after_send_progress.elapsed() / 1000 >= interactive_delay) |
| 1521 | { |
| 1522 | /// Some time passed and there is a progress. |
| 1523 | after_send_progress.restart(); |
| 1524 | sendProgress(state); |
| 1525 | sendSelectProfileEvents(state); |
| 1526 | } |
| 1527 | |
| 1528 | sendLogs(state); |
| 1529 | |
| 1530 | // Block might be empty in case of timeout, i.e. there is no data to process |
| 1531 | if (!block.empty() && !state.io.null_format) |
| 1532 | sendData(state, block); |
| 1533 | } |
| 1534 | } |
| 1535 | } |
| 1536 | catch (...) |
| 1537 | { |
| 1538 | executor.cancel(); |
nothing calls this directly
no test coverage detected