MySQL 8.4.11
Source Code Documentation
classic_query_forwarder.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2023, 2026, Oracle and/or its affiliates.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License, version 2.0,
6 as published by the Free Software Foundation.
7
8 This program is designed to work with certain software (including
9 but not limited to OpenSSL) that is licensed under separate terms,
10 as designated in a particular file or component or in included license
11 documentation. The authors of MySQL hereby grant you an additional
12 permission to link the program and your derivative works with the
13 separately licensed software that they have either included with
14 the program or referenced in the documentation.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24*/
25
26#ifndef ROUTING_SRC_PROCESSORS_FORWARDERS_CLASSIC_QUERY_FORWARDER_H_
27#define ROUTING_SRC_PROCESSORS_FORWARDERS_CLASSIC_QUERY_FORWARDER_H_
28
29#include <system_error>
30
33#include "sql_parser_state.h"
34#include "stmt_classifier.h"
35
37 public:
38 using ForwardingProcessor::ForwardingProcessor;
39
40 enum class Stage {
41 Command,
42
47
49
52
53 Connect,
55
56 Forward,
58
61 Column,
64 Row,
65 RowEnd,
66
68 Data,
69
70 Ok,
71 Error,
72
74 Done,
75
77 };
78
79 static constexpr std::string_view prefix() { return "mysql/query"; }
80
82
84 [[nodiscard]] Stage stage() const { return stage_; }
85
86 std::optional<std::string_view> diagnostic_stage_name() const override;
87
88 void failed(
89 const std::optional<classic_protocol::message::server::Error> &err) {
90 failed_ = err;
91 }
92
93 std::optional<classic_protocol::message::server::Error> failed() const {
94 return failed_;
95 }
96
97 private:
113
120
124
126
128 net::const_buffer session_trackers,
130
132
134
136
137 uint64_t columns_left_{0};
138
144
145 std::optional<classic_protocol::message::server::Error> failed_;
146
148};
149
150#endif // ROUTING_SRC_PROCESSORS_FORWARDERS_CLASSIC_QUERY_FORWARDER_H_
a processor base class with helper functions.
Definition: forwarding_processor.h:38
Definition: classic_query_forwarder.h:36
stdx::expected< Result, std::error_code > response()
Definition: classic_query_forwarder.cc:2685
TraceEvent * trace_event_command_
Definition: classic_query_forwarder.h:139
std::optional< classic_protocol::message::server::Error > failed() const
Definition: classic_query_forwarder.h:93
stdx::expected< Result, std::error_code > row()
Definition: classic_query_forwarder.cc:2827
void stage(Stage stage)
Definition: classic_query_forwarder.h:83
Stage
Definition: classic_query_forwarder.h:40
stdx::expected< Result, std::error_code > switch_backend()
Definition: classic_query_forwarder.cc:2511
stdx::expected< Result, std::error_code > process() override
Definition: classic_query_forwarder.cc:1577
stdx::expected< Result, std::error_code > classify_query()
Definition: classic_query_forwarder.cc:1983
stdx::expected< Result, std::error_code > explicit_commit_connect()
Definition: classic_query_forwarder.cc:1887
stdx::expected< Result, std::error_code > row_end()
Definition: classic_query_forwarder.cc:2836
std::optional< classic_protocol::message::server::Error > failed_
Definition: classic_query_forwarder.h:145
stdx::expected< Result, std::error_code > explicit_commit()
Definition: classic_query_forwarder.cc:1926
stdx::expected< Result, std::error_code > connected()
Definition: classic_query_forwarder.cc:2547
stdx::expected< Result, std::error_code > explicit_commit_connect_done()
Definition: classic_query_forwarder.cc:1897
stdx::expected< Result, std::error_code > load_data()
Definition: classic_query_forwarder.cc:2718
stdx::expected< Result, std::error_code > prepare_backend()
Definition: classic_query_forwarder.cc:2518
stdx::expected< Result, std::error_code > command()
Definition: classic_query_forwarder.cc:1636
TraceEvent * trace_connect_and_explicit_commit(TraceEvent *parent_span)
Definition: classic_query_forwarder.cc:1875
TraceEvent * trace_event_query_result_
Definition: classic_query_forwarder.h:143
stdx::expected< Result, std::error_code > forward()
Definition: classic_query_forwarder.cc:2591
stdx::flags< StmtClassifier > stmt_classified_
Definition: classic_query_forwarder.h:133
stdx::expected< Result, std::error_code > column_end()
Definition: classic_query_forwarder.cc:2781
stdx::expected< Result, std::error_code > error()
Definition: classic_query_forwarder.cc:2996
TraceEvent * trace_event_connect_and_explicit_commit_
Definition: classic_query_forwarder.h:140
stdx::expected< Result, std::error_code > column_count()
Definition: classic_query_forwarder.cc:2747
stdx::expected< Result, std::error_code > forward_done()
Definition: classic_query_forwarder.cc:2672
static constexpr std::string_view prefix()
Definition: classic_query_forwarder.h:79
Stage stage_
Definition: classic_query_forwarder.h:135
stdx::expected< void, std::error_code > track_session_changes(net::const_buffer session_trackers, classic_protocol::capabilities::value_type caps)
stdx::expected< Result, std::error_code > connect()
Definition: classic_query_forwarder.cc:2530
SqlParserState sql_parser_state_
Definition: classic_query_forwarder.h:147
TraceEvent * trace_event_forward_command_
Definition: classic_query_forwarder.h:142
TraceEvent * trace_event_connect_and_forward_command_
Definition: classic_query_forwarder.h:141
stdx::expected< Result, std::error_code > column()
Definition: classic_query_forwarder.cc:2768
stdx::expected< Result, std::error_code > explicit_commit_done()
Definition: classic_query_forwarder.cc:1946
stdx::expected< Result, std::error_code > data()
Definition: classic_query_forwarder.cc:2727
uint64_t columns_left_
Definition: classic_query_forwarder.h:137
Stage stage() const
Definition: classic_query_forwarder.h:84
void failed(const std::optional< classic_protocol::message::server::Error > &err)
Definition: classic_query_forwarder.h:88
stdx::expected< Result, std::error_code > row_or_end()
Definition: classic_query_forwarder.cc:2792
stdx::expected< Result, std::error_code > ok()
Definition: classic_query_forwarder.cc:2919
std::optional< std::string_view > diagnostic_stage_name() const override
stage name of a staged processor.
Definition: classic_query_forwarder.cc:3043
stdx::expected< Result, std::error_code > response_done()
Definition: classic_query_forwarder.cc:3030
stdx::expected< Result, std::error_code > send_queued()
Definition: classic_query_forwarder.cc:3038
Definition: sql_parser_state.h:35
Definition: buffer.h:135
Definition: expected.h:286
a type-safe flags type.
Definition: flags.h:115
std::bitset< 32 > value_type
Definition: classic_protocol_constants.h:73
static Value err()
Create a Value object that represents an error condition.
Definition: json_binary.cc:927
Definition: trace_span.h:35