MySQL 8.0.39
Source Code Documentation
classic_query_sender.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_SENDER_INCLUDED
27#define ROUTING_CLASSIC_QUERY_SENDER_INCLUDED
28
29#include <system_error>
30
31#include "processor.h"
32#include "stmt_classifier.h"
33
34class QuerySender : public Processor {
35 public:
36 using Processor::Processor;
37
38 class Handler {
39 public:
40 virtual ~Handler() = default;
41
42 virtual void on_column_count(uint64_t count) { (void)count; }
43
44 virtual void on_column(
46 (void)column;
47 }
49 (void)row;
50 }
52 (void)eof;
53 }
55 (void)ok;
56 }
58 (void)err;
59 }
60 };
61
63 : Processor(conn), stmt_{std::move(stmt)} {}
64
66 std::unique_ptr<Handler> handler)
67 : Processor(conn), stmt_{std::move(stmt)}, handler_(std::move(handler)) {}
68
69 enum class Stage {
70 Command,
71
74 Column,
77 Row,
78 RowEnd,
79
81 Data,
82
83 Ok,
84 Error,
85
86 Done,
87 };
88
90
92 Stage stage() const { return stage_; }
93
94 private:
99
106
109
111 net::const_buffer session_trackers,
113
115
116 std::string stmt_;
117 uint64_t columns_left_{0};
118
119 std::unique_ptr<Handler> handler_;
120};
121
122#endif
Definition: classic_connection_base.h:221
a processor base class with helper functions.
Definition: processor.h:89
Definition: classic_query_sender.h:38
virtual ~Handler()=default
virtual void on_column_count(uint64_t count)
Definition: classic_query_sender.h:42
virtual void on_ok(const classic_protocol::message::server::Ok &ok)
Definition: classic_query_sender.h:54
virtual void on_error(const classic_protocol::message::server::Error &err)
Definition: classic_query_sender.h:57
virtual void on_row(const classic_protocol::message::server::Row &row)
Definition: classic_query_sender.h:48
virtual void on_column(const classic_protocol::message::server::ColumnMeta &column)
Definition: classic_query_sender.h:44
virtual void on_row_end(const classic_protocol::message::server::Eof &eof)
Definition: classic_query_sender.h:51
Definition: classic_query_sender.h:34
stdx::expected< Result, std::error_code > command()
Definition: classic_query_sender.cc:305
stdx::expected< Result, std::error_code > response()
Definition: classic_query_sender.cc:327
stdx::expected< Result, std::error_code > row_or_end()
Definition: classic_query_sender.cc:480
stdx::expected< Result, std::error_code > data()
Definition: classic_query_sender.cc:382
void stage(Stage stage)
Definition: classic_query_sender.h:91
stdx::expected< void, std::error_code > track_session_changes(net::const_buffer session_trackers, classic_protocol::capabilities::value_type caps)
Stage stage_
Definition: classic_query_sender.h:114
Stage stage() const
Definition: classic_query_sender.h:92
stdx::expected< Result, std::error_code > column_count()
Definition: classic_query_sender.cc:400
stdx::expected< Result, std::error_code > error()
Definition: classic_query_sender.cc:607
std::string stmt_
Definition: classic_query_sender.h:116
Stage
Definition: classic_query_sender.h:69
stdx::expected< Result, std::error_code > load_data()
Definition: classic_query_sender.cc:360
QuerySender(MysqlRoutingClassicConnectionBase *conn, std::string stmt)
Definition: classic_query_sender.h:62
stdx::expected< Result, std::error_code > row_end()
Definition: classic_query_sender.cc:531
stdx::expected< Result, std::error_code > column()
Definition: classic_query_sender.cc:424
QuerySender(MysqlRoutingClassicConnectionBase *conn, std::string stmt, std::unique_ptr< Handler > handler)
Definition: classic_query_sender.h:65
stdx::expected< Result, std::error_code > row()
Definition: classic_query_sender.cc:510
stdx::expected< Result, std::error_code > ok()
Definition: classic_query_sender.cc:569
uint64_t columns_left_
Definition: classic_query_sender.h:117
stdx::expected< Result, std::error_code > column_end()
Definition: classic_query_sender.cc:460
stdx::expected< Result, std::error_code > process() override
Definition: classic_query_sender.cc:272
std::unique_ptr< Handler > handler_
Definition: classic_query_sender.h:119
The handler class is the interface for dynamically loadable storage engines.
Definition: handler.h:4414
Definition: buffer.h:135
Definition: expected.h:944
static int count
Definition: myisam_ftdump.cc:43
std::bitset< 32 > value_type
Definition: classic_protocol_constants.h:73
borrowable::message::server::Error< false > Error
Definition: classic_protocol_message.h:1399
borrowable::message::server::Row< false > Row
Definition: classic_protocol_message.h:1407
borrowable::message::server::Eof< false > Eof
Definition: classic_protocol_message.h:1400
borrowable::message::server::Ok< false > Ok
Definition: classic_protocol_message.h:1398
borrowable::message::server::ColumnMeta< false > ColumnMeta
Definition: classic_protocol_message.h:1403
static Value err()
Create a Value object that represents an error condition.
Definition: json_binary.cc:910
Definition: gcs_xcom_synode.h:64