| 871 | } |
| 872 | |
| 873 | void Call::initializeBlockInputStream(const Block & header) |
| 874 | { |
| 875 | assert(!read_buffer); |
| 876 | read_buffer.emplace([this]() -> std::pair<const void *, size_t> |
| 877 | { |
| 878 | if (need_input_data_from_insert_query) |
| 879 | { |
| 880 | need_input_data_from_insert_query = false; |
| 881 | if (insert_query && insert_query->data && (insert_query->data != insert_query->end)) |
| 882 | { |
| 883 | need_input_data_delimiter = !input_data_delimiter.empty(); |
| 884 | return {insert_query->data, insert_query->end - insert_query->data}; |
| 885 | } |
| 886 | } |
| 887 | |
| 888 | while (true) |
| 889 | { |
| 890 | if (need_input_data_from_query_info) |
| 891 | { |
| 892 | if (need_input_data_delimiter && !query_info.input_data().empty()) |
| 893 | { |
| 894 | need_input_data_delimiter = false; |
| 895 | return {input_data_delimiter.data(), input_data_delimiter.size()}; |
| 896 | } |
| 897 | need_input_data_from_query_info = false; |
| 898 | if (!query_info.input_data().empty()) |
| 899 | { |
| 900 | need_input_data_delimiter = !input_data_delimiter.empty(); |
| 901 | return {query_info.input_data().data(), query_info.input_data().size()}; |
| 902 | } |
| 903 | } |
| 904 | |
| 905 | if (!query_info.next_query_info()) |
| 906 | break; |
| 907 | |
| 908 | if (!isInputStreaming(call_type)) |
| 909 | throw Exception("next_query_info is allowed to be set only for streaming input", ErrorCodes::INVALID_GRPC_QUERY_INFO); |
| 910 | |
| 911 | readQueryInfo(); |
| 912 | if (!query_info.query().empty() || !query_info.query_id().empty() || !query_info.settings().empty() |
| 913 | || !query_info.database().empty() || !query_info.input_data_delimiter().empty() || !query_info.output_format().empty() |
| 914 | || query_info.external_tables_size() || !query_info.user_name().empty() || !query_info.password().empty() |
| 915 | || !query_info.quota().empty() || !query_info.session_id().empty()) |
| 916 | { |
| 917 | throw Exception("Extra query infos can be used only to add more input data. " |
| 918 | "Only the following fields can be set: input_data, next_query_info, cancel", |
| 919 | ErrorCodes::INVALID_GRPC_QUERY_INFO); |
| 920 | } |
| 921 | |
| 922 | if (isQueryCancelled()) |
| 923 | break; |
| 924 | |
| 925 | LOG_DEBUG(log, "Received extra QueryInfo: input_data: {} bytes", query_info.input_data().size()); |
| 926 | need_input_data_from_query_info = true; |
| 927 | } |
| 928 | |
| 929 | return {nullptr, 0}; /// no more input data |
| 930 | }); |
nothing calls this directly
no test coverage detected