MySQL 8.0.39
Source Code Documentation
|
Protocol_local: a helper class to intercept the result of the data written to the network. More...
Public Member Functions | |
Protocol_local (THD *thd, Ed_connection *ed_connection) | |
~Protocol_local () override | |
int | read_packet () override |
Read packet from client. More... | |
int | get_command (COM_DATA *com_data, enum_server_command *cmd) override |
Reads the command from the protocol and creates a command. More... | |
ulong | get_client_capabilities () override |
Returns the client capabilities stored on the protocol. More... | |
bool | has_client_capability (unsigned long client_capability) override |
Checks if the client capabilities include the one specified as parameter. More... | |
void | end_partial_result_set () override |
int | shutdown (bool server_shutdown=false) override |
Thread is being shut down, disconnect and free resources. More... | |
bool | connection_alive () const override |
Checks if the protocol's connection with the client is still alive. More... | |
void | start_row () override |
Called between two result set rows. More... | |
bool | end_row () override |
Add the current row to the result set. More... | |
void | abort_row () override |
uint | get_rw_status () override |
Returns the read/writing status. More... | |
bool | get_compression () override |
Returns if the protocol is compressed or not. More... | |
char * | get_compression_algorithm () override |
Returns compression algorithm name. More... | |
uint | get_compression_level () override |
Returns compression level. More... | |
bool | start_result_metadata (uint num_cols, uint flags, const CHARSET_INFO *resultcs) override |
Prepares the server for metadata sending. More... | |
bool | end_result_metadata () override |
Signals the client that the metadata sending is done. More... | |
bool | send_field_metadata (Send_field *field, const CHARSET_INFO *charset) override |
Sends field metadata. More... | |
bool | flush () override |
Used for the classic protocol. More... | |
bool | send_parameters (List< Item_param > *, bool) override |
Sends the OUT-parameters to the client. More... | |
bool | store_ps_status (ulong, uint, uint, ulong) override |
Sends prepared statement's id and metadata to the client after prepare. More... | |
Public Member Functions inherited from Protocol | |
virtual | ~Protocol ()=default |
Protocol * | pop_protocol () |
Remove the reference to the previous protocol and return it. More... | |
void | push_protocol (Protocol *protocol) |
Set reference to "this" as the previous protocol on the protocol provided as argument. More... | |
bool | store (int from) |
bool | store (uint32 from) |
bool | store (longlong from) |
bool | store (ulonglong from) |
bool | store_tiny (longlong from) |
bool | store_short (longlong from) |
bool | store_long (longlong from) |
bool | store_longlong (longlong from, bool unsigned_flag) |
bool | store (const char *from, const CHARSET_INFO *fromcs) |
Send \0 end terminated string. More... | |
bool | store (String *str) |
bool | store (const LEX_STRING &s, const CHARSET_INFO *cs) |
Protected Member Functions | |
bool | store_null () override |
Add a NULL column to the current row. More... | |
bool | store_tiny (longlong from, uint32) override |
Store a tiny int as is (1 byte) in a result set column. More... | |
bool | store_short (longlong from, uint32) override |
Store a short as is (2 bytes, host order) in a result set column. More... | |
bool | store_long (longlong from, uint32) override |
Store a "long" as is (4 bytes, host order) in a result set column. More... | |
bool | store_longlong (longlong from, bool unsigned_flag, uint32) override |
Store a "longlong" as is (8 bytes, host order) in a result set column. More... | |
bool | store_decimal (const my_decimal *, uint, uint) override |
Store a decimal in string format in a result set column. More... | |
bool | store_string (const char *from, size_t length, const CHARSET_INFO *cs) override |
Convert to cs_results and store a string. More... | |
bool | store_datetime (const MYSQL_TIME &time, uint precision) override |
bool | store_date (const MYSQL_TIME &time) override |
Store MYSQL_TIME (in binary format) More... | |
bool | store_time (const MYSQL_TIME &time, uint precision) override |
Store MYSQL_TIME (in binary format) More... | |
bool | store_float (float value, uint32 decimals, uint32 zerofill) override |
bool | store_double (double value, uint32 decimals, uint32 zerofill) override |
bool | store_field (const Field *field) override |
enum enum_protocol_type | type () const override |
enum enum_vio_type | connection_type () const override |
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. More... | |
bool | send_eof (uint server_status, uint statement_warn_count) override |
Called at the end of a result set. More... | |
bool | send_error (uint sql_errno, const char *err_msg, const char *sqlstate) override |
Called to send an error to the client at the end of a statement. More... | |
Private Member Functions | |
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. More... | |
bool | store_column (const void *data, size_t length) |
A helper method to add any column to the current row in its binary form. More... | |
void | opt_add_row_to_rset () |
A helper function to add the current row to the current result set. More... | |
Private Attributes | |
Ed_connection * | m_connection |
MEM_ROOT | m_rset_root |
List< Ed_row > * | m_rset |
size_t | m_column_count |
Ed_column * | m_current_row |
Ed_column * | m_current_column |
Ed_row * | m_fields |
bool | m_send_metadata |
THD * | m_thd |
Additional Inherited Members | |
Public Types inherited from Protocol | |
enum | enum_protocol_type { PROTOCOL_TEXT = 0 , PROTOCOL_BINARY = 1 , PROTOCOL_LOCAL = 2 , PROTOCOL_ERROR = 3 , PROTOCOL_PLUGIN = 4 } |
Enum used by type() to specify the protocol type. More... | |
enum | { SEND_NUM_ROWS = 1 , SEND_DEFAULTS = 2 , SEND_EOF = 4 } |
Flags available to alter the way the messages are sent to the client. More... | |
using | Type = BaseProtocol::Type |
Static Public Member Functions inherited from Protocol | |
static Type | get_default () |
static Type | get_by_name (const std::string &name) |
Returns type of the protocol by its name. More... | |
static uint16_t | get_default_port (Type type) |
Returns default port for the selected protocol. More... | |
Protocol_local: a helper class to intercept the result of the data written to the network.
At the start of every result set, start_result_metadata allocates m_rset to prepare for the results. The metadata is stored on m_current_row which will be transferred to m_fields in end_result_metadata. The memory for the metadata is allocated on m_rset_root.
Then, for every row of the result received, each of the fields is stored in m_current_row. Then the row is moved to m_rset and m_current_row is cleared to receive the next row. The memory for all the results are also stored in m_rset_root.
Finally, at the end of the result set, a new instance of Ed_result_set is created on m_rset_root and the result set (m_rset and m_fields) is moved into this instance. The ownership of MEM_ROOT m_rset_root is also transferred to this instance. So, at the end we have a fresh MEM_ROOT, cleared m_rset and m_fields to accept the next result set.
Protocol_local::Protocol_local | ( | THD * | thd, |
Ed_connection * | ed_connection | ||
) |
|
inlineoverride |
|
inlineoverridevirtual |
Implements Protocol.
|
overridevirtual |
Checks if the protocol's connection with the client is still alive.
It should always return true unless the protocol closed the connection.
true | if the connection is still alive |
false | otherwise |
Implements Protocol.
|
inlineoverrideprotectedvirtual |
Implements Protocol.
|
overridevirtual |
Implements Protocol.
|
overridevirtual |
Signals the client that the metadata sending is done.
Clears the server after sending the metadata.
false | Ok |
true | An error occurred |
Implements Protocol.
|
overridevirtual |
Add the current row to the result set.
Implements Protocol.
|
inlineoverridevirtual |
Used for the classic protocol.
Makes the protocol send the messages/data to the client.
false | The flush was successful. |
true | An error occurred. |
Implements Protocol.
|
overridevirtual |
Returns the client capabilities stored on the protocol.
The available capabilities are defined in mysql_com.h
Implements Protocol.
|
overridevirtual |
Reads the command from the protocol and creates a command.
com_data | out parameter |
cmd | out parameter |
Implements Protocol.
|
overridevirtual |
Returns if the protocol is compressed or not.
false | Not compressed |
true | Compressed |
Implements Protocol.
|
overridevirtual |
Returns compression algorithm name.
string | compression method name |
NULL | if no compression is enabled |
Implements Protocol.
|
overridevirtual |
|
overridevirtual |
Returns the read/writing status.
1 | Read |
2 | Write |
0 | Other(Idle, Killed) |
Implements Protocol.
|
overridevirtual |
Checks if the client capabilities include the one specified as parameter.
true | if it includes the specified capability |
false | otherwise |
Implements Protocol.
|
private |
A helper function to add the current row to the current result set.
Called in
|
overridevirtual |
|
overrideprotectedvirtual |
Called at the end of a result set.
Append a complete result set to the list in Ed_connection.
Don't send anything to the client, but instead finish building of the result set at hand.
Implements Protocol.
|
overrideprotectedvirtual |
Called to send an error to the client at the end of a statement.
Implements Protocol.
|
overridevirtual |
Sends field metadata.
field | Field metadata to be send to the client |
charset | Field's charset: in case it is different than the one used by the connection it will be used to convert the value to the connection's charset |
false | The metadata was successfully sent |
true | An error occurred |
Implements Protocol.
|
overrideprotectedvirtual |
Called for statements that don't have a result set, at statement end.
Implements Protocol.
|
inlineoverridevirtual |
Sends the OUT-parameters to the client.
parameters | List of PS/SP parameters (both input and output). |
is_sql_prepare | Used for the legacy protocol. If we're dealing with sql prepare then text protocol will be used. |
false | Success. |
true | Error. |
Implements Protocol.
|
overridevirtual |
Thread is being shut down, disconnect and free resources.
server_shutdown | If false then this is normal thread shutdown. If true then the server is shutting down. |
Implements Protocol.
|
overridevirtual |
Prepares the server for metadata sending.
Notifies the client that the metadata sending will start.
num_cols | Number of columns that will be sent |
flags | Flags to alter the metadata sending Can be any of the following: SEND_NUM_ROWS, SEND_DEFAULTS, SEND_EOF |
resultcs | Charset to convert to |
false | Ok |
true | An error occurred |
Implements Protocol.
|
overridevirtual |
Called between two result set rows.
Prepare structures to fill result set rows. Unfortunately, we can't return an error here. If memory allocation fails, we'll have to return an error later. And so is done in methods such as
Implements Protocol.
|
private |
A helper method to add any column to the current row in its binary form.
Allocates memory for the data in the result set memory root.
|
overrideprotectedvirtual |
Store MYSQL_TIME (in binary format)
Implements Protocol.
|
overrideprotectedvirtual |
Implements Protocol.
|
overrideprotectedvirtual |
Store a decimal in string format in a result set column.
Implements Protocol.
|
overrideprotectedvirtual |
Implements Protocol.
|
overrideprotectedvirtual |
Implements Protocol.
|
overrideprotectedvirtual |
Implements Protocol.
|
overrideprotectedvirtual |
Store a "longlong" as is (8 bytes, host order) in a result set column.
Implements Protocol.
|
overrideprotectedvirtual |
Add a NULL column to the current row.
Implements Protocol.
|
inlineoverridevirtual |
Sends prepared statement's id and metadata to the client after prepare.
stmt_id | Statement id. |
column_count | Number of columns. |
param_count | Number of parameters. |
cond_count | Number of conditions raised by the current statement. |
false | The send was successful. |
true | An error occurred. |
Implements Protocol.
Store a short as is (2 bytes, host order) in a result set column.
Implements Protocol.
|
overrideprotectedvirtual |
Convert to cs_results and store a string.
Implements Protocol.
|
private |
Store a string value in a result set column, optionally having converted it to character_set_results.
|
overrideprotectedvirtual |
Store MYSQL_TIME (in binary format)
Implements Protocol.
Store a tiny int as is (1 byte) in a result set column.
Implements Protocol.
|
inlineoverrideprotectedvirtual |
Implements Protocol.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |