24#ifndef PROTOCOL_LOCAL_V2_H
25#define PROTOCOL_LOCAL_V2_H
30#include "mysqld_error.h"
55using value_t = std::variant<std::monostate, int64_t *, uint64_t *,
double *,
98 const T &
operator[](
const unsigned int column_index)
const {
102 assert(column_index <
size());
107 Row(T *column_array_arg,
size_t column_count_arg)
182 size_t column_count,
ulonglong affected_rows,
260 const std::nothrow_t & = std::nothrow)
noexcept {
264 static void operator delete(
void *)
noexcept {}
267 const std::nothrow_t &)
noexcept {
300 size_t column_count,
ulonglong affected_rows,
355 template <
typename T,
typename V>
379 bool send_ok(uint server_status, uint statement_warn_count,
381 const char *message)
override;
383 bool send_eof(uint server_status, uint statement_warn_count)
override;
384 bool send_error(uint sql_errno,
const char *err_msg,
385 const char *sqlstate)
override;
405 int shutdown(
bool server_shutdown =
false)
override;
421 bool flush()
override {
return true; }
Definition: sql_list.h:627
Definition: sql_list.h:467
This is extention of Protocol_local.
Definition: protocol_local_v2.h:315
bool allocate_type(V *value)
Definition: protocol_local_v2.cc:86
bool send_ok(uint server_status, uint statement_warn_count, ulonglong affected_rows, ulonglong last_insert_id, const char *message) override
Called for statements that don't have a result set, at statement end.
Definition: protocol_local_v2.cc:213
bool send_error(uint sql_errno, const char *err_msg, const char *sqlstate) override
Called at the end of a result set.
Definition: protocol_local_v2.cc:242
bool end_row() override
Add the current row to the result set.
Definition: protocol_local_v2.cc:309
void abort_row() override
Definition: protocol_local_v2.h:409
size_t m_column_count
Definition: protocol_local_v2.h:346
Protocol_local_v2(THD *thd, Statement_handle *execute_statement)
Definition: protocol_local_v2.cc:45
bool send_field_metadata(Send_field *field, const CHARSET_INFO *charset) override
Sends field metadata.
Definition: protocol_local_v2.cc:432
Result_set_capacity m_result_set_capacity
Definition: protocol_local_v2.h:353
bool store_long(longlong from, uint32) override
Definition: protocol_local_v2.cc:145
bool store_string(const char *str, size_t length, const CHARSET_INFO *src_cs, const CHARSET_INFO *dst_cs)
Store a string value in a result set column, optionally having converted it to character_set_results.
Definition: protocol_local_v2.cc:119
bool store_float(float value, uint32 decimals, uint32 zerofill) override
Definition: protocol_local_v2.cc:195
bool store_null() override
Add a NULL column to the current row.
Definition: protocol_local_v2.cc:75
void set_result_set_capacity(size_t capacity)
Set the capacity in bytes allowed for caching results.
Definition: protocol_local_v2.h:432
bool m_send_metadata
Definition: protocol_local_v2.h:345
value_t * m_current_column
Definition: protocol_local_v2.h:337
Column_metadata * m_metadata_row
Definition: protocol_local_v2.h:339
value_t * m_current_row
Definition: protocol_local_v2.h:336
bool store_short(longlong from, uint32) override
Definition: protocol_local_v2.cc:141
bool store_ps_status(ulong, uint, uint, ulong) override
Sends prepared statement's id and metadata to the client after prepare.
Definition: protocol_local_v2.h:423
uint get_compression_level() override
Returns compression level.
Definition: protocol_local_v2.cc:329
char * get_compression_algorithm() override
Returns compression algorithm name.
Definition: protocol_local_v2.cc:327
ulong get_client_capabilities() override
Returns the client capabilities stored on the protocol.
Definition: protocol_local_v2.cc:253
Result_set * m_result_set
Definition: protocol_local_v2.h:329
bool store_longlong(longlong value)
Definition: protocol_local_v2.cc:100
bool store_floating_type(double value)
Definition: protocol_local_v2.cc:190
void start_row() override
Called between two result set rows.
Definition: protocol_local_v2.cc:279
bool store_double(double value, uint32 decimals, uint32 zerofill) override
Definition: protocol_local_v2.cc:199
int read_packet() override
Read packet from client.
Definition: protocol_local_v2.cc:251
void add_row_to_result_set()
Definition: protocol_local_v2.cc:57
bool store_date(const MYSQL_TIME &time) override
Definition: protocol_local_v2.cc:182
bool connection_alive() const override
Checks if the protocol's connection with the client is still alive.
Definition: protocol_local_v2.cc:261
void end_partial_result_set() override
Definition: protocol_local_v2.cc:266
bool store_temporal(const MYSQL_TIME &time)
Definition: protocol_local_v2.cc:173
enum enum_protocol_type type() const override
Definition: protocol_local_v2.h:374
uint m_current_row_index
Definition: protocol_local_v2.h:351
bool send_eof(uint server_status, uint statement_warn_count) override
Send eof message to the client.
Definition: protocol_local_v2.cc:360
bool store_time(const MYSQL_TIME &time, uint precision) override
Definition: protocol_local_v2.cc:186
bool end_result_metadata() override
Signals the client that the metadata sending is done.
Definition: protocol_local_v2.cc:349
bool store_decimal(const my_decimal *, uint, uint) override
Definition: protocol_local_v2.cc:154
bool store_tiny(longlong from, uint32) override
Definition: protocol_local_v2.cc:137
List< Row< value_t > > * m_data_rows
Definition: protocol_local_v2.h:333
THD * m_thd
Definition: protocol_local_v2.h:348
Row< Column_metadata > * m_fields
Definition: protocol_local_v2.h:334
bool store_field(const Field *field) override
Definition: protocol_local_v2.cc:205
bool store_datetime(const MYSQL_TIME &time, uint precision) override
Definition: protocol_local_v2.cc:178
bool start_result_metadata(uint num_cols, uint flags, const CHARSET_INFO *resultcs) override
Prepares the server for metadata sending.
Definition: protocol_local_v2.cc:331
int get_command(COM_DATA *, enum_server_command *) override
Reads the command from the protocol and creates a command.
Definition: protocol_local_v2.h:399
MEM_ROOT m_result_set_mem_root
Definition: protocol_local_v2.h:326
size_t get_result_set_capacity()
Get the capacity in bytes allowed for caching results.
Definition: protocol_local_v2.h:439
uint get_rw_status() override
Returns the read/writing status.
Definition: protocol_local_v2.cc:323
void clear_resultset_mem_root()
Clear MEM_ROOT and related members.
Definition: protocol_local_v2.cc:506
bool send_parameters(List< Item_param > *, bool) override
Sends the OUT-parameters to the client.
Definition: protocol_local_v2.h:422
enum enum_vio_type connection_type() const override
Definition: protocol_local_v2.h:375
bool has_client_capability(unsigned long client_capability) override
Checks if the client capabilities include the one specified as parameter.
Definition: protocol_local_v2.cc:257
bool flush() override
Used for the classic protocol.
Definition: protocol_local_v2.h:421
int shutdown(bool server_shutdown=false) override
Thread is being shut down, disconnect and free resources.
Definition: protocol_local_v2.cc:269
~Protocol_local_v2() override
Definition: protocol_local_v2.h:395
Column_metadata * m_current_metadata_column
Definition: protocol_local_v2.h:340
bool get_compression() override
Returns if the protocol is compressed or not.
Definition: protocol_local_v2.cc:325
Statement_handle * m_execute_statement
Definition: protocol_local_v2.h:324
uint get_current_column_number()
Definition: protocol_local_v2.h:387
Definition: protocol.h:33
enum_protocol_type
Enum used by type() to specify the protocol type.
Definition: protocol.h:101
@ PROTOCOL_LOCAL
Definition: protocol.h:105
This class is used to limit the bytes collected in Result_set.
Definition: protocol_local_v2.h:117
void reset()
Definition: protocol_local_v2.h:142
bool has_capacity()
Definition: protocol_local_v2.h:139
void set_capacity(uint64_t cap)
Definition: protocol_local_v2.h:144
uint64_t get_capacity()
Definition: protocol_local_v2.h:146
static constexpr auto MAX_CAPACITY
Definition: protocol_local_v2.h:120
void add_bytes(uint64_t amend)
Definition: protocol_local_v2.h:132
uint64_t m_configured_capacity
Definition: protocol_local_v2.h:123
uint64_t m_current_capacity
Definition: protocol_local_v2.h:125
A result set contains the result of a query.
Definition: protocol_local_v2.h:154
Row< Column_metadata > * m_fields
Definition: protocol_local_v2.h:157
Result_set()
Definition: protocol_local_v2.cc:31
Row< Column_metadata > * get_fields()
Get the field metadata.
Definition: protocol_local_v2.h:243
Result_set & operator=(Result_set &&)=delete
ulonglong get_num_affected_rows() const
Get the num affected row count.
Definition: protocol_local_v2.h:208
bool is_last_row()
Check if the iterator is at the last row.
Definition: protocol_local_v2.h:201
unsigned int size() const
Get number for rows in result set.
Definition: protocol_local_v2.h:236
List< Row< value_t > > * get_rows()
Get the list of rows from result set.
Definition: protocol_local_v2.h:222
List< Row< value_t > > * m_rows
Definition: protocol_local_v2.h:161
Result_set & operator=(Result_set &)=delete
Result_set(const Result_set &)=delete
Row< value_t > * get_next_row()
Get the next row.
Definition: protocol_local_v2.h:192
void update(List< Row< value_t > > *rows_arg, Row< Column_metadata > *fields, size_t column_count, ulonglong affected_rows, ulonglong last_insert_id)
Update the members of result set.
Definition: protocol_local_v2.h:299
Result_set * m_next
Definition: protocol_local_v2.h:167
ulonglong m_affected_row
Definition: protocol_local_v2.h:169
List_iterator_fast< Row< value_t > > m_row_iterator
Definition: protocol_local_v2.h:164
size_t m_column_count
Definition: protocol_local_v2.h:158
ulonglong m_last_insert_id
Definition: protocol_local_v2.h:170
bool has_next()
Check if we have more than one result set.
Definition: protocol_local_v2.h:277
Result_set * get_next()
Get the next result set object.
Definition: protocol_local_v2.h:284
size_t get_field_count() const
Get the field count in result set.
Definition: protocol_local_v2.h:250
void set_next(Result_set *ptr)
Set the current result set pointer.
Definition: protocol_local_v2.h:292
Result_set(const Result_set &&)=delete
ulonglong get_last_insert_id() const
Get the last insert id.
Definition: protocol_local_v2.h:215
A row of result or a row of metadata A row is a collection of Column values or Column metadata.
Definition: protocol_local_v2.h:92
Row(T *column_array_arg, size_t column_count_arg)
Definition: protocol_local_v2.h:107
size_t size() const
Definition: protocol_local_v2.h:105
T * m_column_array
Definition: protocol_local_v2.h:94
T * get_column(const unsigned int column_index) const
Definition: protocol_local_v2.h:101
const T & operator[](const unsigned int column_index) const
Definition: protocol_local_v2.h:98
size_t m_column_count
Definition: protocol_local_v2.h:95
T * get_column_array()
Definition: protocol_local_v2.h:110
Statement_handle is extension of Ed_connection.
Definition: statement.h:66
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
Class representing a warning.
Definition: warning.h:41
Warning(const uint32 level, const uint32_t code, const char *message)
Definition: protocol_local_v2.h:77
uint32_t m_level
Definition: protocol_local_v2.h:80
const char * m_message
Definition: protocol_local_v2.h:82
uint32_t m_code
Definition: protocol_local_v2.h:81
my_decimal class limits 'decimal_t' type to what we need in MySQL.
Definition: my_decimal.h:95
static MEM_ROOT mem_root
Definition: client_plugin.cc:114
enum_field_types
Column types for MySQL Note: Keep include/mysql/components/services/bits/stored_program_bits....
Definition: field_types.h:55
void my_error(int nr, myf MyFlags,...)
Fill in and print a previously registered error message.
Definition: my_error.cc:216
static int flags[50]
Definition: hp_test1.cc:40
enum_server_command
A list of all MySQL protocol commands.
Definition: my_command.h:48
It is interface module to fixed precision decimals library.
unsigned long long int ulonglong
Definition: my_inttypes.h:56
long long int longlong
Definition: my_inttypes.h:55
#define MYF(v)
Definition: my_inttypes.h:97
uint32_t uint32
Definition: my_inttypes.h:67
Common header for many mysys elements.
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1081
constexpr value_type zerofill
Definition: classic_protocol_constants.h:274
const std::string charset("charset")
Definition: commit_order_queue.h:34
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
std::variant< std::monostate, int64_t *, uint64_t *, double *, MYSQL_TIME *, char *, decimal * > value_t
A type to store the value of a Column which can be one of all the types that are supported by the Pro...
Definition: protocol_local_v2.h:56
Definition: m_ctype.h:423
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:83
void Clear()
Deallocate all the RAM used.
Definition: my_alloc.cc:172
void * Alloc(size_t length)
Allocate memory.
Definition: my_alloc.h:145
Definition: mysql_time.h:82
A structure to store a decimal value together with its precision and number of decimals TODO: HCS-100...
Definition: protocol_local_v2.h:43
uint dec
Definition: protocol_local_v2.h:46
uint prec
Definition: protocol_local_v2.h:45
my_decimal decimal
Definition: protocol_local_v2.h:44
Definition: com_data.h:104
enum_vio_type
Definition: violite.h:79
@ VIO_TYPE_LOCAL
Used internally by the prepared statements.
Definition: violite.h:107