| 1278 | } |
| 1279 | |
| 1280 | void Call::generateOutput() |
| 1281 | { |
| 1282 | /// We add query_id and time_zone to the first result anyway. |
| 1283 | addQueryDetailsToResult(); |
| 1284 | |
| 1285 | if (!io.pipeline.initialized() || io.pipeline.pushing()) |
| 1286 | return; |
| 1287 | |
| 1288 | Block header; |
| 1289 | if (io.pipeline.pulling()) |
| 1290 | header = io.pipeline.getHeader(); |
| 1291 | |
| 1292 | if (output_compression_method != CompressionMethod::None) |
| 1293 | output.resize(DBMS_DEFAULT_BUFFER_SIZE); /// Must have enough space for compressed data. |
| 1294 | write_buffer = std::make_unique<WriteBufferFromVector<PODArray<char>>>(output); |
| 1295 | nested_write_buffer = static_cast<WriteBufferFromVector<PODArray<char>> *>(write_buffer.get()); |
| 1296 | if (output_compression_method != CompressionMethod::None) |
| 1297 | { |
| 1298 | write_buffer = wrapWriteBufferWithCompressionMethod(std::move(write_buffer), output_compression_method, output_compression_level); |
| 1299 | compressing_write_buffer = write_buffer.get(); |
| 1300 | } |
| 1301 | |
| 1302 | auto has_output = [&] { return (nested_write_buffer->position() != output.data()) || (compressing_write_buffer && compressing_write_buffer->offset()); }; |
| 1303 | |
| 1304 | output_format_processor = query_context->getOutputFormat(output_format, *write_buffer, header); |
| 1305 | Stopwatch after_send_progress; |
| 1306 | |
| 1307 | /// Unless the input() function is used we are not going to receive input data anymore. |
| 1308 | if (!input_function_is_used) |
| 1309 | check_query_info_contains_cancel_only = true; |
| 1310 | |
| 1311 | if (io.pipeline.pulling()) |
| 1312 | { |
| 1313 | auto executor = std::make_shared<PullingAsyncPipelineExecutor>(io.pipeline); |
| 1314 | io.pipeline.setConcurrencyControl(query_context->getSettingsRef()[Setting::use_concurrency_control]); |
| 1315 | auto check_for_cancel = [&] |
| 1316 | { |
| 1317 | if (isQueryCancelled()) |
| 1318 | { |
| 1319 | executor->cancel(); |
| 1320 | return false; |
| 1321 | } |
| 1322 | return true; |
| 1323 | }; |
| 1324 | |
| 1325 | addOutputFormatToResult(); |
| 1326 | addOutputColumnsNamesAndTypesToResult(header); |
| 1327 | |
| 1328 | Block block; |
| 1329 | while (check_for_cancel()) |
| 1330 | { |
| 1331 | if (!executor->pull(block, interactive_delay / 1000)) |
| 1332 | break; |
| 1333 | |
| 1334 | throwIfFailedToSendResult(); |
| 1335 | if (!check_for_cancel()) |
| 1336 | break; |
| 1337 |
nothing calls this directly
no test coverage detected