| 785 | |
| 786 | |
| 787 | void TCPHandler::processOrdinaryQuery() |
| 788 | { |
| 789 | OpenTelemetrySpanHolder span(__PRETTY_FUNCTION__); |
| 790 | |
| 791 | /// Pull query execution result, if exists, and send it to network. |
| 792 | if (state.io.in) |
| 793 | { |
| 794 | if (query_context->getSettingsRef().allow_experimental_query_deduplication) |
| 795 | sendPartUUIDs(); |
| 796 | |
| 797 | /// This allows the client to prepare output format |
| 798 | if (Block header = state.io.in->getHeader()) |
| 799 | sendData(header); |
| 800 | |
| 801 | /// Use of async mode here enables reporting progress and monitoring client cancelling the query |
| 802 | AsynchronousBlockInputStream async_in(state.io.in); |
| 803 | |
| 804 | async_in.readPrefix(); |
| 805 | while (true) |
| 806 | { |
| 807 | if (isQueryCancelled()) |
| 808 | { |
| 809 | async_in.cancel(false); |
| 810 | break; |
| 811 | } |
| 812 | |
| 813 | if (after_send_progress.elapsed() / 1000 >= query_context->getSettingsRef().interactive_delay) |
| 814 | { |
| 815 | /// Some time passed. |
| 816 | after_send_progress.restart(); |
| 817 | sendProgress(); |
| 818 | } |
| 819 | |
| 820 | sendLogs(); |
| 821 | |
| 822 | if (async_in.poll(query_context->getSettingsRef().interactive_delay / 1000)) |
| 823 | { |
| 824 | const auto block = async_in.read(); |
| 825 | if (!block) |
| 826 | break; |
| 827 | |
| 828 | if (!state.io.null_format) |
| 829 | sendData(block); |
| 830 | } |
| 831 | } |
| 832 | async_in.readSuffix(); |
| 833 | |
| 834 | /** When the data has run out, we send the profiling data and totals up to the terminating empty block, |
| 835 | * so that this information can be used in the suffix output of stream. |
| 836 | * If the request has been interrupted, then sendTotals and other methods should not be called, |
| 837 | * because we have not read all the data. |
| 838 | */ |
| 839 | if (!isQueryCancelled()) |
| 840 | { |
| 841 | sendTotals(state.io.in->getTotals()); |
| 842 | sendExtremes(state.io.in->getExtremes()); |
| 843 | sendProfileInfo(state.io.in->getProfileInfo()); |
| 844 | sendProgress(); |
nothing calls this directly
no test coverage detected