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

Method finalizeImpl

src/Processors/Formats/Impl/MySQLOutputFormat.cpp:110–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108}
109
110void MySQLOutputFormat::finalizeImpl()
111{
112 if (!use_binary_result_set)
113 {
114 size_t affected_rows = 0;
115 std::string human_readable_info;
116 if (QueryStatusPtr process_list_elem = getContext()->getProcessListElement())
117 {
118 CurrentThread::finalizePerformanceCounters();
119 QueryStatusInfo info = process_list_elem->getInfo();
120 affected_rows = info.written_rows;
121 double elapsed_seconds = static_cast<double>(info.elapsed_microseconds) / 1000000.0;
122 human_readable_info = fmt::format(
123 "Read {} rows, {} in {} sec., {} rows/sec., {}/sec.",
124 info.read_rows,
125 ReadableSize(info.read_bytes),
126 elapsed_seconds,
127 static_cast<size_t>(static_cast<double>(info.read_rows) / elapsed_seconds),
128 ReadableSize(static_cast<double>(info.read_bytes) / elapsed_seconds));
129 }
130
131 const auto & header = getPort(PortKind::Main).getHeader();
132 if (header.columns() == 0)
133 packet_endpoint->sendPacket(OKPacket(0x0, client_capabilities, affected_rows, 0, 0, "", human_readable_info));
134 else if (client_capabilities & CLIENT_DEPRECATE_EOF)
135 packet_endpoint->sendPacket(OKPacket(0xfe, client_capabilities, affected_rows, 0, 0, "", human_readable_info));
136 else
137 packet_endpoint->sendPacket(EOFPacket(0, 0));
138 }
139 else
140 {
141 size_t affected_rows = 0;
142 if (QueryStatusPtr process_list_elem = getContext()->getProcessListElement())
143 {
144 CurrentThread::finalizePerformanceCounters();
145 QueryStatusInfo info = process_list_elem->getInfo();
146 affected_rows = info.written_rows;
147 }
148 if (client_capabilities & CLIENT_DEPRECATE_EOF)
149 packet_endpoint->sendPacket(OKPacket(0xfe, client_capabilities, affected_rows, 0, 0, "", ""));
150 else
151 packet_endpoint->sendPacket(EOFPacket(0, 0));
152 }
153}
154
155void MySQLOutputFormat::flushImpl()
156{

Callers

nothing calls this directly

Calls 10

ReadableSizeClass · 0.85
OKPacketClass · 0.85
EOFPacketClass · 0.85
columnsMethod · 0.80
sendPacketMethod · 0.80
getContextFunction · 0.50
formatFunction · 0.50
getProcessListElementMethod · 0.45
getInfoMethod · 0.45
getHeaderMethod · 0.45

Tested by

no test coverage detected