| 574 | |
| 575 | |
| 576 | void ClientBase::onData(Block & block, ASTPtr parsed_query) |
| 577 | { |
| 578 | if (block.empty()) |
| 579 | return; |
| 580 | |
| 581 | processed_rows_from_blocks += block.rows(); |
| 582 | /// Even if all blocks are empty, we still need to initialize the output stream to write empty resultset. |
| 583 | initOutputFormat(block, parsed_query); |
| 584 | |
| 585 | /// The header block containing zero rows was used to initialize |
| 586 | /// output_format, do not output it. |
| 587 | /// Also do not output too much data if we're fuzzing. |
| 588 | if (block.rows() == 0 || (query_fuzzer_runs != 0 && processed_rows_from_blocks >= 100)) |
| 589 | return; |
| 590 | |
| 591 | try |
| 592 | { |
| 593 | output_format->write(materializeBlock( |
| 594 | block, |
| 595 | !output_format->supportsSpecialSerializationKinds())); |
| 596 | written_first_block = true; |
| 597 | } |
| 598 | catch (const NetException &) |
| 599 | { |
| 600 | throw; |
| 601 | } |
| 602 | catch (const ErrnoException &) |
| 603 | { |
| 604 | throw; |
| 605 | } |
| 606 | catch (const Exception &) |
| 607 | { |
| 608 | //this is a bad catch. It catches too much cases unrelated to LocalFormatError |
| 609 | /// Catch client errors like NO_ROW_DELIMITER |
| 610 | throw LocalFormatError(getCurrentExceptionMessageAndPattern(print_stack_trace), getCurrentExceptionCode()); |
| 611 | } |
| 612 | |
| 613 | /// Received data block is immediately displayed to the user. |
| 614 | output_format->flush(); |
| 615 | |
| 616 | /// Restore progress bar and progress table after data block. |
| 617 | if (need_render_progress && tty_buf) |
| 618 | { |
| 619 | if (select_into_file && !select_into_file_and_stdout) |
| 620 | error_stream << "\r"; |
| 621 | std::unique_lock lock(tty_mutex); |
| 622 | progress_indication.writeProgress(*tty_buf, lock); |
| 623 | } |
| 624 | if (need_render_progress_table && tty_buf && !cancelled) |
| 625 | { |
| 626 | if (!need_render_progress && select_into_file && !select_into_file_and_stdout) |
| 627 | error_stream << "\r"; |
| 628 | std::unique_lock lock(tty_mutex); |
| 629 | progress_table.writeTable(*tty_buf, lock, progress_table_toggle_on.load(), progress_table_toggle_enabled, false); |
| 630 | } |
| 631 | } |
| 632 | |
| 633 |
nothing calls this directly
no test coverage detected