| 698 | } |
| 699 | |
| 700 | void Call::executeQuery() |
| 701 | { |
| 702 | /// Retrieve user credentials. |
| 703 | std::string user = query_info.user_name(); |
| 704 | std::string password = query_info.password(); |
| 705 | std::string quota_key = query_info.quota(); |
| 706 | Poco::Net::SocketAddress user_address = responder->getClientAddress(); |
| 707 | |
| 708 | if (user.empty()) |
| 709 | { |
| 710 | user = "default"; |
| 711 | password = ""; |
| 712 | } |
| 713 | |
| 714 | /// Create context. |
| 715 | query_context = Context::createCopy(iserver.context()); |
| 716 | |
| 717 | /// Authentication. |
| 718 | query_context->setUser(user, password, user_address); |
| 719 | query_context->setCurrentQueryId(query_info.query_id()); |
| 720 | if (!quota_key.empty()) |
| 721 | query_context->setQuotaKey(quota_key); |
| 722 | |
| 723 | /// The user could specify session identifier and session timeout. |
| 724 | /// It allows to modify settings, create temporary tables and reuse them in subsequent requests. |
| 725 | if (!query_info.session_id().empty()) |
| 726 | { |
| 727 | session = query_context->acquireNamedSession( |
| 728 | query_info.session_id(), getSessionTimeout(query_info, iserver.config()), query_info.session_check()); |
| 729 | query_context = Context::createCopy(session->context); |
| 730 | query_context->setSessionContext(session->context); |
| 731 | } |
| 732 | |
| 733 | query_scope.emplace(query_context); |
| 734 | |
| 735 | /// Set client info. |
| 736 | ClientInfo & client_info = query_context->getClientInfo(); |
| 737 | client_info.query_kind = ClientInfo::QueryKind::INITIAL_QUERY; |
| 738 | client_info.interface = ClientInfo::Interface::GRPC; |
| 739 | client_info.initial_user = client_info.current_user; |
| 740 | client_info.initial_query_id = client_info.current_query_id; |
| 741 | client_info.initial_address = client_info.current_address; |
| 742 | |
| 743 | /// Prepare settings. |
| 744 | SettingsChanges settings_changes; |
| 745 | for (const auto & [key, value] : query_info.settings()) |
| 746 | { |
| 747 | settings_changes.push_back({key, value}); |
| 748 | } |
| 749 | query_context->checkSettingsConstraints(settings_changes); |
| 750 | query_context->applySettingsChanges(settings_changes); |
| 751 | const Settings & settings = query_context->getSettingsRef(); |
| 752 | |
| 753 | /// Prepare for sending exceptions and logs. |
| 754 | send_exception_with_stacktrace = query_context->getSettingsRef().calculate_text_stack_trace; |
| 755 | const auto client_logs_level = query_context->getSettingsRef().send_logs_level; |
| 756 | if (client_logs_level != LogsLevel::none) |
| 757 | { |
nothing calls this directly
no test coverage detected