| 1484 | } |
| 1485 | |
| 1486 | void Call::readQueryInfo() |
| 1487 | { |
| 1488 | auto start_reading = [&] |
| 1489 | { |
| 1490 | reading_query_info.set(true); |
| 1491 | responder->read(next_query_info_while_reading, [this](bool ok) |
| 1492 | { |
| 1493 | /// Called on queue_thread. |
| 1494 | if (ok) |
| 1495 | { |
| 1496 | const auto & nqi = next_query_info_while_reading; |
| 1497 | if (check_query_info_contains_cancel_only) |
| 1498 | { |
| 1499 | if (!nqi.query().empty() || !nqi.query_id().empty() || !nqi.settings().empty() || !nqi.database().empty() |
| 1500 | || !nqi.input_data().empty() || !nqi.input_data_delimiter().empty() || !nqi.output_format().empty() |
| 1501 | || !nqi.user_name().empty() || !nqi.password().empty() || !nqi.quota().empty() || !nqi.session_id().empty()) |
| 1502 | { |
| 1503 | LOG_WARNING(log, "Cannot add extra information to a query which is already executing. Only the 'cancel' field can be set"); |
| 1504 | } |
| 1505 | } |
| 1506 | if (nqi.cancel()) |
| 1507 | want_to_cancel = true; |
| 1508 | } |
| 1509 | else |
| 1510 | { |
| 1511 | /// We cannot throw an exception right here because this code is executed |
| 1512 | /// on queue_thread. |
| 1513 | failed_to_read_query_info = true; |
| 1514 | } |
| 1515 | reading_query_info.set(false); |
| 1516 | }); |
| 1517 | }; |
| 1518 | |
| 1519 | auto finish_reading = [&] |
| 1520 | { |
| 1521 | if (reading_query_info.get()) |
| 1522 | { |
| 1523 | Stopwatch client_writing_watch; |
| 1524 | reading_query_info.wait(false); |
| 1525 | waited_for_client_writing += client_writing_watch.elapsedNanoseconds(); |
| 1526 | } |
| 1527 | throwIfFailedToReadQueryInfo(); |
| 1528 | query_info = std::move(next_query_info_while_reading); |
| 1529 | initial_query_info_read = true; |
| 1530 | }; |
| 1531 | |
| 1532 | if (!initial_query_info_read) |
| 1533 | { |
| 1534 | /// Initial query info hasn't been read yet, so we're going to read it now. |
| 1535 | start_reading(); |
| 1536 | } |
| 1537 | |
| 1538 | /// Maybe it's reading a query info right now. Let it finish. |
| 1539 | finish_reading(); |
| 1540 | |
| 1541 | if (isInputStreaming(call_type)) |
| 1542 | { |
| 1543 | /// Next query info can contain more input data. Now we start reading a next query info, |
nothing calls this directly
no test coverage detected