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

Method loadWarningMessages

programs/client/Client.cpp:149–203  ·  view source on GitHub ↗

Make query to get all server warnings

Source from the content-addressed store, hash-verified

147
148/// Make query to get all server warnings
149std::vector<String> Client::loadWarningMessages()
150{
151 /// Older server versions cannot execute the query loading warnings.
152 constexpr UInt64 min_server_revision_to_load_warnings = DBMS_MIN_PROTOCOL_VERSION_WITH_VIEW_IF_PERMITTED;
153
154 if (server_revision < min_server_revision_to_load_warnings)
155 return {};
156
157 std::vector<String> messages;
158 connection->sendQuery(connection_parameters.timeouts,
159 "SELECT * FROM viewIfPermitted(SELECT message FROM system.warnings ELSE null('message String'))",
160 {} /* query_parameters */,
161 "" /* query_id */,
162 QueryProcessingStage::Complete,
163 &client_context->getSettingsRef(),
164 &client_context->getClientInfo(), false, {}, {});
165 while (true)
166 {
167 Packet packet = connection->receivePacket();
168 switch (packet.type)
169 {
170 case Protocol::Server::Data:
171 if (!packet.block.empty())
172 {
173 const ColumnString & column = typeid_cast<const ColumnString &>(*packet.block.getByPosition(0).column);
174
175 size_t rows = packet.block.rows();
176 for (size_t i = 0; i < rows; ++i)
177 messages.emplace_back(column[i].safeGet<String>());
178 }
179 continue;
180
181 case Protocol::Server::Progress:
182 case Protocol::Server::ProfileInfo:
183 case Protocol::Server::Totals:
184 case Protocol::Server::Extremes:
185 case Protocol::Server::Log:
186 continue;
187
188 case Protocol::Server::Exception:
189 packet.exception->rethrow();
190 return messages;
191
192 case Protocol::Server::EndOfStream:
193 return messages;
194
195 case Protocol::Server::ProfileEvents:
196 continue;
197
198 default:
199 throw Exception(
200 ErrorCodes::UNKNOWN_PACKET_FROM_SERVER, "Unknown packet {} from server {}", packet.type, connection->getDescription());
201 }
202 }
203}
204
205
206Poco::Util::LayeredConfiguration & Client::getClientConfiguration()

Callers

nothing calls this directly

Calls 8

ExceptionClass · 0.50
sendQueryMethod · 0.45
receivePacketMethod · 0.45
emptyMethod · 0.45
rowsMethod · 0.45
emplace_backMethod · 0.45
rethrowMethod · 0.45
getDescriptionMethod · 0.45

Tested by

no test coverage detected