| 1293 | } |
| 1294 | |
| 1295 | void Call::readQueryInfo() |
| 1296 | { |
| 1297 | auto start_reading = [&] |
| 1298 | { |
| 1299 | reading_query_info.set(true); |
| 1300 | responder->read(next_query_info_while_reading, [this](bool ok) |
| 1301 | { |
| 1302 | /// Called on queue_thread. |
| 1303 | if (ok) |
| 1304 | { |
| 1305 | const auto & nqi = next_query_info_while_reading; |
| 1306 | if (check_query_info_contains_cancel_only) |
| 1307 | { |
| 1308 | if (!nqi.query().empty() || !nqi.query_id().empty() || !nqi.settings().empty() || !nqi.database().empty() |
| 1309 | || !nqi.input_data().empty() || !nqi.input_data_delimiter().empty() || !nqi.output_format().empty() |
| 1310 | || !nqi.user_name().empty() || !nqi.password().empty() || !nqi.quota().empty() || !nqi.session_id().empty()) |
| 1311 | { |
| 1312 | LOG_WARNING(log, "Cannot add extra information to a query which is already executing. Only the 'cancel' field can be set"); |
| 1313 | } |
| 1314 | } |
| 1315 | if (nqi.cancel()) |
| 1316 | want_to_cancel = true; |
| 1317 | } |
| 1318 | else |
| 1319 | { |
| 1320 | /// We cannot throw an exception right here because this code is executed |
| 1321 | /// on queue_thread. |
| 1322 | failed_to_read_query_info = true; |
| 1323 | } |
| 1324 | reading_query_info.set(false); |
| 1325 | }); |
| 1326 | }; |
| 1327 | |
| 1328 | auto finish_reading = [&] |
| 1329 | { |
| 1330 | if (reading_query_info.get()) |
| 1331 | { |
| 1332 | Stopwatch client_writing_watch; |
| 1333 | reading_query_info.wait(false); |
| 1334 | waited_for_client_writing += client_writing_watch.elapsedNanoseconds(); |
| 1335 | } |
| 1336 | throwIfFailedToReadQueryInfo(); |
| 1337 | query_info = std::move(next_query_info_while_reading); |
| 1338 | initial_query_info_read = true; |
| 1339 | }; |
| 1340 | |
| 1341 | if (!initial_query_info_read) |
| 1342 | { |
| 1343 | /// Initial query info hasn't been read yet, so we're going to read it now. |
| 1344 | start_reading(); |
| 1345 | } |
| 1346 | |
| 1347 | /// Maybe it's reading a query info right now. Let it finish. |
| 1348 | finish_reading(); |
| 1349 | |
| 1350 | if (isInputStreaming(call_type)) |
| 1351 | { |
| 1352 | /// Next query info can contain more input data. Now we start reading a next query info, |
nothing calls this directly
no test coverage detected