MySQL 8.3.0
Source Code Documentation
classic_protocol_message.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2019, 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 MYSQL_ROUTER_CLASSIC_PROTOCOL_MESSAGE_H_
26#define MYSQL_ROUTER_CLASSIC_PROTOCOL_MESSAGE_H_
27
28#include <cstddef> // uint8_t
29#include <optional>
30#include <string>
31#include <vector>
32
36
39 public:
40 // flags of message::client::BinlogDump
41 enum class Flags : uint16_t {
42 non_blocking = 1 << 0,
43 };
44};
45} // namespace classic_protocol::message::client::impl
46
47namespace stdx {
48// enable flag-ops for BinlogDump::Flags
49template <>
50struct is_flags<classic_protocol::message::client::impl::BinlogDump::Flags>
51 : std::true_type {};
52} // namespace stdx
53 //
56 public:
57 // flags of message::client::BinlogDumpGtid
58 enum class Flags : uint16_t {
59 non_blocking = 1 << 0,
60 through_position = 1 << 1,
61 through_gtid = 1 << 2,
62 };
63};
64} // namespace classic_protocol::message::client::impl
65
66namespace stdx {
67// enable flag-ops for BinlogDumpGtid::Flags
68template <>
69struct is_flags<classic_protocol::message::client::impl::BinlogDumpGtid::Flags>
70 : std::true_type {};
71} // namespace stdx
72
73namespace classic_protocol {
74
75namespace borrowable {
76/**
77 * AuthMethod of classic protocol.
78 *
79 * classic proto supports negotiating the auth-method via capabilities and
80 * auth-method names.
81 */
82template <bool Borrowed>
84 public:
86 std::conditional_t<Borrowed, std::string_view, std::string>;
87
89 string_type auth_method_name)
90 : capabilities_{capabilities},
91 auth_method_name_{std::move(auth_method_name)} {}
92
93 constexpr string_type name() const {
94 if (auth_method_name_.empty() &&
98 return "mysql_native_password";
99 } else {
100 return "old_password";
101 }
102 }
103
104 return auth_method_name_;
105 }
106
107 private:
110};
111
112namespace message {
113
114namespace server {
115
116template <bool Borrowed>
117class Greeting {
118 public:
120 std::conditional_t<Borrowed, std::string_view, std::string>;
121
125 uint8_t collation,
129 version_{std::move(version)},
136
137 constexpr uint8_t protocol_version() const noexcept {
138 return protocol_version_;
139 }
140 void protocol_version(uint8_t val) { protocol_version_ = val; }
141
142 constexpr string_type version() const { return version_; }
143 void version(string_type val) { version_ = val; }
144
145 constexpr string_type auth_method_name() const { return auth_method_name_; }
147 constexpr string_type auth_method_data() const { return auth_method_data_; }
149
151 return capabilities_;
152 }
153
155 capabilities_ = caps;
156 }
157
158 constexpr uint8_t collation() const noexcept { return collation_; }
159 void collation(uint8_t val) { collation_ = val; }
160
162 return status_flags_;
163 }
165 status_flags_ = val;
166 }
167
168 constexpr uint32_t connection_id() const noexcept { return connection_id_; }
169 void connection_id(uint32_t val) { connection_id_ = val; }
170
171 private:
177 uint8_t collation_;
180};
181
182template <bool Borrowed>
183inline bool operator==(const Greeting<Borrowed> &a,
184 const Greeting<Borrowed> &b) {
185 return (a.protocol_version() == b.protocol_version()) &&
186 (a.version() == b.version()) &&
187 (a.connection_id() == b.connection_id()) &&
188 (a.auth_method_data() == b.auth_method_data()) &&
189 (a.capabilities() == b.capabilities()) &&
190 (a.collation() == b.collation()) &&
191 (a.status_flags() == b.status_flags()) &&
193}
194
195template <bool Borrowed>
197 public:
199 std::conditional_t<Borrowed, std::string_view, std::string>;
200
201 constexpr AuthMethodSwitch() = default;
202
205 : auth_method_{std::move(auth_method)},
207
210
211 private:
214};
215
216template <bool Borrowed>
219 return (a.auth_method_data() == b.auth_method_data()) &&
220 (a.auth_method() == b.auth_method());
221}
222
223/**
224 * Opaque auth-method-data message.
225 *
226 * used for server messages the handshake phase that aren't
227 *
228 * - Ok
229 * - Error
230 * - AuthMethodSwitch
231 *
232 * like caching_sha2_password does:
233 *
234 * - 0x01 0x02 (send public key)
235 * - 0x01 0x03 (send full handshake)
236 * - 0x01 0x04 (fast path done)
237 */
238template <bool Borrowed>
240 public:
242 std::conditional_t<Borrowed, std::string_view, std::string>;
243
246
247 constexpr string_type auth_method_data() const { return auth_method_data_; }
248
249 private:
251};
252
253template <bool Borrowed>
255 const AuthMethodData<Borrowed> &b) {
256 return a.auth_method_data() == b.auth_method_data();
257}
258
259/**
260 * Ok message.
261 *
262 * - affected_rows
263 * - last_insert_id
264 * - status_flags
265 * - warning_count
266 * - optional message
267 * - optional server-side tracked session_changes
268 */
269template <bool Borrowed>
270class Ok {
271 public:
273 std::conditional_t<Borrowed, std::string_view, std::string>;
274
275 constexpr Ok() = default;
276
277 constexpr Ok(uint64_t affected_rows, uint64_t last_insert_id,
279 uint16_t warning_count, string_type message = "",
285 message_{std::move(message)},
287
290 }
291
293 return status_flags_;
294 }
295
296 constexpr void warning_count(uint16_t count) { warning_count_ = count; }
297 constexpr uint16_t warning_count() const noexcept { return warning_count_; }
298
299 constexpr void last_insert_id(uint64_t val) { last_insert_id_ = val; }
300 constexpr uint64_t last_insert_id() const noexcept { return last_insert_id_; }
301
302 constexpr void affected_rows(uint64_t val) { affected_rows_ = val; }
303 constexpr uint64_t affected_rows() const noexcept { return affected_rows_; }
304
305 constexpr void message(const string_type &msg) { message_ = msg; }
306 constexpr string_type message() const { return message_; }
307
308 constexpr void session_changes(const string_type &changes) {
309 session_changes_ = changes;
310 }
311 /**
312 * get session-changes.
313 *
314 * @returns encoded array of session_track::Field
315 */
317
318 private:
320 uint16_t warning_count_{};
321 uint64_t last_insert_id_{};
322 uint64_t affected_rows_{};
323
326};
327
328template <bool Borrowed>
329inline bool operator==(const Ok<Borrowed> &a, const Ok<Borrowed> &b) {
330 return (a.status_flags() == b.status_flags()) &&
331 (a.warning_count() == b.warning_count()) &&
332 (a.last_insert_id() == b.last_insert_id()) &&
333 (a.affected_rows() == b.affected_rows()) &&
334 (a.message() == b.message()) &&
335 (a.session_changes() == b.session_changes());
336}
337
338/**
339 * End of Resultset message.
340 */
341template <bool Borrowed>
342class Eof : public Ok<Borrowed> {
343 public:
345 std::conditional_t<Borrowed, std::string_view, std::string>;
346
348
349 using base__::base__;
350
351 // 3.23-like constructor
352 constexpr Eof() = default;
353
354 // 4.1-like constructor
356 uint16_t warning_count)
358
363 std::move(session_changes)) {}
364};
365
366/**
367 * Error message.
368 */
369template <bool Borrowed>
370class Error {
371 public:
373 std::conditional_t<Borrowed, std::string_view, std::string>;
374
375 constexpr Error() = default;
376 /**
377 * construct an Error message.
378 *
379 * @param error_code error code
380 * @param message error message
381 * @param sql_state SQL state
382 */
383 constexpr Error(uint16_t error_code, string_type message,
384 string_type sql_state = "HY000")
386 message_{std::move(message)},
387 sql_state_{std::move(sql_state)} {}
388
389 constexpr uint16_t error_code() const noexcept { return error_code_; }
390 constexpr void error_code(uint16_t code) { error_code_ = code; }
391 constexpr string_type sql_state() const { return sql_state_; }
392 constexpr void sql_state(const string_type &state) { sql_state_ = state; }
393 constexpr string_type message() const { return message_; }
394 constexpr void message(const string_type &msg) { message_ = msg; }
395
396 private:
397 uint16_t error_code_{0};
400};
401
402template <bool Borrowed>
403inline bool operator==(const Error<Borrowed> &a, const Error<Borrowed> &b) {
404 return (a.error_code() == b.error_code()) &&
405 (a.sql_state() == b.sql_state()) && (a.message() == b.message());
406}
407
408/**
409 * ColumnCount message.
410 */
412 public:
413 /**
414 * construct an ColumnCount message.
415 *
416 * @param count column count
417 */
418 constexpr ColumnCount(uint64_t count) : count_{count} {}
419
420 constexpr uint64_t count() const noexcept { return count_; }
421
422 private:
423 uint64_t count_;
424};
425
426constexpr inline bool operator==(const ColumnCount &a, const ColumnCount &b) {
427 return (a.count() == b.count());
428}
429
430template <bool Borrowed>
432 public:
434 std::conditional_t<Borrowed, std::string_view, std::string>;
435
439 uint16_t collation, uint32_t column_length, uint8_t type,
441 uint8_t decimals)
442 : catalog_{std::move(catalog)},
443 schema_{std::move(schema)},
444 table_{std::move(table)},
445 orig_table_{std::move(orig_table)},
446 name_{std::move(name)},
447 orig_name_{std::move(orig_name)},
450 type_{type},
451 flags_{flags},
453
454 constexpr string_type catalog() const { return catalog_; }
455 constexpr string_type schema() const { return schema_; }
456 constexpr string_type table() const { return table_; }
457 constexpr string_type orig_table() const { return orig_table_; }
458 constexpr string_type name() const { return name_; }
459 constexpr string_type orig_name() const { return orig_name_; }
460 constexpr uint16_t collation() const { return collation_; }
461 constexpr uint32_t column_length() const { return column_length_; }
462 constexpr uint8_t type() const { return type_; }
464 return flags_;
465 }
466 constexpr uint8_t decimals() const { return decimals_; }
467
468 private:
475 uint16_t collation_;
477 uint8_t type_;
479 uint8_t decimals_;
480};
481
482template <bool Borrowed>
483inline bool operator==(const ColumnMeta<Borrowed> &a,
484 const ColumnMeta<Borrowed> &b) {
485 return (a.catalog() == b.catalog()) && (a.schema() == b.schema()) &&
486 (a.table() == b.table()) && (a.orig_table() == b.orig_table()) &&
487 (a.name() == b.name()) && (a.orig_name() == b.orig_name()) &&
488 (a.collation() == b.collation()) &&
489 (a.column_length() == b.column_length()) && (a.type() == b.type()) &&
490 (a.flags() == b.flags()) && (a.decimals() == b.decimals());
491}
492
493/**
494 * Row in a resultset.
495 *
496 * each Row is sent as its own frame::Frame
497 *
498 * each Field in a row may either be NULL or a std::string.
499 */
500template <bool Borrowed>
501class Row {
502 public:
504 std::conditional_t<Borrowed, std::string_view, std::string>;
505
506 using value_type = std::optional<string_type>;
507 using const_iterator = typename std::vector<value_type>::const_iterator;
508
509 Row(std::vector<value_type> fields) : fields_{std::move(fields)} {}
510
511 auto begin() const { return fields_.begin(); }
512 auto end() const { return fields_.end(); }
513
514 private:
515 std::vector<value_type> fields_;
516};
517
518template <bool Borrowed>
519inline bool operator==(const Row<Borrowed> &a, const Row<Borrowed> &b) {
520 auto a_iter = a.begin();
521 const auto a_end = a.end();
522 auto b_iter = b.begin();
523 const auto b_end = b.end();
524
525 for (; a_iter != a_end && b_iter != b_end; ++a_iter, ++b_iter) {
526 if (*a_iter != *b_iter) return false;
527 }
528
529 return true;
530}
531
532template <bool Borrowed>
534 public:
537 : column_metas_{std::move(column_metas)}, rows_{std::move(rows)} {}
538
539 std::vector<ColumnMeta<Borrowed>> column_metas() const {
540 return column_metas_;
541 }
542 std::vector<Row<Borrowed>> rows() const { return rows_; }
543
544 private:
545 std::vector<ColumnMeta<Borrowed>> column_metas_;
546 std::vector<Row<Borrowed>> rows_;
547};
548
549/**
550 * StmtPrepareOk message.
551 *
552 * response to a client::StmtPrepare
553 */
555 public:
556 /**
557 * create a Ok message for a client::StmtPrepare.
558 *
559 * @param stmt_id id of the statement
560 * @param column_count number of columns the prepared stmt will return
561 * @param param_count number of parameters the prepared stmt contained
562 * @param warning_count number of warnings the prepared stmt created
563 * @param with_metadata 0 if no metadata shall be sent for "param_count" and
564 * "column_count".
565 */
566 constexpr StmtPrepareOk(uint32_t stmt_id, uint16_t column_count,
567 uint16_t param_count, uint16_t warning_count,
568 uint8_t with_metadata)
569 : statement_id_{stmt_id},
574
575 constexpr uint32_t statement_id() const noexcept { return statement_id_; }
576 constexpr void statement_id(uint32_t id) noexcept { statement_id_ = id; }
577 constexpr uint16_t warning_count() const noexcept { return warning_count_; }
578 constexpr void warning_count(uint16_t cnt) noexcept { warning_count_ = cnt; }
579
580 constexpr uint16_t column_count() const noexcept { return column_count_; }
581 constexpr void column_count(uint16_t cnt) noexcept { column_count_ = cnt; }
582 constexpr uint16_t param_count() const noexcept { return param_count_; }
583 constexpr void param_count(uint16_t cnt) noexcept { param_count_ = cnt; }
584 constexpr uint8_t with_metadata() const noexcept { return with_metadata_; }
585 constexpr void with_metadata(uint8_t with) noexcept { with_metadata_ = with; }
586
587 friend constexpr bool operator==(const StmtPrepareOk &lhs,
588 const StmtPrepareOk &rhs) {
589 return (lhs.statement_id() == rhs.statement_id()) &&
590 (lhs.column_count() == rhs.column_count()) &&
591 (lhs.param_count() == rhs.param_count()) &&
592 (lhs.warning_count() == rhs.warning_count()) &&
593 (lhs.with_metadata() == rhs.with_metadata());
594 }
595
596 private:
599 uint16_t param_count_;
602};
603
604/**
605 * StmtRow message.
606 *
607 * holds the same information as a Row.
608 *
609 * needs 'types' to be able to encode a Field of the Row.
610 */
611template <bool Borrowed>
612class StmtRow : public Row<Borrowed> {
613 public:
615
617
618 StmtRow(std::vector<field_type::value_type> types,
619 std::vector<value_type> fields)
620 : base_{std::move(fields)}, types_{std::move(types)} {}
621
622 std::vector<field_type::value_type> types() const { return types_; }
623
624 private:
625 std::vector<field_type::value_type> types_;
626};
627
628template <bool Borrowed>
630 public:
632 std::conditional_t<Borrowed, std::string_view, std::string>;
633 /**
634 * construct a SendFileRequest message.
635 *
636 * @param filename filename
637 */
639 : filename_{std::move(filename)} {}
640
641 constexpr string_type filename() const { return filename_; }
642
643 private:
645};
646
647template <bool Borrowed>
648constexpr bool operator==(const SendFileRequest<Borrowed> &a,
649 const SendFileRequest<Borrowed> &b) {
650 return a.filename() == b.filename();
651}
652
653template <bool Borrowed>
655 public:
657 std::conditional_t<Borrowed, std::string_view, std::string>;
658
659 /**
660 * construct a Statistics message.
661 *
662 * @param stats statistics
663 */
664 constexpr Statistics(string_type stats) : stats_{std::move(stats)} {}
665
666 constexpr string_type stats() const { return stats_; }
667
668 private:
670};
671
672template <bool Borrowed>
673constexpr bool operator==(const Statistics<Borrowed> &a,
674 const Statistics<Borrowed> &b) {
675 return a.stats() == b.stats();
676}
677
678} // namespace server
679
680namespace client {
681
682template <bool Borrowed>
683class Greeting {
684 public:
686 std::conditional_t<Borrowed, std::string_view, std::string>;
687
688 /**
689 * construct a client::Greeting message.
690 *
691 * @param capabilities protocol capabilities of the client
692 * @param max_packet_size max size of the frame::Frame client wants to send
693 * @param collation initial collation of connection
694 * @param username username to authenticate as
695 * @param auth_method_data auth-method specific data like hashed password
696 * @param schema initial schema of the newly authenticated session
697 * @param auth_method_name auth-method the data is for
698 * @param attributes session-attributes
699 */
701 uint32_t max_packet_size, uint8_t collation,
708 username_{std::move(username)},
710 schema_{std::move(schema)},
712 attributes_{std::move(attributes)} {}
713
715 return capabilities_;
716 }
717
719 capabilities_ = caps;
720 }
721
722 constexpr uint32_t max_packet_size() const noexcept {
723 return max_packet_size_;
724 }
725 constexpr void max_packet_size(uint32_t sz) noexcept {
726 max_packet_size_ = sz;
727 }
728
729 constexpr uint8_t collation() const noexcept { return collation_; }
730 constexpr void collation(uint8_t coll) noexcept { collation_ = coll; }
731
732 constexpr string_type username() const { return username_; }
733 constexpr void username(const string_type &v) { username_ = v; }
734
735 constexpr string_type auth_method_data() const { return auth_method_data_; }
736 constexpr void auth_method_data(const string_type &v) {
738 }
739
740 constexpr string_type schema() const { return schema_; }
741 constexpr void schema(const string_type &schema) { schema_ = schema; }
742
743 /**
744 * name of the auth-method that was explicitly set.
745 *
746 * use classic_protocol::AuthMethod() to get the effective auth-method
747 * which may be announced though capability flags (like if
748 * capabilities::plugin_auth wasn't set)
749 */
750 constexpr string_type auth_method_name() const { return auth_method_name_; }
751
752 constexpr void auth_method_name(const string_type &name) {
754 }
755
756 // [key, value]* in Codec<wire::VarString> encoding
757 constexpr string_type attributes() const { return attributes_; }
758
759 constexpr void attributes(const string_type &attrs) { attributes_ = attrs; }
760
761 private:
764 uint8_t collation_;
770};
771
772template <bool Borrowed>
773constexpr bool operator==(const Greeting<Borrowed> &a,
774 const Greeting<Borrowed> &b) {
775 return (a.capabilities() == b.capabilities()) &&
776 (a.max_packet_size() == b.max_packet_size()) &&
777 (a.collation() == b.collation()) && (a.username() == b.username()) &&
778 (a.auth_method_data() == b.auth_method_data()) &&
779 (a.schema() == b.schema()) &&
780 (a.auth_method_name() == b.auth_method_name()) &&
781 (a.attributes() == b.attributes());
782}
783
784template <bool Borrowed>
785class Query {
786 public:
788 std::conditional_t<Borrowed, std::string_view, std::string>;
789
790 struct Param {
793 std::optional<string_type> value;
794
795 Param(uint16_t t, string_type n, std::optional<string_type> v)
796 : type_and_flags(t), name(std::move(n)), value(std::move(v)) {}
797 };
798
800
801 /**
802 * construct a Query message with values.
803 *
804 * @param statement statement to query
805 * @param values values for statement
806 */
807 Query(string_type statement, std::vector<Param> values)
808 : statement_{std::move(statement)}, values_(std::move(values)) {}
809
810 constexpr string_type statement() const { return statement_; }
811
812 std::vector<Param> values() const { return values_; }
813
814 private:
816 std::vector<Param> values_;
817};
818
819template <bool Borrowed>
820constexpr bool operator==(const Query<Borrowed> &a, const Query<Borrowed> &b) {
821 return a.statement() == b.statement();
822}
823
824template <bool Borrowed>
826 public:
828 std::conditional_t<Borrowed, std::string_view, std::string>;
829
830 /**
831 * list columns of a table.
832 *
833 * If 'wildcard' is empty the server will execute:
834 *
835 * SHOW COLUMNS FROM table_name
836 *
837 * Otherwise:
838 *
839 * SHOW COLUMNS FROM table_name LIKE wildcard
840 *
841 * @param table_name name of table to list
842 * @param wildcard wildcard
843 */
845 : table_name_{std::move(table_name)}, wildcard_{std::move(wildcard)} {}
846
847 constexpr string_type table_name() const { return table_name_; }
848 constexpr string_type wildcard() const { return wildcard_; }
849
850 private:
853};
854
855template <bool Borrowed>
856constexpr bool operator==(const ListFields<Borrowed> &a,
857 const ListFields<Borrowed> &b) {
858 return a.table_name() == b.table_name() && a.wildcard() == b.wildcard();
859}
860
861template <bool Borrowed>
863 public:
865 std::conditional_t<Borrowed, std::string_view, std::string>;
866
867 /**
868 * construct a InitSchema message.
869 *
870 * @param schema schema to change to
871 */
873
874 constexpr string_type schema() const { return schema_; }
875
876 private:
878};
879
880template <bool Borrowed>
881constexpr bool operator==(const InitSchema<Borrowed> &a,
882 const InitSchema<Borrowed> &b) {
883 return a.schema() == b.schema();
884}
885
886template <bool Borrowed>
888 public:
890 std::conditional_t<Borrowed, std::string_view, std::string>;
891 /**
892 * construct a ChangeUser message.
893 *
894 * @param username username to change to
895 * @param auth_method_data auth-method specific data like hashed password
896 * @param schema initial schema of the newly authenticated session
897 * @param auth_method_name auth-method the data is for
898 * @param collation collation
899 * @param attributes session-attributes
900 */
902 string_type schema, uint16_t collation,
904 : username_{std::move(username)},
906 schema_{std::move(schema)},
909 attributes_{std::move(attributes)} {}
910
911 constexpr uint8_t collation() const noexcept { return collation_; }
912 constexpr string_type username() const { return username_; }
913 constexpr string_type auth_method_data() const { return auth_method_data_; }
914 constexpr string_type schema() const { return schema_; }
915 constexpr string_type auth_method_name() const { return auth_method_name_; }
916
917 // [key, value]* in Codec<wire::VarString> encoding
918 constexpr string_type attributes() const { return attributes_; }
919
920 private:
924 uint16_t collation_;
927};
928
929template <bool Borrowed>
930constexpr bool operator==(const ChangeUser<Borrowed> &a,
931 const ChangeUser<Borrowed> &b) {
932 return (a.collation() == b.collation()) && (a.username() == b.username()) &&
933 (a.auth_method_data() == b.auth_method_data()) &&
934 (a.schema() == b.schema()) &&
935 (a.auth_method_name() == b.auth_method_name()) &&
936 (a.attributes() == b.attributes());
937}
938
939// no content
941
942constexpr bool operator==(const ResetConnection &, const ResetConnection &) {
943 return true;
944}
945
946// no content
947class Statistics {};
948
949constexpr bool operator==(const Statistics &, const Statistics &) {
950 return true;
951}
952
953class Reload {
954 public:
955 /**
956 * construct a Reload message.
957 *
958 * @param cmds what to reload
959 */
961 : cmds_{cmds} {}
962
964 return cmds_;
965 }
966
967 private:
969};
970
971inline bool operator==(const Reload &a, const Reload &b) {
972 return a.cmds() == b.cmds();
973}
974
975class Kill {
976 public:
977 /**
978 * construct a Kill message.
979 *
980 * @param connection_id payload
981 */
983
984 constexpr uint32_t connection_id() const { return connection_id_; }
985
986 private:
988};
989
990constexpr bool operator==(const Kill &a, const Kill &b) {
991 return a.connection_id() == b.connection_id();
992}
993
994template <bool Borrowed>
995class SendFile {
996 public:
998 std::conditional_t<Borrowed, std::string_view, std::string>;
999
1000 /**
1001 * construct a SendFile message.
1002 *
1003 * @param payload payload
1004 */
1006
1007 constexpr string_type payload() const { return payload_; }
1008
1009 private:
1011};
1012
1013template <bool Borrowed>
1014inline bool operator==(const SendFile<Borrowed> &a,
1015 const SendFile<Borrowed> &b) {
1016 return a.payload() == b.payload();
1017}
1018
1019template <bool Borrowed>
1021 public:
1023 std::conditional_t<Borrowed, std::string_view, std::string>;
1024 /**
1025 * construct a PrepareStmt message.
1026 *
1027 * @param statement statement to prepare
1028 */
1030 : statement_{std::move(statement)} {}
1031
1032 constexpr string_type statement() const { return statement_; }
1033
1034 private:
1036};
1037
1038template <bool Borrowed>
1040 const StmtPrepare<Borrowed> &b) {
1041 return a.statement() == b.statement();
1042}
1043
1044/**
1045 * append data to a parameter of a prepared statement.
1046 */
1047template <bool Borrowed>
1049 public:
1051 std::conditional_t<Borrowed, std::string_view, std::string>;
1052
1053 /**
1054 * construct an append-data-to-parameter message.
1055 *
1056 * @param statement_id statement-id to close
1057 * @param param_id parameter-id to append data to
1058 * @param data data to append to param_id of statement_id
1059 */
1060 constexpr StmtParamAppendData(uint32_t statement_id, uint16_t param_id,
1064 data_{std::move(data)} {}
1065
1066 constexpr uint32_t statement_id() const { return statement_id_; }
1067 constexpr uint16_t param_id() const { return param_id_; }
1068 constexpr string_type data() const { return data_; }
1069
1070 private:
1072 uint16_t param_id_;
1074};
1075
1076template <bool Borrowed>
1079 return a.statement_id() == b.statement_id() && a.param_id() == b.param_id() &&
1080 a.data() == b.data();
1081}
1082
1083/**
1084 * execute a prepared statement.
1085 *
1086 * 'values' raw bytes as encoded by the binary codec
1087 */
1088template <bool Borrowed>
1090 public:
1092 std::conditional_t<Borrowed, std::string_view, std::string>;
1093
1094 using value_type = std::optional<string_type>;
1095
1096 struct ParamDef {
1097 ParamDef() = default;
1098
1099 ParamDef(uint16_t type_and_flags_) : type_and_flags(type_and_flags_) {}
1100
1101 ParamDef(uint16_t type_and_flags_, string_type name_,
1102 bool param_already_sent_ = false)
1103 : type_and_flags(type_and_flags_),
1104 name(std::move(name_)),
1105 param_already_sent(param_already_sent_) {}
1106
1107 friend bool operator==(const ParamDef &lhs, const ParamDef &rhs) {
1108 return lhs.type_and_flags == rhs.type_and_flags && lhs.name == rhs.name;
1109 }
1110
1111 uint16_t type_and_flags{};
1112
1114
1115 // param already send via stmt_param_append_data
1117 };
1118
1119 /**
1120 * construct a ExecuteStmt message.
1121 *
1122 * @param statement_id statement id
1123 * @param flags cursor flags
1124 * @param iteration_count iteration_count
1125 * @param new_params_bound new params bound
1126 * @param types field types of the parameters
1127 * @param values binary-encoded values without length-bytes
1128 */
1130 uint32_t iteration_count, bool new_params_bound,
1131 std::vector<ParamDef> types, std::vector<value_type> values)
1133 flags_{flags},
1136 types_{std::move(types)},
1137 values_{std::move(values)} {}
1138
1139 uint32_t statement_id() const noexcept { return statement_id_; }
1141 uint32_t iteration_count() const noexcept { return iteration_count_; }
1142 bool new_params_bound() const noexcept { return new_params_bound_; }
1143 std::vector<ParamDef> types() const { return types_; }
1144 std::vector<value_type> values() const { return values_; }
1145
1146 private:
1151 std::vector<ParamDef> types_;
1152 std::vector<value_type> values_;
1153};
1154
1155template <bool Borrowed>
1157 const StmtExecute<Borrowed> &b) {
1158 return a.statement_id() == b.statement_id() && a.flags() == b.flags() &&
1159 a.iteration_count() == b.iteration_count() &&
1161 a.types() == b.types() && a.values() == b.values();
1162}
1163
1164/**
1165 * close a prepared statement.
1166 */
1168 public:
1169 /**
1170 * construct a StmtClose message.
1171 *
1172 * @param statement_id statement-id to close
1173 */
1175
1176 constexpr uint32_t statement_id() const { return statement_id_; }
1177
1178 private:
1180};
1181
1182constexpr bool operator==(const StmtClose &a, const StmtClose &b) {
1183 return a.statement_id() == b.statement_id();
1184}
1185
1186/**
1187 * reset a prepared statement.
1188 */
1190 public:
1191 /**
1192 * construct a ResetStmt message.
1193 *
1194 * @param statement_id statement-id to close
1195 */
1197
1198 constexpr uint32_t statement_id() const { return statement_id_; }
1199
1200 private:
1202};
1203
1204constexpr bool operator==(const StmtReset &a, const StmtReset &b) {
1205 return a.statement_id() == b.statement_id();
1206}
1207
1208/**
1209 * fetch rows from an executed statement.
1210 */
1212 public:
1213 /**
1214 * construct a ResetStmt message.
1215 *
1216 * @param statement_id statement-id to close
1217 * @param row_count statement-id to close
1218 */
1219 constexpr StmtFetch(uint32_t statement_id, uint32_t row_count)
1221
1222 constexpr uint32_t statement_id() const { return statement_id_; }
1223 constexpr uint32_t row_count() const { return row_count_; }
1224
1225 private:
1227 uint32_t row_count_;
1228};
1229
1230constexpr bool operator==(const StmtFetch &a, const StmtFetch &b) {
1231 return a.statement_id() == b.statement_id() && a.row_count() == b.row_count();
1232}
1233
1234/**
1235 * set options on the current connection.
1236 */
1238 public:
1239 /**
1240 * construct a SetOption message.
1241 *
1242 * @param option options to set
1243 */
1244 constexpr SetOption(uint16_t option) : option_{option} {}
1245
1246 constexpr uint16_t option() const { return option_; }
1247
1248 private:
1249 uint16_t option_;
1250};
1251
1252constexpr bool operator==(const SetOption &a, const SetOption &b) {
1253 return a.option() == b.option();
1254}
1255
1256// no content
1257class Quit {};
1258
1259constexpr bool operator==(const Quit &, const Quit &) { return true; }
1260
1261// no content
1262class Ping {};
1263
1264constexpr bool operator==(const Ping &, const Ping &) { return true; }
1265
1266// no content
1267class Debug {};
1268
1269constexpr bool operator==(const Debug &, const Debug &) { return true; }
1270
1271template <bool Borrowed>
1273 public:
1275 std::conditional_t<Borrowed, std::string_view, std::string>;
1276
1277 /**
1278 * send data for the current auth-method to server.
1279 *
1280 * @param auth_method_data data of the auth-method
1281 */
1284
1285 constexpr string_type auth_method_data() const { return auth_method_data_; }
1286
1287 private:
1289};
1290
1291template <bool Borrowed>
1292constexpr bool operator==(const AuthMethodData<Borrowed> &a,
1293 const AuthMethodData<Borrowed> &b) {
1294 return a.auth_method_data() == b.auth_method_data();
1295}
1296
1297// switch to Clone Protocol.
1298//
1299// response: server::Ok -> clone protocol
1300// response: server::Error
1301//
1302// no content
1303class Clone {};
1304
1305template <bool Borrowed>
1307 public:
1309 std::conditional_t<Borrowed, std::string_view, std::string>;
1310
1311 using Flags =
1313
1315 string_type filename, uint32_t position)
1317 flags_{flags},
1319 filename_{std::move(filename)} {}
1320
1321 [[nodiscard]] constexpr stdx::flags<Flags> flags() const { return flags_; }
1322 [[nodiscard]] constexpr uint32_t server_id() const { return server_id_; }
1323 [[nodiscard]] constexpr string_type filename() const { return filename_; }
1324 [[nodiscard]] constexpr uint64_t position() const { return position_; }
1325
1326 private:
1327 uint32_t position_;
1329 uint32_t server_id_;
1331};
1332
1333template <bool Borrowed>
1335 public:
1337 std::conditional_t<Borrowed, std::string_view, std::string>;
1338
1339 using Flags =
1341
1343 string_type filename, uint64_t position,
1345 : flags_{flags},
1347 filename_{std::move(filename)},
1349 sids_{std::move(sids)} {}
1350
1351 [[nodiscard]] constexpr stdx::flags<Flags> flags() const { return flags_; }
1352 [[nodiscard]] constexpr uint32_t server_id() const { return server_id_; }
1353 [[nodiscard]] constexpr string_type filename() const { return filename_; }
1354 [[nodiscard]] constexpr uint64_t position() const { return position_; }
1355 [[nodiscard]] constexpr string_type sids() const { return sids_; }
1356
1357 private:
1359 uint32_t server_id_;
1361 uint64_t position_;
1363};
1364
1365template <bool Borrowed>
1367 public:
1369 std::conditional_t<Borrowed, std::string_view, std::string>;
1370
1373 uint16_t port, uint32_t replication_rank,
1374 uint32_t master_id)
1376 hostname_{std::move(hostname)},
1377 username_{std::move(username)},
1378 password_{std::move(password)},
1379 port_{port},
1382
1383 [[nodiscard]] constexpr uint32_t server_id() const { return server_id_; }
1384 [[nodiscard]] constexpr string_type hostname() const { return hostname_; }
1385 [[nodiscard]] constexpr string_type username() const { return username_; }
1386 [[nodiscard]] constexpr string_type password() const { return password_; }
1387 [[nodiscard]] constexpr uint16_t port() const { return port_; }
1388 [[nodiscard]] constexpr uint32_t replication_rank() const {
1389 return replication_rank_;
1390 }
1391 [[nodiscard]] constexpr uint32_t master_id() const { return master_id_; }
1392
1393 private:
1394 uint32_t server_id_;
1398 uint16_t port_;
1400 uint32_t master_id_;
1401};
1402
1403} // namespace client
1404} // namespace message
1405} // namespace borrowable
1406
1407namespace message {
1408namespace server {
1409using Ok = borrowable::message::server::Ok<false>;
1410using Error = borrowable::message::server::Error<false>;
1411using Eof = borrowable::message::server::Eof<false>;
1412using Greeting = borrowable::message::server::Greeting<false>;
1414using ColumnMeta = borrowable::message::server::ColumnMeta<false>;
1415using AuthMethodSwitch = borrowable::message::server::AuthMethodSwitch<false>;
1416using AuthMethodData = borrowable::message::server::AuthMethodData<false>;
1417using SendFileRequest = borrowable::message::server::SendFileRequest<false>;
1418using Row = borrowable::message::server::Row<false>;
1419using StmtRow = borrowable::message::server::StmtRow<false>;
1421using Statistics = borrowable::message::server::Statistics<false>;
1422} // namespace server
1423
1424namespace client {
1451} // namespace client
1452} // namespace message
1453
1454namespace borrowed {
1455namespace message {
1456namespace server {
1457using Ok = borrowable::message::server::Ok<true>;
1458using Error = borrowable::message::server::Error<true>;
1459using Eof = borrowable::message::server::Eof<true>;
1460using Greeting = borrowable::message::server::Greeting<true>;
1462using ColumnMeta = borrowable::message::server::ColumnMeta<true>;
1463using AuthMethodSwitch = borrowable::message::server::AuthMethodSwitch<true>;
1464using AuthMethodData = borrowable::message::server::AuthMethodData<true>;
1465using SendFileRequest = borrowable::message::server::SendFileRequest<true>;
1466using Row = borrowable::message::server::Row<true>;
1467using StmtRow = borrowable::message::server::StmtRow<true>;
1469using Statistics = borrowable::message::server::Statistics<true>;
1470} // namespace server
1471
1472namespace client {
1499} // namespace client
1500} // namespace message
1501} // namespace borrowed
1502
1503} // namespace classic_protocol
1504
1505#endif
Class representing an error.
Definition: error.h:47
AuthMethod of classic protocol.
Definition: classic_protocol_message.h:83
constexpr string_type name() const
Definition: classic_protocol_message.h:93
const classic_protocol::capabilities::value_type capabilities_
Definition: classic_protocol_message.h:108
const string_type auth_method_name_
Definition: classic_protocol_message.h:109
std::conditional_t< Borrowed, std::string_view, std::string > string_type
Definition: classic_protocol_message.h:86
AuthMethod(classic_protocol::capabilities::value_type capabilities, string_type auth_method_name)
Definition: classic_protocol_message.h:88
Definition: classic_protocol_message.h:1272
constexpr string_type auth_method_data() const
Definition: classic_protocol_message.h:1285
string_type auth_method_data_
Definition: classic_protocol_message.h:1288
std::conditional_t< Borrowed, std::string_view, std::string > string_type
Definition: classic_protocol_message.h:1275
constexpr AuthMethodData(string_type auth_method_data)
send data for the current auth-method to server.
Definition: classic_protocol_message.h:1282
Definition: classic_protocol_message.h:1334
constexpr uint64_t position() const
Definition: classic_protocol_message.h:1354
constexpr stdx::flags< Flags > flags() const
Definition: classic_protocol_message.h:1351
string_type filename_
Definition: classic_protocol_message.h:1360
uint32_t server_id_
Definition: classic_protocol_message.h:1359
std::conditional_t< Borrowed, std::string_view, std::string > string_type
Definition: classic_protocol_message.h:1337
stdx::flags< Flags > flags_
Definition: classic_protocol_message.h:1358
constexpr string_type sids() const
Definition: classic_protocol_message.h:1355
string_type sids_
Definition: classic_protocol_message.h:1362
constexpr string_type filename() const
Definition: classic_protocol_message.h:1353
typename classic_protocol::message::client::impl::BinlogDumpGtid::Flags Flags
Definition: classic_protocol_message.h:1340
uint64_t position_
Definition: classic_protocol_message.h:1361
constexpr uint32_t server_id() const
Definition: classic_protocol_message.h:1352
constexpr BinlogDumpGtid(stdx::flags< Flags > flags, uint32_t server_id, string_type filename, uint64_t position, string_type sids)
Definition: classic_protocol_message.h:1342
Definition: classic_protocol_message.h:1306
constexpr stdx::flags< Flags > flags() const
Definition: classic_protocol_message.h:1321
string_type filename_
Definition: classic_protocol_message.h:1330
uint32_t server_id_
Definition: classic_protocol_message.h:1329
constexpr uint64_t position() const
Definition: classic_protocol_message.h:1324
stdx::flags< Flags > flags_
Definition: classic_protocol_message.h:1328
uint32_t position_
Definition: classic_protocol_message.h:1327
constexpr BinlogDump(stdx::flags< Flags > flags, uint32_t server_id, string_type filename, uint32_t position)
Definition: classic_protocol_message.h:1314
std::conditional_t< Borrowed, std::string_view, std::string > string_type
Definition: classic_protocol_message.h:1309
constexpr uint32_t server_id() const
Definition: classic_protocol_message.h:1322
constexpr string_type filename() const
Definition: classic_protocol_message.h:1323
typename classic_protocol::message::client::impl::BinlogDump::Flags Flags
Definition: classic_protocol_message.h:1312
Definition: classic_protocol_message.h:887
constexpr ChangeUser(string_type username, string_type auth_method_data, string_type schema, uint16_t collation, string_type auth_method_name, string_type attributes)
construct a ChangeUser message.
Definition: classic_protocol_message.h:901
string_type attributes_
Definition: classic_protocol_message.h:926
std::conditional_t< Borrowed, std::string_view, std::string > string_type
Definition: classic_protocol_message.h:890
string_type username_
Definition: classic_protocol_message.h:921
constexpr string_type attributes() const
Definition: classic_protocol_message.h:918
uint16_t collation_
Definition: classic_protocol_message.h:924
constexpr string_type auth_method_name() const
Definition: classic_protocol_message.h:915
constexpr uint8_t collation() const noexcept
Definition: classic_protocol_message.h:911
string_type auth_method_data_
Definition: classic_protocol_message.h:922
constexpr string_type username() const
Definition: classic_protocol_message.h:912
constexpr string_type auth_method_data() const
Definition: classic_protocol_message.h:913
constexpr string_type schema() const
Definition: classic_protocol_message.h:914
string_type schema_
Definition: classic_protocol_message.h:923
string_type auth_method_name_
Definition: classic_protocol_message.h:925
Definition: classic_protocol_message.h:1303
Definition: classic_protocol_message.h:1267
Definition: classic_protocol_message.h:683
constexpr string_type schema() const
Definition: classic_protocol_message.h:740
constexpr void schema(const string_type &schema)
Definition: classic_protocol_message.h:741
constexpr string_type auth_method_data() const
Definition: classic_protocol_message.h:735
string_type auth_method_name_
Definition: classic_protocol_message.h:768
constexpr void capabilities(classic_protocol::capabilities::value_type caps)
Definition: classic_protocol_message.h:718
uint32_t max_packet_size_
Definition: classic_protocol_message.h:763
constexpr string_type auth_method_name() const
name of the auth-method that was explicitly set.
Definition: classic_protocol_message.h:750
std::conditional_t< Borrowed, std::string_view, std::string > string_type
Definition: classic_protocol_message.h:686
uint8_t collation_
Definition: classic_protocol_message.h:764
constexpr void collation(uint8_t coll) noexcept
Definition: classic_protocol_message.h:730
constexpr uint8_t collation() const noexcept
Definition: classic_protocol_message.h:729
string_type username_
Definition: classic_protocol_message.h:765
constexpr void username(const string_type &v)
Definition: classic_protocol_message.h:733
constexpr Greeting(classic_protocol::capabilities::value_type capabilities, uint32_t max_packet_size, uint8_t collation, string_type username, string_type auth_method_data, string_type schema, string_type auth_method_name, string_type attributes)
construct a client::Greeting message.
Definition: classic_protocol_message.h:700
constexpr classic_protocol::capabilities::value_type capabilities() const
Definition: classic_protocol_message.h:714
constexpr void max_packet_size(uint32_t sz) noexcept
Definition: classic_protocol_message.h:725
constexpr void auth_method_data(const string_type &v)
Definition: classic_protocol_message.h:736
string_type attributes_
Definition: classic_protocol_message.h:769
constexpr uint32_t max_packet_size() const noexcept
Definition: classic_protocol_message.h:722
constexpr void attributes(const string_type &attrs)
Definition: classic_protocol_message.h:759
constexpr string_type attributes() const
Definition: classic_protocol_message.h:757
constexpr string_type username() const
Definition: classic_protocol_message.h:732
classic_protocol::capabilities::value_type capabilities_
Definition: classic_protocol_message.h:762
string_type auth_method_data_
Definition: classic_protocol_message.h:766
constexpr void auth_method_name(const string_type &name)
Definition: classic_protocol_message.h:752
string_type schema_
Definition: classic_protocol_message.h:767
Definition: classic_protocol_message.h:862
string_type schema_
Definition: classic_protocol_message.h:877
constexpr InitSchema(string_type schema)
construct a InitSchema message.
Definition: classic_protocol_message.h:872
constexpr string_type schema() const
Definition: classic_protocol_message.h:874
std::conditional_t< Borrowed, std::string_view, std::string > string_type
Definition: classic_protocol_message.h:865
Definition: classic_protocol_message.h:975
uint32_t connection_id_
Definition: classic_protocol_message.h:987
constexpr uint32_t connection_id() const
Definition: classic_protocol_message.h:984
constexpr Kill(uint32_t connection_id)
construct a Kill message.
Definition: classic_protocol_message.h:982
Definition: classic_protocol_message.h:825
constexpr string_type table_name() const
Definition: classic_protocol_message.h:847
constexpr ListFields(string_type table_name, string_type wildcard)
list columns of a table.
Definition: classic_protocol_message.h:844
string_type table_name_
Definition: classic_protocol_message.h:851
constexpr string_type wildcard() const
Definition: classic_protocol_message.h:848
string_type wildcard_
Definition: classic_protocol_message.h:852
std::conditional_t< Borrowed, std::string_view, std::string > string_type
Definition: classic_protocol_message.h:828
Definition: classic_protocol_message.h:1262
Definition: classic_protocol_message.h:785
std::conditional_t< Borrowed, std::string_view, std::string > string_type
Definition: classic_protocol_message.h:788
constexpr string_type statement() const
Definition: classic_protocol_message.h:810
string_type statement_
Definition: classic_protocol_message.h:815
Query(string_type statement)
Definition: classic_protocol_message.h:799
Query(string_type statement, std::vector< Param > values)
construct a Query message with values.
Definition: classic_protocol_message.h:807
std::vector< Param > values_
Definition: classic_protocol_message.h:816
std::vector< Param > values() const
Definition: classic_protocol_message.h:812
Definition: classic_protocol_message.h:1257
Definition: classic_protocol_message.h:1366
std::conditional_t< Borrowed, std::string_view, std::string > string_type
Definition: classic_protocol_message.h:1369
uint32_t server_id_
Definition: classic_protocol_message.h:1394
string_type password_
Definition: classic_protocol_message.h:1397
constexpr RegisterReplica(uint32_t server_id, string_type hostname, string_type username, string_type password, uint16_t port, uint32_t replication_rank, uint32_t master_id)
Definition: classic_protocol_message.h:1371
constexpr string_type password() const
Definition: classic_protocol_message.h:1386
uint32_t replication_rank_
Definition: classic_protocol_message.h:1399
uint16_t port_
Definition: classic_protocol_message.h:1398
constexpr uint32_t master_id() const
Definition: classic_protocol_message.h:1391
constexpr uint32_t replication_rank() const
Definition: classic_protocol_message.h:1388
constexpr uint32_t server_id() const
Definition: classic_protocol_message.h:1383
constexpr string_type username() const
Definition: classic_protocol_message.h:1385
constexpr string_type hostname() const
Definition: classic_protocol_message.h:1384
string_type username_
Definition: classic_protocol_message.h:1396
string_type hostname_
Definition: classic_protocol_message.h:1395
uint32_t master_id_
Definition: classic_protocol_message.h:1400
constexpr uint16_t port() const
Definition: classic_protocol_message.h:1387
Definition: classic_protocol_message.h:953
classic_protocol::reload_cmds::value_type cmds_
Definition: classic_protocol_message.h:968
constexpr Reload(classic_protocol::reload_cmds::value_type cmds)
construct a Reload message.
Definition: classic_protocol_message.h:960
constexpr classic_protocol::reload_cmds::value_type cmds() const
Definition: classic_protocol_message.h:963
Definition: classic_protocol_message.h:940
Definition: classic_protocol_message.h:995
constexpr string_type payload() const
Definition: classic_protocol_message.h:1007
string_type payload_
Definition: classic_protocol_message.h:1010
std::conditional_t< Borrowed, std::string_view, std::string > string_type
Definition: classic_protocol_message.h:998
constexpr SendFile(string_type payload)
construct a SendFile message.
Definition: classic_protocol_message.h:1005
set options on the current connection.
Definition: classic_protocol_message.h:1237
constexpr SetOption(uint16_t option)
construct a SetOption message.
Definition: classic_protocol_message.h:1244
constexpr uint16_t option() const
Definition: classic_protocol_message.h:1246
uint16_t option_
Definition: classic_protocol_message.h:1249
Definition: classic_protocol_message.h:947
close a prepared statement.
Definition: classic_protocol_message.h:1167
constexpr uint32_t statement_id() const
Definition: classic_protocol_message.h:1176
constexpr StmtClose(uint32_t statement_id)
construct a StmtClose message.
Definition: classic_protocol_message.h:1174
uint32_t statement_id_
Definition: classic_protocol_message.h:1179
execute a prepared statement.
Definition: classic_protocol_message.h:1089
bool new_params_bound() const noexcept
Definition: classic_protocol_message.h:1142
std::vector< value_type > values_
Definition: classic_protocol_message.h:1152
std::optional< string_type > value_type
Definition: classic_protocol_message.h:1094
uint32_t iteration_count() const noexcept
Definition: classic_protocol_message.h:1141
std::vector< value_type > values() const
Definition: classic_protocol_message.h:1144
std::conditional_t< Borrowed, std::string_view, std::string > string_type
Definition: classic_protocol_message.h:1092
uint32_t statement_id_
Definition: classic_protocol_message.h:1147
bool new_params_bound_
Definition: classic_protocol_message.h:1150
std::vector< ParamDef > types_
Definition: classic_protocol_message.h:1151
uint32_t statement_id() const noexcept
Definition: classic_protocol_message.h:1139
uint32_t iteration_count_
Definition: classic_protocol_message.h:1149
StmtExecute(uint32_t statement_id, classic_protocol::cursor::value_type flags, uint32_t iteration_count, bool new_params_bound, std::vector< ParamDef > types, std::vector< value_type > values)
construct a ExecuteStmt message.
Definition: classic_protocol_message.h:1129
classic_protocol::cursor::value_type flags() const noexcept
Definition: classic_protocol_message.h:1140
std::vector< ParamDef > types() const
Definition: classic_protocol_message.h:1143
classic_protocol::cursor::value_type flags_
Definition: classic_protocol_message.h:1148
fetch rows from an executed statement.
Definition: classic_protocol_message.h:1211
constexpr uint32_t row_count() const
Definition: classic_protocol_message.h:1223
uint32_t row_count_
Definition: classic_protocol_message.h:1227
constexpr uint32_t statement_id() const
Definition: classic_protocol_message.h:1222
uint32_t statement_id_
Definition: classic_protocol_message.h:1226
constexpr StmtFetch(uint32_t statement_id, uint32_t row_count)
construct a ResetStmt message.
Definition: classic_protocol_message.h:1219
append data to a parameter of a prepared statement.
Definition: classic_protocol_message.h:1048
constexpr string_type data() const
Definition: classic_protocol_message.h:1068
string_type data_
Definition: classic_protocol_message.h:1073
uint16_t param_id_
Definition: classic_protocol_message.h:1072
constexpr uint32_t statement_id() const
Definition: classic_protocol_message.h:1066
constexpr StmtParamAppendData(uint32_t statement_id, uint16_t param_id, string_type data)
construct an append-data-to-parameter message.
Definition: classic_protocol_message.h:1060
std::conditional_t< Borrowed, std::string_view, std::string > string_type
Definition: classic_protocol_message.h:1051
constexpr uint16_t param_id() const
Definition: classic_protocol_message.h:1067
uint32_t statement_id_
Definition: classic_protocol_message.h:1071
Definition: classic_protocol_message.h:1020
constexpr StmtPrepare(string_type statement)
construct a PrepareStmt message.
Definition: classic_protocol_message.h:1029
string_type statement_
Definition: classic_protocol_message.h:1035
std::conditional_t< Borrowed, std::string_view, std::string > string_type
Definition: classic_protocol_message.h:1023
constexpr string_type statement() const
Definition: classic_protocol_message.h:1032
reset a prepared statement.
Definition: classic_protocol_message.h:1189
uint32_t statement_id_
Definition: classic_protocol_message.h:1201
constexpr uint32_t statement_id() const
Definition: classic_protocol_message.h:1198
constexpr StmtReset(uint32_t statement_id)
construct a ResetStmt message.
Definition: classic_protocol_message.h:1196
Opaque auth-method-data message.
Definition: classic_protocol_message.h:239
string_type auth_method_data_
Definition: classic_protocol_message.h:250
constexpr AuthMethodData(string_type auth_method_data)
Definition: classic_protocol_message.h:244
constexpr string_type auth_method_data() const
Definition: classic_protocol_message.h:247
std::conditional_t< Borrowed, std::string_view, std::string > string_type
Definition: classic_protocol_message.h:242
Definition: classic_protocol_message.h:196
std::conditional_t< Borrowed, std::string_view, std::string > string_type
Definition: classic_protocol_message.h:199
constexpr AuthMethodSwitch(string_type auth_method, string_type auth_method_data)
Definition: classic_protocol_message.h:203
string_type auth_method_data_
Definition: classic_protocol_message.h:213
string_type auth_method_data() const
Definition: classic_protocol_message.h:209
string_type auth_method() const
Definition: classic_protocol_message.h:208
string_type auth_method_
Definition: classic_protocol_message.h:212
ColumnCount message.
Definition: classic_protocol_message.h:411
constexpr uint64_t count() const noexcept
Definition: classic_protocol_message.h:420
uint64_t count_
Definition: classic_protocol_message.h:423
constexpr ColumnCount(uint64_t count)
construct an ColumnCount message.
Definition: classic_protocol_message.h:418
Definition: classic_protocol_message.h:431
constexpr classic_protocol::column_def::value_type flags() const
Definition: classic_protocol_message.h:463
classic_protocol::column_def::value_type flags_
Definition: classic_protocol_message.h:478
constexpr uint32_t column_length() const
Definition: classic_protocol_message.h:461
string_type schema_
Definition: classic_protocol_message.h:470
constexpr ColumnMeta(string_type catalog, string_type schema, string_type table, string_type orig_table, string_type name, string_type orig_name, uint16_t collation, uint32_t column_length, uint8_t type, classic_protocol::column_def::value_type flags, uint8_t decimals)
Definition: classic_protocol_message.h:436
constexpr string_type orig_table() const
Definition: classic_protocol_message.h:457
uint16_t collation_
Definition: classic_protocol_message.h:475
std::conditional_t< Borrowed, std::string_view, std::string > string_type
Definition: classic_protocol_message.h:434
uint8_t type_
Definition: classic_protocol_message.h:477
constexpr string_type name() const
Definition: classic_protocol_message.h:458
string_type catalog_
Definition: classic_protocol_message.h:469
string_type orig_name_
Definition: classic_protocol_message.h:474
constexpr string_type orig_name() const
Definition: classic_protocol_message.h:459
uint32_t column_length_
Definition: classic_protocol_message.h:476
constexpr string_type catalog() const
Definition: classic_protocol_message.h:454
string_type table_
Definition: classic_protocol_message.h:471
uint8_t decimals_
Definition: classic_protocol_message.h:479
constexpr uint8_t decimals() const
Definition: classic_protocol_message.h:466
constexpr string_type schema() const
Definition: classic_protocol_message.h:455
string_type name_
Definition: classic_protocol_message.h:473
constexpr uint16_t collation() const
Definition: classic_protocol_message.h:460
constexpr string_type table() const
Definition: classic_protocol_message.h:456
string_type orig_table_
Definition: classic_protocol_message.h:472
constexpr uint8_t type() const
Definition: classic_protocol_message.h:462
End of Resultset message.
Definition: classic_protocol_message.h:342
constexpr Eof(classic_protocol::status::value_type status_flags, uint16_t warning_count, string_type message, string_type session_changes)
Definition: classic_protocol_message.h:359
constexpr Eof(classic_protocol::status::value_type status_flags, uint16_t warning_count)
Definition: classic_protocol_message.h:355
Error message.
Definition: classic_protocol_message.h:370
constexpr string_type message() const
Definition: classic_protocol_message.h:393
constexpr string_type sql_state() const
Definition: classic_protocol_message.h:391
string_type message_
Definition: classic_protocol_message.h:398
constexpr uint16_t error_code() const noexcept
Definition: classic_protocol_message.h:389
constexpr void message(const string_type &msg)
Definition: classic_protocol_message.h:394
string_type sql_state_
Definition: classic_protocol_message.h:399
constexpr Error(uint16_t error_code, string_type message, string_type sql_state="HY000")
construct an Error message.
Definition: classic_protocol_message.h:383
uint16_t error_code_
Definition: classic_protocol_message.h:397
std::conditional_t< Borrowed, std::string_view, std::string > string_type
Definition: classic_protocol_message.h:373
constexpr void error_code(uint16_t code)
Definition: classic_protocol_message.h:390
constexpr void sql_state(const string_type &state)
Definition: classic_protocol_message.h:392
Definition: classic_protocol_message.h:117
constexpr uint8_t collation() const noexcept
Definition: classic_protocol_message.h:158
constexpr uint32_t connection_id() const noexcept
Definition: classic_protocol_message.h:168
constexpr classic_protocol::status::value_type status_flags() const noexcept
Definition: classic_protocol_message.h:161
uint32_t connection_id_
Definition: classic_protocol_message.h:174
void status_flags(classic_protocol::status::value_type val)
Definition: classic_protocol_message.h:164
string_type auth_method_data_
Definition: classic_protocol_message.h:175
void collation(uint8_t val)
Definition: classic_protocol_message.h:159
void connection_id(uint32_t val)
Definition: classic_protocol_message.h:169
constexpr Greeting(uint8_t protocol_version, string_type version, uint32_t connection_id, string_type auth_method_data, classic_protocol::capabilities::value_type capabilities, uint8_t collation, classic_protocol::status::value_type status_flags, string_type auth_method_name)
Definition: classic_protocol_message.h:122
string_type version_
Definition: classic_protocol_message.h:173
void auth_method_data(string_type val)
Definition: classic_protocol_message.h:148
constexpr string_type auth_method_name() const
Definition: classic_protocol_message.h:145
classic_protocol::capabilities::value_type capabilities() const noexcept
Definition: classic_protocol_message.h:150
std::conditional_t< Borrowed, std::string_view, std::string > string_type
Definition: classic_protocol_message.h:120
uint8_t protocol_version_
Definition: classic_protocol_message.h:172
string_type auth_method_name_
Definition: classic_protocol_message.h:179
uint8_t collation_
Definition: classic_protocol_message.h:177
void version(string_type val)
Definition: classic_protocol_message.h:143
void auth_method_name(string_type val)
Definition: classic_protocol_message.h:146
void protocol_version(uint8_t val)
Definition: classic_protocol_message.h:140
classic_protocol::capabilities::value_type capabilities_
Definition: classic_protocol_message.h:176
constexpr string_type version() const
Definition: classic_protocol_message.h:142
constexpr string_type auth_method_data() const
Definition: classic_protocol_message.h:147
classic_protocol::status::value_type status_flags_
Definition: classic_protocol_message.h:178
void capabilities(classic_protocol::capabilities::value_type caps)
Definition: classic_protocol_message.h:154
constexpr uint8_t protocol_version() const noexcept
Definition: classic_protocol_message.h:137
Ok message.
Definition: classic_protocol_message.h:270
constexpr string_type message() const
Definition: classic_protocol_message.h:306
constexpr uint64_t last_insert_id() const noexcept
Definition: classic_protocol_message.h:300
uint16_t warning_count_
Definition: classic_protocol_message.h:320
constexpr void affected_rows(uint64_t val)
Definition: classic_protocol_message.h:302
constexpr void status_flags(classic_protocol::status::value_type flags)
Definition: classic_protocol_message.h:288
constexpr void last_insert_id(uint64_t val)
Definition: classic_protocol_message.h:299
constexpr void message(const string_type &msg)
Definition: classic_protocol_message.h:305
constexpr void session_changes(const string_type &changes)
Definition: classic_protocol_message.h:308
uint64_t last_insert_id_
Definition: classic_protocol_message.h:321
constexpr classic_protocol::status::value_type status_flags() const noexcept
Definition: classic_protocol_message.h:292
std::conditional_t< Borrowed, std::string_view, std::string > string_type
Definition: classic_protocol_message.h:273
string_type message_
Definition: classic_protocol_message.h:324
classic_protocol::status::value_type status_flags_
Definition: classic_protocol_message.h:319
constexpr uint64_t affected_rows() const noexcept
Definition: classic_protocol_message.h:303
constexpr uint16_t warning_count() const noexcept
Definition: classic_protocol_message.h:297
uint64_t affected_rows_
Definition: classic_protocol_message.h:322
string_type session_changes() const
get session-changes.
Definition: classic_protocol_message.h:316
constexpr void warning_count(uint16_t count)
Definition: classic_protocol_message.h:296
constexpr Ok(uint64_t affected_rows, uint64_t last_insert_id, classic_protocol::status::value_type status_flags, uint16_t warning_count, string_type message="", string_type session_changes="")
Definition: classic_protocol_message.h:277
string_type session_changes_
Definition: classic_protocol_message.h:325
Definition: classic_protocol_message.h:533
std::vector< Row< Borrowed > > rows() const
Definition: classic_protocol_message.h:542
std::vector< ColumnMeta< Borrowed > > column_metas() const
Definition: classic_protocol_message.h:539
std::vector< ColumnMeta< Borrowed > > column_metas_
Definition: classic_protocol_message.h:545
std::vector< Row< Borrowed > > rows_
Definition: classic_protocol_message.h:546
ResultSet(std::vector< ColumnMeta< Borrowed > > column_metas, std::vector< Row< Borrowed > > rows)
Definition: classic_protocol_message.h:535
Row in a resultset.
Definition: classic_protocol_message.h:501
typename std::vector< value_type >::const_iterator const_iterator
Definition: classic_protocol_message.h:507
Row(std::vector< value_type > fields)
Definition: classic_protocol_message.h:509
auto begin() const
Definition: classic_protocol_message.h:511
std::vector< value_type > fields_
Definition: classic_protocol_message.h:515
std::conditional_t< Borrowed, std::string_view, std::string > string_type
Definition: classic_protocol_message.h:504
std::optional< string_type > value_type
Definition: classic_protocol_message.h:506
auto end() const
Definition: classic_protocol_message.h:512
Definition: classic_protocol_message.h:629
std::conditional_t< Borrowed, std::string_view, std::string > string_type
Definition: classic_protocol_message.h:632
constexpr string_type filename() const
Definition: classic_protocol_message.h:641
constexpr SendFileRequest(string_type filename)
construct a SendFileRequest message.
Definition: classic_protocol_message.h:638
string_type filename_
Definition: classic_protocol_message.h:644
Definition: classic_protocol_message.h:654
string_type stats_
Definition: classic_protocol_message.h:669
constexpr Statistics(string_type stats)
construct a Statistics message.
Definition: classic_protocol_message.h:664
constexpr string_type stats() const
Definition: classic_protocol_message.h:666
std::conditional_t< Borrowed, std::string_view, std::string > string_type
Definition: classic_protocol_message.h:657
StmtPrepareOk message.
Definition: classic_protocol_message.h:554
constexpr uint16_t param_count() const noexcept
Definition: classic_protocol_message.h:582
constexpr void column_count(uint16_t cnt) noexcept
Definition: classic_protocol_message.h:581
uint8_t with_metadata_
Definition: classic_protocol_message.h:601
constexpr uint16_t column_count() const noexcept
Definition: classic_protocol_message.h:580
constexpr void warning_count(uint16_t cnt) noexcept
Definition: classic_protocol_message.h:578
constexpr void statement_id(uint32_t id) noexcept
Definition: classic_protocol_message.h:576
constexpr uint8_t with_metadata() const noexcept
Definition: classic_protocol_message.h:584
uint32_t statement_id_
Definition: classic_protocol_message.h:597
uint16_t warning_count_
Definition: classic_protocol_message.h:598
constexpr StmtPrepareOk(uint32_t stmt_id, uint16_t column_count, uint16_t param_count, uint16_t warning_count, uint8_t with_metadata)
create a Ok message for a client::StmtPrepare.
Definition: classic_protocol_message.h:566
constexpr friend bool operator==(const StmtPrepareOk &lhs, const StmtPrepareOk &rhs)
Definition: classic_protocol_message.h:587
uint16_t column_count_
Definition: classic_protocol_message.h:600
constexpr uint16_t warning_count() const noexcept
Definition: classic_protocol_message.h:577
constexpr void with_metadata(uint8_t with) noexcept
Definition: classic_protocol_message.h:585
constexpr uint32_t statement_id() const noexcept
Definition: classic_protocol_message.h:575
constexpr void param_count(uint16_t cnt) noexcept
Definition: classic_protocol_message.h:583
uint16_t param_count_
Definition: classic_protocol_message.h:599
StmtRow message.
Definition: classic_protocol_message.h:612
std::vector< field_type::value_type > types_
Definition: classic_protocol_message.h:625
std::vector< field_type::value_type > types() const
Definition: classic_protocol_message.h:622
StmtRow(std::vector< field_type::value_type > types, std::vector< value_type > fields)
Definition: classic_protocol_message.h:618
Definition: classic_protocol_message.h:55
Flags
Definition: classic_protocol_message.h:58
Definition: classic_protocol_message.h:38
Flags
Definition: classic_protocol_message.h:41
a type-safe flags type.
Definition: flags.h:114
static int flags[50]
Definition: hp_test1.cc:39
static int count
Definition: myisam_ftdump.cc:44
uint16_t value_type
Definition: vt100.h:183
constexpr bool operator==(const Greeting< Borrowed > &a, const Greeting< Borrowed > &b)
Definition: classic_protocol_message.h:773
bool operator==(const Greeting< Borrowed > &a, const Greeting< Borrowed > &b)
Definition: classic_protocol_message.h:183
borrowable::message::client::Reload Reload
Definition: classic_protocol_message.h:1483
borrowable::message::client::Kill Kill
Definition: classic_protocol_message.h:1481
borrowable::message::server::ColumnMeta< true > ColumnMeta
Definition: classic_protocol_message.h:1462
borrowable::message::server::StmtPrepareOk StmtPrepareOk
Definition: classic_protocol_message.h:1468
borrowable::message::server::SendFileRequest< true > SendFileRequest
Definition: classic_protocol_message.h:1465
borrowable::message::server::StmtRow< true > StmtRow
Definition: classic_protocol_message.h:1467
borrowable::message::server::Eof< true > Eof
Definition: classic_protocol_message.h:1459
borrowable::message::server::Statistics< true > Statistics
Definition: classic_protocol_message.h:1469
borrowable::message::server::Row< true > Row
Definition: classic_protocol_message.h:1466
borrowable::message::server::AuthMethodData< true > AuthMethodData
Definition: classic_protocol_message.h:1464
borrowable::message::server::Ok< true > Ok
Definition: classic_protocol_message.h:1457
borrowable::message::server::ColumnCount ColumnCount
Definition: classic_protocol_message.h:1461
borrowable::message::server::Greeting< true > Greeting
Definition: classic_protocol_message.h:1460
borrowable::message::server::AuthMethodSwitch< true > AuthMethodSwitch
Definition: classic_protocol_message.h:1463
constexpr value_type plugin_auth
Definition: classic_protocol_constants.h:56
constexpr value_type secure_connection
Definition: classic_protocol_constants.h:52
std::bitset< 32 > value_type
Definition: classic_protocol_constants.h:72
std::bitset< pos::_bitset_size > value_type
Definition: classic_protocol_constants.h:285
std::bitset< pos::_bitset_size > value_type
Definition: classic_protocol_constants.h:219
Definition: classic_protocol_message.h:37
borrowable::message::server::AuthMethodSwitch< false > AuthMethodSwitch
Definition: classic_protocol_message.h:1415
borrowable::message::server::StmtPrepareOk StmtPrepareOk
Definition: classic_protocol_message.h:1420
borrowable::message::server::Greeting< false > Greeting
Definition: classic_protocol_message.h:1412
borrowable::message::server::Row< false > Row
Definition: classic_protocol_message.h:1418
borrowable::message::server::Eof< false > Eof
Definition: classic_protocol_message.h:1411
borrowable::message::server::ColumnCount ColumnCount
Definition: classic_protocol_message.h:1413
borrowable::message::server::Ok< false > Ok
Definition: classic_protocol_message.h:1409
borrowable::message::server::AuthMethodData< false > AuthMethodData
Definition: classic_protocol_message.h:1416
borrowable::message::server::Statistics< false > Statistics
Definition: classic_protocol_message.h:1421
borrowable::message::server::StmtRow< false > StmtRow
Definition: classic_protocol_message.h:1419
borrowable::message::server::SendFileRequest< false > SendFileRequest
Definition: classic_protocol_message.h:1417
borrowable::message::server::ColumnMeta< false > ColumnMeta
Definition: classic_protocol_message.h:1414
std::bitset< pos::_bitset_size > value_type
Definition: classic_protocol_constants.h:318
std::bitset< 16 > value_type
Definition: classic_protocol_constants.h:167
Definition: classic_protocol_binary.h:38
Definition: varlen_sort.h:174
Definition: bit.h:33
std::vector< T, ut::allocator< T > > vector
Specialization of vector which uses allocator.
Definition: ut0new.h:2873
case opt name
Definition: sslopt-case.h:32
Definition: classic_protocol_message.h:790
std::optional< string_type > value
Definition: classic_protocol_message.h:793
string_type name
Definition: classic_protocol_message.h:792
uint16_t type_and_flags
Definition: classic_protocol_message.h:791
Param(uint16_t t, string_type n, std::optional< string_type > v)
Definition: classic_protocol_message.h:795
ParamDef(uint16_t type_and_flags_, string_type name_, bool param_already_sent_=false)
Definition: classic_protocol_message.h:1101
uint16_t type_and_flags
Definition: classic_protocol_message.h:1111
string_type name
Definition: classic_protocol_message.h:1113
friend bool operator==(const ParamDef &lhs, const ParamDef &rhs)
Definition: classic_protocol_message.h:1107
ParamDef(uint16_t type_and_flags_)
Definition: classic_protocol_message.h:1099
bool param_already_sent
Definition: classic_protocol_message.h:1116
Definition: server_struct.h:38
Definition: mysqlslap.cc:218
Definition: mysqlslap.cc:239
Definition: flags.h:37
@ a_end
Definition: task_arg.h:37
unsigned long id[MAX_DEAD]
Definition: xcom_base.cc:509
int n
Definition: xcom_base.cc:508