MySQL 8.3.0
Source Code Documentation
classic_query_forwarder.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2023, 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 also distributed 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 included with MySQL.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23*/
24
25#ifndef ROUTING_CLASSIC_QUERY_FORWARDER_INCLUDED
26#define ROUTING_CLASSIC_QUERY_FORWARDER_INCLUDED
27
28#include <system_error>
29
32#include "sql_parser_state.h"
33#include "stmt_classifier.h"
34
36 public:
37 using ForwardingProcessor::ForwardingProcessor;
38
39 enum class Stage {
40 Command,
41
46
48
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:
112
119
123
125
127 net::const_buffer session_trackers,
129
131
133
135
136 uint64_t columns_left_{0};
137
143
144 std::optional<classic_protocol::message::server::Error> failed_;
145
147};
148
149#endif
a processor base class with helper functions.
Definition: forwarding_processor.h:36
Definition: classic_query_forwarder.h:35
stdx::expected< Result, std::error_code > response()
Definition: classic_query_forwarder.cc:2771
TraceEvent * trace_event_command_
Definition: classic_query_forwarder.h:138
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:2921
void stage(Stage stage)
Definition: classic_query_forwarder.h:83
Stage
Definition: classic_query_forwarder.h:39
stdx::expected< Result, std::error_code > switch_backend()
Definition: classic_query_forwarder.cc:2588
stdx::expected< Result, std::error_code > process() override
Definition: classic_query_forwarder.cc:1618
stdx::expected< Result, std::error_code > classify_query()
Definition: classic_query_forwarder.cc:2035
stdx::expected< Result, std::error_code > explicit_commit_connect()
Definition: classic_query_forwarder.cc:1934
stdx::expected< Result, std::error_code > row_end()
Definition: classic_query_forwarder.cc:2930
std::optional< classic_protocol::message::server::Error > failed_
Definition: classic_query_forwarder.h:144
stdx::expected< Result, std::error_code > explicit_commit()
Definition: classic_query_forwarder.cc:1976
stdx::expected< Result, std::error_code > connected()
Definition: classic_query_forwarder.cc:2629
stdx::expected< Result, std::error_code > explicit_commit_connect_done()
Definition: classic_query_forwarder.cc:1944
stdx::expected< Result, std::error_code > load_data()
Definition: classic_query_forwarder.cc:2806
stdx::expected< Result, std::error_code > prepare_backend()
Definition: classic_query_forwarder.cc:2607
stdx::expected< Result, std::error_code > command()
Definition: classic_query_forwarder.cc:1679
TraceEvent * trace_connect_and_explicit_commit(TraceEvent *parent_span)
Definition: classic_query_forwarder.cc:1922
TraceEvent * trace_event_query_result_
Definition: classic_query_forwarder.h:142
stdx::expected< Result, std::error_code > forward()
Definition: classic_query_forwarder.cc:2676
stdx::flags< StmtClassifier > stmt_classified_
Definition: classic_query_forwarder.h:132
stdx::expected< Result, std::error_code > column_end()
Definition: classic_query_forwarder.cc:2873
stdx::expected< Result, std::error_code > error()
Definition: classic_query_forwarder.cc:3085
TraceEvent * trace_event_connect_and_explicit_commit_
Definition: classic_query_forwarder.h:139
stdx::expected< Result, std::error_code > column_count()
Definition: classic_query_forwarder.cc:2836
stdx::expected< Result, std::error_code > forward_done()
Definition: classic_query_forwarder.cc:2758
static constexpr std::string_view prefix()
Definition: classic_query_forwarder.h:79
Stage stage_
Definition: classic_query_forwarder.h:134
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:2620
SqlParserState sql_parser_state_
Definition: classic_query_forwarder.h:146
TraceEvent * trace_event_forward_command_
Definition: classic_query_forwarder.h:141
TraceEvent * trace_event_connect_and_forward_command_
Definition: classic_query_forwarder.h:140
stdx::expected< Result, std::error_code > column()
Definition: classic_query_forwarder.cc:2860
stdx::expected< Result, std::error_code > explicit_commit_done()
Definition: classic_query_forwarder.cc:1996
stdx::expected< Result, std::error_code > data()
Definition: classic_query_forwarder.cc:2815
stdx::expected< Result, std::error_code > pool_backend()
Definition: classic_query_forwarder.cc:2562
uint64_t columns_left_
Definition: classic_query_forwarder.h:136
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:2884
stdx::expected< Result, std::error_code > ok()
Definition: classic_query_forwarder.cc:3011
stdx::expected< Result, std::error_code > response_done()
Definition: classic_query_forwarder.cc:3121
stdx::expected< Result, std::error_code > send_queued()
Definition: classic_query_forwarder.cc:3129
Definition: sql_parser_state.h:34
Definition: buffer.h:134
Definition: expected.h:943
a type-safe flags type.
Definition: flags.h:114
std::bitset< 32 > value_type
Definition: classic_protocol_constants.h:72
static Value err()
Create a Value object that represents an error condition.
Definition: json_binary.cc:926
Definition: trace_span.h:34