MySQL 9.3.0
Source Code Documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
mysql_session.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2016, 2025, 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 _ROUTER_MYSQL_SESSION_H_
27#define _ROUTER_MYSQL_SESSION_H_
28
31
32#include <functional>
33#include <map>
34#include <memory>
35#include <stdexcept>
36#include <string>
37#include <vector>
38
39#include <mysql.h> // enum mysql_ssl_mode
40#include <string.h>
41
44#include "secure_string.h" // NOLINT(build/include_subdir)
45
46namespace mysqlrouter {
47
49 public:
50 MysqlError() = default;
51 MysqlError(unsigned int code, std::string message, std::string sql_state)
52 : code_{code},
53 message_{std::move(message)},
54 sql_state_{std::move(sql_state)} {}
55
56 operator bool() { return code_ != 0; }
57
58 std::string message() const { return message_; }
59 std::string sql_state() const { return sql_state_; }
60 unsigned int value() const { return code_; }
61
62 private:
63 unsigned int code_{0};
64 std::string message_;
65 std::string sql_state_;
66};
67
68namespace impl {
69/**
70 * gettable, settable option for mysql_option's.
71 *
72 * adapts scalar types like int/bool/... mysql_option's to
73 * mysql_options()/mysql_get_option().
74 *
75 * - mysql_options() expects a '&int'
76 * - mysql_get_option() expects a '&int'
77 */
78template <mysql_option Opt, class ValueType>
79class Option {
80 public:
81 using value_type = ValueType;
82
83 constexpr Option() = default;
84 constexpr explicit Option(value_type v) : v_{std::move(v)} {}
85
86 // get the option id
87 constexpr mysql_option option() const noexcept { return Opt; }
88
89 // get address of the storage.
90 constexpr const void *data() const { return std::addressof(v_); }
91
92 // get address of the storage.
93 constexpr void *data() { return std::addressof(v_); }
94
95 // set the value of the option
96 constexpr void value(value_type v) { v_ = v; }
97
98 // get the value of the option
99 constexpr value_type value() const { return v_; }
100
101 private:
103};
104
105/**
106 * gettable, settable option for 'const char *' based mysql_option's.
107 *
108 * adapts 'const char *' based mysql_option to
109 * mysql_options()/mysql_get_option().
110 *
111 * - mysql_options() expects a 'const char *'
112 * - mysql_get_option() expects a '&(const char *)'
113 */
114template <mysql_option Opt>
115class Option<Opt, const char *> {
116 public:
117 using value_type = const char *;
118
119 Option() = default;
120 constexpr explicit Option(value_type v) : v_{std::move(v)} {}
121
122 constexpr mysql_option option() const noexcept { return Opt; }
123
124 constexpr const void *data() const { return v_; }
125
126 constexpr void *data() { return std::addressof(v_); }
127
128 constexpr void value(value_type v) { v_ = v; }
129
130 constexpr value_type value() const { return v_; }
131
132 private:
134};
135
136template <mysql_option Opt>
137class Option<Opt, std::nullptr_t> {
138 public:
139 using value_type = std::nullptr_t;
140
141 Option() = default;
142 // accept a void *, but ignore it.
143 constexpr explicit Option(value_type) {}
144
145 constexpr mysql_option option() const noexcept { return Opt; }
146
147 constexpr const void *data() const { return nullptr; }
148
149 constexpr void *data() { return nullptr; }
150
151 constexpr value_type value() const { return nullptr; }
152};
153} // namespace impl
154
155// mysql_options() may be used with MYSQL * == nullptr to get global values.
156
158 public:
159 static constexpr int kDefaultConnectTimeout = 5;
160 static constexpr int kDefaultReadTimeout = 30;
161 class ResultRow;
162 typedef std::vector<const char *> Row;
163 typedef std::function<bool(const Row &)> RowProcessor;
164 typedef std::function<bool(const ResultRow &)> ResultRowProcessor;
165
166 typedef std::function<void(unsigned, MYSQL_FIELD *)> FieldValidator;
167 typedef std::function<void()> OnResultSetEnd;
168
169 // text representations of SSL modes
170 static const char kSslModeDisabled[];
171 static const char kSslModePreferred[];
172 static const char kSslModeRequired[];
173 static const char kSslModeVerifyCa[];
174 static const char kSslModeVerifyIdentity[];
175 //
176 // mysql_option's
177 //
178 // (sorted by appearance in documentation)
179
180 // type for mysql_option's which set/get a 'bool'
181 template <mysql_option Opt>
183
184 // type for mysql_option's which set/get a 'unsigned int'
185 template <mysql_option Opt>
187
188 // type for mysql_option's which set/get a 'unsigned long'
189 template <mysql_option Opt>
191
192 // type for mysql_option's which set/get a 'const char *'
193 template <mysql_option Opt>
195
216 // TCP/UnixSocket/...
233
242
244 public:
246 Transaction(Transaction &&other) : session_{other.session_} {
247 other.session_ = nullptr;
248 }
249
250 Transaction(MySQLSession *session, const bool consisten_snapshot = false)
251 : session_(session) {
252 session_->execute(consisten_snapshot
253 ? "START TRANSACTION WITH CONSISTENT SNAPSHOT"
254 : "START TRANSACTION");
255 }
256
258 try {
259 rollback();
260 } catch (...) {
261 // ignore errors during rollback on d-tor
262 }
263 }
264
265 void commit() {
266 if (session_) {
267 session_->execute("COMMIT");
268 session_ = nullptr;
269 }
270 }
271
272 void rollback() {
273 if (session_) {
274 session_->execute("ROLLBACK");
275 session_ = nullptr;
276 }
277 }
278
280 std::swap(session_, other.session_);
281 return *this;
282 }
283
284 private:
285 MySQLSession *session_{nullptr};
286 };
287
288 class Error : public std::runtime_error {
289 public:
290 // NOTE Not all calls to constructors provide the 3rd argument. To save
291 // time, only the code where it was needed atm was upgraded from 2 to
292 // 3 args; upgrade elsewhere if needed
293
294 Error(const char *error, unsigned int code,
295 const std::string message = "<not set>")
296 : std::runtime_error(error), code_(code), message_(message) {}
297
298 Error(const std::string &error, unsigned int code,
299 const std::string &message = "<not set>")
300 : std::runtime_error(error), code_(code), message_(message) {}
301
302 unsigned int code() const { return code_; }
303 std::string message() const { return message_; }
304
305 private:
306 const unsigned int code_;
307 const std::string message_;
308 };
309
310 class ResultRow {
311 public:
312 class RowIt {
313 public:
314 RowIt(const ResultRow *parent, uint32_t idx = 0)
315 : idx_{idx}, parent_{parent} {}
316 const char *operator*() const { return (*parent_)[idx_]; }
317 void operator++() { ++idx_; }
318
319 bool operator!=(const RowIt &other) const {
320 if (parent_ != other.parent_) return false;
321 return idx_ != other.idx_;
322 }
323
324 private:
325 uint32_t idx_{0};
327 };
328 ResultRow(Row row) : row_{std::move(row)} {}
329 virtual ~ResultRow() = default;
330 size_t size() const { return row_.size(); }
331 RowIt begin() const { return RowIt(this, 0); }
332 RowIt end() const { return RowIt(this, size()); }
333 const char *&operator[](size_t i) { return row_[i]; }
334 const char *operator[](size_t i) const { return row_[i]; }
335 virtual size_t get_data_size(size_t i) const { return strlen(row_[i]); }
336
337 private:
338 friend class MySQLSession;
340 };
341
342 MySQLSession();
343 virtual ~MySQLSession();
344
346 std::string ssl_mode); // throws std::logic_error
347 static const char *ssl_mode_to_string(mysql_ssl_mode ssl_mode) noexcept;
348
349 // throws Error, std::invalid_argument
351 const std::string &tls_version,
352 const std::string &ssl_cipher,
353 const std::string &ca, const std::string &capath,
354 const std::string &crl,
355 const std::string &crlpath);
356
357 uint64_t connection_id();
358
359 mysql_ssl_mode ssl_mode() const;
360 std::string tls_version() const;
361 std::string ssl_cipher() const;
362 std::string ssl_ca() const;
363 std::string ssl_capath() const;
364 std::string ssl_crl() const;
365 std::string ssl_crlpath() const;
366
367 std::string ssl_cert() const;
368 std::string ssl_key() const;
369
370 int connect_timeout() const;
371 int read_timeout() const;
372
373 // throws Error
374 virtual void set_ssl_cert(const std::string &cert, const std::string &key);
375
376 /**
377 * set a mysql option.
378 *
379 * @code
380 * auto res = set_option(ConnectTimeout(10));
381 * @endcode
382 *
383 * @note on error the MysqlError may not always contain the right error-code.
384 *
385 * @param [in] opt option to set.
386 * @returns a MysqlError on error
387 * @retval true on success
388 */
389 template <class SettableMysqlOption>
390 stdx::expected<void, MysqlError> set_option(const SettableMysqlOption &opt) {
391 if (0 != mysql_options(connection_, opt.option(), opt.data())) {
395 }
396
397 return {};
398 }
399
400 /**
401 * get a mysql option.
402 *
403 * @code
404 * ConnectTimeout opt_connect_timeout;
405 * auto res = get_option(opt_connect_timeout);
406 * if (res) {
407 * std::cerr << opt_connect_timeout.value() << std::endl;
408 * }
409 * @endcode
410 *
411 * @param [in,out] opt option to query.
412 * @retval true on success.
413 * @retval false if option is not known.
414 */
415 template <class GettableMysqlOption>
416 bool get_option(GettableMysqlOption &opt) const {
417 if (0 != mysql_get_option(connection_, opt.option(), opt.data())) {
418 return false;
419 }
420
421 return true;
422 }
423
424 // these methods are deprecated, versions with a SecureString password should
425 // be used instead
426 void connect(const std::string &host, unsigned int port,
427 const std::string &username, const std::string &password,
428 const std::string &unix_socket,
429 const std::string &default_schema,
432 unsigned long extra_client_flags = 0);
433 void connect(const MySQLSession &other, const std::string &username,
434 const std::string &password);
435 void change_user(const std::string &user, const std::string &password,
436 const std::string &db);
437
438 virtual void connect(const std::string &host, unsigned int port,
439 const std::string &username,
441 const std::string &unix_socket,
442 const std::string &default_schema,
445 unsigned long extra_client_flags = 0); // throws Error
446 /**
447 * Connect using the same settings and parameters that were used for the last
448 * other.connect() using provided credentials.
449 */
450 virtual void connect(const MySQLSession &other, const std::string &username,
452 virtual void change_user(const std::string &user,
454 const std::string &db);
455
456 virtual void disconnect();
457
458 virtual void reset();
459
460 virtual uint64_t prepare(const std::string &query);
462 uint64_t ps_id, std::vector<MYSQL_BIND> bind_parameters,
463 const ResultRowProcessor &processor,
464 const FieldValidator &validator /*= null_field_validator*/,
465 const OnResultSetEnd &on_resultset_end);
466 virtual void prepare_remove(uint64_t ps_id);
467 virtual void execute(
468 const std::string &query); // throws Error, std::logic_error
469 virtual void query(
470 const std::string &query, const ResultRowProcessor &processor,
471 const FieldValidator &validator); // throws Error, std::logic_error
472 virtual std::unique_ptr<MySQLSession::ResultRow> query_one(
473 const std::string &query,
474 const FieldValidator &validator); // throws Error
475 //
476 void query(
477 const std::string &query, const RowProcessor &processor,
478 const FieldValidator &validator); // throws Error, std::logic_error
479 void query(const std::string &stmt, const RowProcessor &processor) {
480 return query(stmt, processor, [](unsigned, MYSQL_FIELD *) {});
481 }
482
483 virtual std::unique_ptr<MySQLSession::ResultRow> query_one(
484 const std::string &stmt) {
485 return query_one(stmt, [](unsigned, MYSQL_FIELD *) {});
486 }
487
488 virtual int ping();
489 virtual bool execute_nb(
490 const std::string &query); // throws Error, std::logic_error
491
492 virtual uint64_t last_insert_id() noexcept;
493 virtual uint64_t affected_rows() noexcept;
494
495 virtual unsigned warning_count() noexcept;
496
497 virtual std::string quote(const std::string &s, char qchar = '\'') const;
498
499 virtual bool is_connected() noexcept { return connection_ && connected_; }
500 const std::string &get_address() noexcept { return connection_address_; }
501
502 virtual const char *last_sqlstate();
503 virtual const char *last_error();
504 virtual unsigned int last_errno();
505
506 virtual const char *ssl_cipher();
507 virtual bool has_data_on_socket();
508 virtual std::vector<std::string> get_session_tracker_data(
510
511 virtual bool is_ssl_session_reused();
512
513 virtual unsigned long server_version();
514
516
517 private:
518 // stores selected parameters that were passed to the last successful call to
519 // connect()
520 struct {
521 std::string host;
522 unsigned int port{};
523 std::string unix_socket;
524 std::string default_schema;
525 } connect_params_;
526
527 uint64_t last_stmt_id{0};
528 std::map<uint64_t, MYSQL_STMT *> stmts_;
533 unsigned long extra_client_flags_{0};
534 uint64_t connection_id_{0};
535
537 public:
539 };
540
541 using mysql_result_type = std::unique_ptr<MYSQL_RES, MYSQL_RES_Deleter>;
542
543 enum class AsyncQueryState {
544 kNone, // no async query active
545 kQuery, // waiting query to finish
546 kStoreResult // waiting store result to finish
547 };
549 bool async_query_logged_ = false;
550
551 /**
552 * run query.
553 *
554 * There are 3 cases:
555 *
556 * 1. query returns a resultset
557 * 3. query returns no resultset
558 * 2. query fails with an error
559 *
560 * @param q stmt to execute
561 *
562 * @returns resultset on success, MysqlError on error
563 */
565 const std::string &q);
566
568 const std::string &q);
569
570 /**
571 * log query after running it.
572 */
574 const std::string &q);
575
577 const std::string &q);
578
579 void throw_mysqlerror(MYSQL_STMT *stmt, uint64_t ps_id);
580 // if query be timed and sent to the sql-log.
582};
583
584} // namespace mysqlrouter
585
586#endif
mysqlrouter::MySQLSession MySQLSession
Definition: bootstrap_mysql_account.cc:41
Null-terminated string which is securely wiped on destruction.
Definition: secure_string.h:59
Definition: mysql_session.h:288
Error(const char *error, unsigned int code, const std::string message="<not set>")
Definition: mysql_session.h:294
std::string message() const
Definition: mysql_session.h:303
unsigned int code() const
Definition: mysql_session.h:302
const std::string message_
Definition: mysql_session.h:307
Error(const std::string &error, unsigned int code, const std::string &message="<not set>")
Definition: mysql_session.h:298
const unsigned int code_
Definition: mysql_session.h:306
Definition: mysql_session.h:536
void operator()(MYSQL_RES *res)
Definition: mysql_session.h:538
Definition: mysql_session.h:312
bool operator!=(const RowIt &other) const
Definition: mysql_session.h:319
uint32_t idx_
Definition: mysql_session.h:325
RowIt(const ResultRow *parent, uint32_t idx=0)
Definition: mysql_session.h:314
void operator++()
Definition: mysql_session.h:317
const ResultRow * parent_
Definition: mysql_session.h:326
const char * operator*() const
Definition: mysql_session.h:316
Definition: mysql_session.h:310
ResultRow(Row row)
Definition: mysql_session.h:328
size_t size() const
Definition: mysql_session.h:330
RowIt begin() const
Definition: mysql_session.h:331
RowIt end() const
Definition: mysql_session.h:332
virtual size_t get_data_size(size_t i) const
Definition: mysql_session.h:335
Row row_
Definition: mysql_session.h:339
const char * operator[](size_t i) const
Definition: mysql_session.h:334
const char *& operator[](size_t i)
Definition: mysql_session.h:333
Definition: mysql_session.h:243
Transaction(MySQLSession *session, const bool consisten_snapshot=false)
Definition: mysql_session.h:250
Transaction & operator=(Transaction &&other)
Definition: mysql_session.h:279
Transaction(Transaction &&other)
Definition: mysql_session.h:246
Transaction()
Definition: mysql_session.h:245
void commit()
Definition: mysql_session.h:265
void rollback()
Definition: mysql_session.h:272
~Transaction()
Definition: mysql_session.h:257
Definition: mysql_session.h:157
std::function< void(unsigned, MYSQL_FIELD *)> FieldValidator
Definition: mysql_session.h:166
virtual std::unique_ptr< MySQLSession::ResultRow > query_one(const std::string &stmt)
Definition: mysql_session.h:483
std::string connection_address_
Definition: mysql_session.h:531
std::string ssl_crlpath() const
Definition: mysql_session.cc:302
virtual bool has_data_on_socket()
Definition: mysql_session.cc:940
virtual void set_ssl_cert(const std::string &cert, const std::string &key)
Definition: mysql_session.cc:311
bool get_option(GettableMysqlOption &opt) const
get a mysql option.
Definition: mysql_session.h:416
MYSQL * connection_
Definition: mysql_session.h:529
std::function< bool(const ResultRow &)> ResultRowProcessor
Definition: mysql_session.h:164
std::string ssl_key() const
Definition: mysql_session.cc:329
virtual unsigned warning_count() noexcept
Definition: mysql_session.cc:960
virtual uint64_t affected_rows() noexcept
Definition: mysql_session.cc:936
std::unique_ptr< MYSQL_RES, MYSQL_RES_Deleter > mysql_result_type
Definition: mysql_session.h:541
virtual ~MySQLSession()
Definition: mysql_session.cc:139
std::function< bool(const Row &)> RowProcessor
Definition: mysql_session.h:163
stdx::expected< void, MysqlError > set_option(const SettableMysqlOption &opt)
set a mysql option.
Definition: mysql_session.h:390
virtual void prepare_execute_with_bind_parameters(uint64_t ps_id, std::vector< MYSQL_BIND > bind_parameters, const ResultRowProcessor &processor, const FieldValidator &validator, const OnResultSetEnd &on_resultset_end)
Definition: mysql_session.cc:705
std::string ssl_ca() const
Definition: mysql_session.cc:275
virtual uint64_t prepare(const std::string &query)
Definition: mysql_session.cc:668
virtual int ping()
Definition: mysql_session.cc:964
void query(const std::string &stmt, const RowProcessor &processor)
Definition: mysql_session.h:479
virtual bool is_ssl_session_reused()
Definition: mysql_session.cc:992
virtual std::unique_ptr< MySQLSession::ResultRow > query_one(const std::string &query, const FieldValidator &validator)
Definition: mysql_session.cc:875
std::string ssl_crl() const
Definition: mysql_session.cc:293
std::function< void()> OnResultSetEnd
Definition: mysql_session.h:167
std::string ssl_cert() const
Definition: mysql_session.cc:320
std::string default_schema
Definition: mysql_session.h:524
SQLLogFilter log_filter_
Definition: mysql_session.h:532
const std::string & get_address() noexcept
Definition: mysql_session.h:500
bool connected_
Definition: mysql_session.h:530
mysql_ssl_mode ssl_mode() const
Definition: mysql_session.cc:248
virtual uint64_t last_insert_id() noexcept
Definition: mysql_session.cc:932
virtual bool execute_nb(const std::string &query)
Definition: mysql_session.cc:915
virtual unsigned long server_version()
Definition: mysql_session.cc:996
std::string tls_version() const
Definition: mysql_session.cc:257
std::string host
Definition: mysql_session.h:521
virtual const char * last_sqlstate()
Definition: mysql_session.cc:977
virtual std::vector< std::string > get_session_tracker_data(enum enum_session_state_type type)
Definition: mysql_session.cc:944
MYSQL * get_handle()
Definition: mysql_session.h:515
std::string ssl_cipher() const
Definition: mysql_session.cc:266
static mysql_ssl_mode parse_ssl_mode(std::string ssl_mode)
Definition: mysql_session.cc:146
std::string unix_socket
Definition: mysql_session.h:523
virtual void prepare_remove(uint64_t ps_id)
Definition: mysql_session.cc:782
uint64_t connection_id()
Definition: mysql_session.cc:236
int read_timeout() const
Definition: mysql_session.cc:347
AsyncQueryState
Definition: mysql_session.h:543
std::string ssl_capath() const
Definition: mysql_session.cc:284
std::vector< const char * > Row
Definition: mysql_session.h:161
std::map< uint64_t, MYSQL_STMT * > stmts_
Definition: mysql_session.h:528
virtual std::string quote(const std::string &s, char qchar='\'') const
Definition: mysql_session.cc:966
virtual unsigned int last_errno()
Definition: mysql_session.cc:984
void change_user(const std::string &user, const std::string &password, const std::string &db)
Definition: mysql_session.cc:467
Definition: mysql_session.h:48
MysqlError(unsigned int code, std::string message, std::string sql_state)
Definition: mysql_session.h:51
unsigned int value() const
Definition: mysql_session.h:60
std::string message() const
Definition: mysql_session.h:58
std::string sql_state() const
Definition: mysql_session.h:59
std::string sql_state_
Definition: mysql_session.h:65
unsigned int code_
Definition: mysql_session.h:63
std::string message_
Definition: mysql_session.h:64
A SQLLogFilter allows to replace substrings defined by a set of hardcoded regular expressions with '*...
Definition: log_filter.h:77
gettable, settable option for 'const char *' based mysql_option's.
Definition: mysql_session.h:115
constexpr const void * data() const
Definition: mysql_session.h:124
const char * value_type
Definition: mysql_session.h:117
constexpr void * data()
Definition: mysql_session.h:126
constexpr Option(value_type v)
Definition: mysql_session.h:120
constexpr value_type value() const
Definition: mysql_session.h:130
constexpr mysql_option option() const noexcept
Definition: mysql_session.h:122
constexpr void value(value_type v)
Definition: mysql_session.h:128
constexpr mysql_option option() const noexcept
Definition: mysql_session.h:145
constexpr value_type value() const
Definition: mysql_session.h:151
constexpr void * data()
Definition: mysql_session.h:149
std::nullptr_t value_type
Definition: mysql_session.h:139
constexpr Option(value_type)
Definition: mysql_session.h:143
constexpr const void * data() const
Definition: mysql_session.h:147
gettable, settable option for mysql_option's.
Definition: mysql_session.h:79
constexpr Option()=default
constexpr Option(value_type v)
Definition: mysql_session.h:84
constexpr const void * data() const
Definition: mysql_session.h:90
ValueType value_type
Definition: mysql_session.h:81
constexpr void * data()
Definition: mysql_session.h:93
value_type v_
Definition: mysql_session.h:102
constexpr mysql_option option() const noexcept
Definition: mysql_session.h:87
constexpr value_type value() const
Definition: mysql_session.h:99
constexpr void value(value_type v)
Definition: mysql_session.h:96
Definition: expected.h:286
static bool execute(MYSQL_STMT *stmt, char *packet, ulong length, bool send_param_count)
Auxiliary function to send COM_STMT_EXECUTE packet to server and read reply.
Definition: libmysql.cc:1831
static char * query
Definition: myisam_ftdump.cc:47
This file defines the client API to MySQL and also the ABI of the dynamically linked libmysqlclient.
const char *STDCALL mysql_sqlstate(MYSQL *mysql)
Definition: client.cc:9536
unsigned int STDCALL mysql_errno(MYSQL *mysql)
Definition: client.cc:9194
mysql_option
Definition: mysql.h:170
int STDCALL mysql_get_option(MYSQL *mysql, enum mysql_option option, const void *arg)
Return the current values for the options settable through mysql_options()
Definition: client.cc:8893
const char *STDCALL mysql_error(MYSQL *mysql)
Definition: client.cc:9198
void STDCALL mysql_free_result(MYSQL_RES *result)
Definition: client.cc:1955
int STDCALL mysql_options(MYSQL *mysql, enum mysql_option option, const void *arg)
Definition: client.cc:8554
mysql_ssl_mode
Definition: mysql.h:272
enum_session_state_type
Type of state change information that the server can include in the Ok packet.
Definition: mysql_com.h:1071
static char * password
Definition: mysql_secure_installation.cc:58
char * user
Definition: mysqladmin.cc:67
const char * host
Definition: mysqladmin.cc:66
void error(const char *format,...)
ulong connect_timeout
Definition: mysqld.cc:1354
std::string HARNESS_EXPORT reset()
get 'reset attributes' ESC sequence.
Definition: vt100.cc:37
void set_ssl_options(MySQLSession *sess, const std::map< std::string, std::string > &options)
Definition: router_conf.cc:182
void disconnect(Connection &c)
Definition: server.cc:48
Definition: http_server_component.cc:34
constexpr const unsigned int kDefaultConnectTimeout
Definition: metadata_cache.h:60
constexpr const unsigned int kDefaultReadTimeout
Definition: metadata_cache.h:62
constexpr char kNone[]
Definition: logging.h:70
Definition: base64.h:43
size_t size(const char *const c)
Definition: base64.h:46
int last_error()
get last socket error.
Definition: socket_error.h:82
stdx::expected< void, error_type > connect(native_handle_type native_handle, const struct sockaddr *addr, size_t addr_len)
wrap connect() in a portable way.
Definition: socket.h:353
Definition: gcs_xcom_synode.h:64
unexpected(E) -> unexpected< E >
static int is_connected(connection_descriptor *con)
Definition: node_connection.h:94
required string key
Definition: replication_asynchronous_connection_failover.proto:60
required uint64 port
Definition: replication_asynchronous_connection_failover.proto:33
required string type
Definition: replication_group_member_actions.proto:34
#define ROUTER_MYSQL_EXPORT
Definition: router_mysql_export.h:15
static bool rollback(THD *thd)
Abort the current statement and transaction.
Definition: sql_cmd_srs.cc:140
static void swap(String &a, String &b) noexcept
Definition: sql_string.h:663
constexpr const char * ssl_mode_to_string(SslMode mode)
Definition: ssl_mode.h:44
Definition: mysql.h:121
Definition: mysql.h:340
Definition: mysql.h:692
Definition: mysql.h:300
synode_no q[FIFO_SIZE]
Definition: xcom_base.cc:4101