| 465 | } |
| 466 | |
| 467 | void readQueries() |
| 468 | { |
| 469 | if (query_to_execute.empty()) |
| 470 | { |
| 471 | ReadBufferFromFileDescriptor in(STDIN_FILENO); |
| 472 | |
| 473 | switch (queries_format) |
| 474 | { |
| 475 | case QueriesFormat::Script: |
| 476 | { |
| 477 | String all_queries_text; |
| 478 | readStringUntilEOF(all_queries_text, in); |
| 479 | |
| 480 | auto parse_res = splitMultipartQuery( |
| 481 | all_queries_text, |
| 482 | queries, |
| 483 | settings[Setting::max_query_size], |
| 484 | settings[Setting::max_parser_depth], |
| 485 | settings[Setting::max_parser_backtracks], |
| 486 | settings[Setting::allow_settings_after_format_in_insert], |
| 487 | settings[Setting::implicit_select]); |
| 488 | |
| 489 | if (!parse_res.second) |
| 490 | throw Exception(ErrorCodes::BAD_ARGUMENTS, |
| 491 | "Cannot parse query near: {}", String(parse_res.first, std::min<size_t>(100, all_queries_text.data() + all_queries_text.size() - parse_res.first))); |
| 492 | break; |
| 493 | } |
| 494 | case QueriesFormat::TSV: |
| 495 | { |
| 496 | /// Default: one query per line, tab-escaped |
| 497 | while (!in.eof()) |
| 498 | { |
| 499 | String query; |
| 500 | readText(query, in); |
| 501 | assertChar('\n', in); |
| 502 | |
| 503 | if (!query.empty()) |
| 504 | queries.emplace_back(std::move(query)); |
| 505 | } |
| 506 | break; |
| 507 | } |
| 508 | } |
| 509 | |
| 510 | if (queries.empty()) |
| 511 | throw Exception(ErrorCodes::EMPTY_DATA_PASSED, "Empty list of queries."); |
| 512 | } |
| 513 | else |
| 514 | { |
| 515 | queries.emplace_back(query_to_execute); |
| 516 | } |
| 517 | |
| 518 | |
| 519 | std::lock_guard lock(mutex); |
| 520 | log << "Loaded " << queries.size() << " queries.\n" << flush; |
| 521 | } |
| 522 | |
| 523 | /// Try push new query and check cancellation conditions |
| 524 | bool tryPushQueryInteractively(const String & query, InterruptListener & interrupt_listener) |
nothing calls this directly
no test coverage detected