MySQL 8.4.2
Source Code Documentation
mysql_command_consumer_imp.h
Go to the documentation of this file.
1/* Copyright (c) 2022, 2024, Oracle and/or its affiliates.
2
3This program is free software; you can redistribute it and/or modify
4it under the terms of the GNU General Public License, version 2.0,
5as published by the Free Software Foundation.
6
7This program is designed to work with certain software (including
8but not limited to OpenSSL) that is licensed under separate terms,
9as designated in a particular file or component or in included license
10documentation. The authors of MySQL hereby grant you an additional
11permission to link the program and your derivative works with the
12separately licensed software that they have either included with
13the program or referenced in the documentation.
14
15This program is distributed in the hope that it will be useful,
16but WITHOUT ANY WARRANTY; without even the implied warranty of
17MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18GNU General Public License, version 2.0, for more details.
19
20You should have received a copy of the GNU General Public License
21along with this program; if not, write to the Free Software
22Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef MYSQL_COMMAND_CONSUMER_IMP_H
25#define MYSQL_COMMAND_CONSUMER_IMP_H
26
29#include "include/sql_common.h"
30
31struct Dom_ctx {
32 MYSQL *m_mysql = nullptr;
33 MYSQL_DATA **m_result = nullptr;
34 MYSQL_DATA *m_data = nullptr;
36 unsigned int m_field_column_count = 0;
37 unsigned int m_cur_field_num = 0;
38 uint32_t m_sql_errno = 0;
41 std::string *m_message = nullptr;
42 std::string *m_err_msg = nullptr;
43 std::string *m_sqlstate = nullptr;
44};
45
46/*
47 The default consumer works like document object
48 model (DOM) parser i.e. first it fetches the
49 entire result set from server and stores that in local buffer.
50 Consumer then extracts the rows from the local buffer.
51 Therefore, this consumer is not suitable if result set is huge.
52 */
54 public:
55 static DEFINE_BOOL_METHOD(start, (SRV_CTX_H * srv_ctx_h, MYSQL_H *mysql_h));
56
58 (SRV_CTX_H srv_ctx_h, unsigned int num_cols,
59 unsigned int flags,
60 const char *const collation_name));
62 (SRV_CTX_H srv_ctx_h, struct Field_metadata *field,
63 const char *const collation_name));
65 (SRV_CTX_H srv_ctx_h, unsigned int server_status,
66 unsigned int warn_count));
67
68 static DEFINE_BOOL_METHOD(start_row, (SRV_CTX_H srv_ctx_h));
69 static DEFINE_BOOL_METHOD(abort_row, (SRV_CTX_H srv_ctx_h));
70 static DEFINE_BOOL_METHOD(end_row, (SRV_CTX_H srv_ctx_h));
71
72 static DEFINE_METHOD(void, handle_ok,
73 (SRV_CTX_H srv_ctx_h, unsigned int server_status,
74 unsigned int statement_warn_count,
75 unsigned long long affected_rows,
76 unsigned long long last_insert_id,
77 const char *const message));
78 static DEFINE_METHOD(void, handle_error,
79 (SRV_CTX_H srv_ctx_h, uint sql_errno,
80 const char *const err_msg, const char *const sqlstate));
81
82 /* get_null */
84 /* get_integer */
85 static DEFINE_BOOL_METHOD(get, (SRV_CTX_H, long long));
86 /* get_longlong */
87 static DEFINE_BOOL_METHOD(get, (SRV_CTX_H, long long, unsigned int));
88 /* get_decimal */
90 /* get_double */
91 static DEFINE_BOOL_METHOD(get, (SRV_CTX_H, double, unsigned int decimals));
92 static DEFINE_BOOL_METHOD(get_date, (SRV_CTX_H, const MYSQL_TIME_H value));
94 unsigned int precision));
96 unsigned int decimals));
98 (SRV_CTX_H, const char *const value, size_t length,
99 const char *const collation_name));
101 (SRV_CTX_H, unsigned long *capabilities));
102
103 static DEFINE_BOOL_METHOD(error, (SRV_CTX_H, uint32_t *err_num,
104 const char **error_msg));
105
106 static DEFINE_METHOD(void, end, (SRV_CTX_H srv_ctx_h));
107
108 private:
110 (SRV_CTX_H, const char *data, size_t length));
111};
112
113#endif // MYSQL_COMMAND_CONSUMER_IMP_H
Definition: mysql_command_consumer_imp.h:53
static mysql_service_status_t start_result_metadata(SRV_CTX_H srv_ctx_h, unsigned int num_cols, unsigned int flags, const char *const collation_name) noexcept
Definition: mysql_command_consumer_imp.cc:76
static mysql_service_status_t get_datetime(SRV_CTX_H, const MYSQL_TIME_H value, unsigned int decimals) noexcept
Definition: mysql_command_consumer_imp.cc:382
static void handle_error(SRV_CTX_H srv_ctx_h, uint sql_errno, const char *const err_msg, const char *const sqlstate) noexcept
Definition: mysql_command_consumer_imp.cc:239
static mysql_service_status_t get_string(SRV_CTX_H, const char *const value, size_t length, const char *const collation_name) noexcept
Definition: mysql_command_consumer_imp.cc:399
static void client_capabilities(SRV_CTX_H, unsigned long *capabilities) noexcept
Definition: mysql_command_consumer_imp.cc:413
static mysql_service_status_t start(SRV_CTX_H *srv_ctx_h, MYSQL_H *mysql_h) noexcept
Definition: mysql_command_consumer_imp.cc:41
static mysql_service_status_t error(SRV_CTX_H, uint32_t *err_num, const char **error_msg) noexcept
Definition: mysql_command_consumer_imp.cc:426
static void handle_ok(SRV_CTX_H srv_ctx_h, unsigned int server_status, unsigned int statement_warn_count, unsigned long long affected_rows, unsigned long long last_insert_id, const char *const message) noexcept
Definition: mysql_command_consumer_imp.cc:220
static mysql_service_status_t end_result_metadata(SRV_CTX_H srv_ctx_h, unsigned int server_status, unsigned int warn_count) noexcept
Definition: mysql_command_consumer_imp.cc:150
static mysql_service_status_t abort_row(SRV_CTX_H srv_ctx_h) noexcept
Definition: mysql_command_consumer_imp.cc:186
static mysql_service_status_t get(SRV_CTX_H) noexcept
Definition: mysql_command_consumer_imp.cc:254
static mysql_service_status_t field_metadata(SRV_CTX_H srv_ctx_h, struct Field_metadata *field, const char *const collation_name) noexcept
Definition: mysql_command_consumer_imp.cc:117
static mysql_service_status_t end_row(SRV_CTX_H srv_ctx_h) noexcept
Definition: mysql_command_consumer_imp.cc:204
static mysql_service_status_t start_row(SRV_CTX_H srv_ctx_h) noexcept
Definition: mysql_command_consumer_imp.cc:155
static mysql_service_status_t get_time(SRV_CTX_H, const MYSQL_TIME_H value, unsigned int precision) noexcept
Definition: mysql_command_consumer_imp.cc:365
static mysql_service_status_t store_data(SRV_CTX_H, const char *data, size_t length) noexcept
Definition: mysql_command_consumer_imp.cc:465
static void end(SRV_CTX_H srv_ctx_h) noexcept
Definition: mysql_command_consumer_imp.cc:441
static mysql_service_status_t get_date(SRV_CTX_H, const MYSQL_TIME_H value) noexcept
Definition: mysql_command_consumer_imp.cc:348
static int flags[50]
Definition: hp_test1.cc:40
struct DECIMAL_T_H_imp * DECIMAL_T_H
Definition: mysql_command_consumer.h:32
struct SRV_CTX_H_imp * SRV_CTX_H
Definition: mysql_command_consumer.h:31
struct MYSQL_TIME_H_imp * MYSQL_TIME_H
Definition: mysql_command_consumer.h:33
struct MYSQL_H_imp * MYSQL_H
Definition: mysql_command_services.h:33
char * collation_name
Definition: audit_api_message_emit.cc:185
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:76
Specifies macros to define Service Implementations.
#define DEFINE_BOOL_METHOD(name, args)
A short macro to define method that returns bool, which is the most common case.
Definition: service_implementation.h:88
#define DEFINE_METHOD(retval, name, args)
A macro to ensure method implementation has required properties, that is it does not throw exceptions...
Definition: service_implementation.h:79
Definition: mysql_command_consumer_imp.h:31
std::string * m_sqlstate
Definition: mysql_command_consumer_imp.h:43
MYSQL_DATA ** m_result
Definition: mysql_command_consumer_imp.h:33
std::string * m_err_msg
Definition: mysql_command_consumer_imp.h:42
unsigned int m_cur_field_num
Definition: mysql_command_consumer_imp.h:37
unsigned int m_field_column_count
Definition: mysql_command_consumer_imp.h:36
MYSQL_ROWS * m_cur_row
Definition: mysql_command_consumer_imp.h:39
MYSQL_FIELD * m_fields
Definition: mysql_command_consumer_imp.h:35
uint32_t m_sql_errno
Definition: mysql_command_consumer_imp.h:38
std::string * m_message
Definition: mysql_command_consumer_imp.h:41
MYSQL_DATA * m_data
Definition: mysql_command_consumer_imp.h:34
MYSQL_ROWS ** m_prev_ptr
Definition: mysql_command_consumer_imp.h:40
MYSQL * m_mysql
Definition: mysql_command_consumer_imp.h:32
The Field_metadata has the information about the field, which is used by field_metadata() service api...
Definition: mysql_command_consumer.h:39
Definition: mysql.h:163
Definition: mysql.h:121
Definition: mysql.h:153
Definition: mysql.h:300