MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / resetOutput

Method resetOutput

src/Client/ClientBase.cpp:1817–1888  ·  view source on GitHub ↗

Flush all buffers.

Source from the content-addressed store, hash-verified

1815
1816/// Flush all buffers.
1817void ClientBase::resetOutput()
1818{
1819 if (need_render_progress_table && tty_buf)
1820 {
1821 std::unique_lock lock(tty_mutex);
1822 progress_table.clearTableOutput(*tty_buf, lock);
1823 }
1824
1825 /// Order is important: format, compression, file
1826
1827 try
1828 {
1829 if (output_format)
1830 output_format->finalize();
1831 }
1832 catch (...)
1833 {
1834 /// We need to make sure we continue resetting output_format (will stop threads on parallel output)
1835 /// as well as cleaning other output related setup
1836 if (!have_error)
1837 {
1838 client_exception
1839 = std::make_unique<Exception>(getCurrentExceptionMessageAndPattern(print_stack_trace), getCurrentExceptionCode());
1840 have_error = true;
1841 }
1842 }
1843
1844 output_format.reset();
1845 pending_progress.reset();
1846
1847 /// out_file_buf wraps std_out_wrapper (via a raw pointer), so it must be finalized
1848 /// first to flush remaining data (e.g. the gzip footer) into std_out_wrapper.
1849 if (out_file_buf)
1850 {
1851 if (out_file_buf->isCanceled())
1852 out_file_buf.reset();
1853 else
1854 out_file_buf->finalize();
1855 }
1856 out_file_buf.reset();
1857
1858 if (std_out_wrapper)
1859 {
1860 if (std_out_wrapper->isCanceled())
1861 std_out_wrapper.reset();
1862 else
1863 std_out_wrapper->finalize();
1864 }
1865 std_out_wrapper.reset();
1866
1867 logs_out_stream.reset();
1868
1869 out_logs_buf.reset();
1870
1871 if (pager_cmd)
1872 {
1873 pager_cmd->in.close();
1874 /// The process will terminated in destructor anyway (due to terminate_in_destructor_strategy.terminate_in_destructor=true)

Callers

nothing calls this directly

Calls 10

getCurrentExceptionCodeFunction · 0.85
ErrnoExceptionClass · 0.85
clearTableOutputMethod · 0.80
finalizeMethod · 0.45
resetMethod · 0.45
isCanceledMethod · 0.45
closeMethod · 0.45
waitMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected