MySQL 8.4.2
Source Code Documentation
classic_query_forwarder.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2023, 2024, 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_CLASSIC_QUERY_FORWARDER_INCLUDED
27#define ROUTING_CLASSIC_QUERY_FORWARDER_INCLUDED
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 void failed(
87 const std::optional<classic_protocol::message::server::Error> &err) {
88 failed_ = err;
89 }
90
91 std::optional<classic_protocol::message::server::Error> failed() const {
92 return failed_;
93 }
94
95 private:
111
118
122
124
126 net::const_buffer session_trackers,
128
130
132
134
135 uint64_t columns_left_{0};
136
142
143 std::optional<classic_protocol::message::server::Error> failed_;
144
146};
147
148#endif
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:2680
TraceEvent * trace_event_command_
Definition: classic_query_forwarder.h:137
std::optional< classic_protocol::message::server::Error > failed() const
Definition: classic_query_forwarder.h:91
stdx::expected< Result, std::error_code > row()
Definition: classic_query_forwarder.cc:2822
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:2508
stdx::expected< Result, std::error_code > process() override
Definition: classic_query_forwarder.cc:1580
stdx::expected< Result, std::error_code > classify_query()
Definition: classic_query_forwarder.cc:1987
stdx::expected< Result, std::error_code > explicit_commit_connect()
Definition: classic_query_forwarder.cc:1890
stdx::expected< Result, std::error_code > row_end()
Definition: classic_query_forwarder.cc:2831
std::optional< classic_protocol::message::server::Error > failed_
Definition: classic_query_forwarder.h:143
stdx::expected< Result, std::error_code > explicit_commit()
Definition: classic_query_forwarder.cc:1930
stdx::expected< Result, std::error_code > connected()
Definition: classic_query_forwarder.cc:2541
stdx::expected< Result, std::error_code > explicit_commit_connect_done()
Definition: classic_query_forwarder.cc:1900
stdx::expected< Result, std::error_code > load_data()
Definition: classic_query_forwarder.cc:2713
stdx::expected< Result, std::error_code > prepare_backend()
Definition: classic_query_forwarder.cc:2515
stdx::expected< Result, std::error_code > command()
Definition: classic_query_forwarder.cc:1639
TraceEvent * trace_connect_and_explicit_commit(TraceEvent *parent_span)
Definition: classic_query_forwarder.cc:1878
TraceEvent * trace_event_query_result_
Definition: classic_query_forwarder.h:141
stdx::expected< Result, std::error_code > forward()
Definition: classic_query_forwarder.cc:2586
stdx::flags< StmtClassifier > stmt_classified_
Definition: classic_query_forwarder.h:131
stdx::expected< Result, std::error_code > column_end()
Definition: classic_query_forwarder.cc:2776
stdx::expected< Result, std::error_code > error()
Definition: classic_query_forwarder.cc:2991
TraceEvent * trace_event_connect_and_explicit_commit_
Definition: classic_query_forwarder.h:138
stdx::expected< Result, std::error_code > column_count()
Definition: classic_query_forwarder.cc:2742
stdx::expected< Result, std::error_code > forward_done()
Definition: classic_query_forwarder.cc:2667
static constexpr std::string_view prefix()
Definition: classic_query_forwarder.h:79
Stage stage_
Definition: classic_query_forwarder.h:133
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:2527
SqlParserState sql_parser_state_
Definition: classic_query_forwarder.h:145
TraceEvent * trace_event_forward_command_
Definition: classic_query_forwarder.h:140
TraceEvent * trace_event_connect_and_forward_command_
Definition: classic_query_forwarder.h:139
stdx::expected< Result, std::error_code > column()
Definition: classic_query_forwarder.cc:2763
stdx::expected< Result, std::error_code > explicit_commit_done()
Definition: classic_query_forwarder.cc:1950
stdx::expected< Result, std::error_code > data()
Definition: classic_query_forwarder.cc:2722
uint64_t columns_left_
Definition: classic_query_forwarder.h:135
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:86
stdx::expected< Result, std::error_code > row_or_end()
Definition: classic_query_forwarder.cc:2787
stdx::expected< Result, std::error_code > ok()
Definition: classic_query_forwarder.cc:2914
stdx::expected< Result, std::error_code > response_done()
Definition: classic_query_forwarder.cc:3025
stdx::expected< Result, std::error_code > send_queued()
Definition: classic_query_forwarder.cc:3033
Definition: sql_parser_state.h:35
Definition: buffer.h:135
Definition: expected.h:284
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