MySQL 8.4.2
Source Code Documentation
|
#include <protocol.h>
Public Types | |
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 |
Public Member Functions | |
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... | |
virtual int | read_packet ()=0 |
Read packet from client. More... | |
virtual int | get_command (COM_DATA *com_data, enum_server_command *cmd)=0 |
Reads the command from the protocol and creates a command. More... | |
virtual enum enum_protocol_type | type () const =0 |
virtual enum enum_vio_type | connection_type () const =0 |
virtual bool | store_null ()=0 |
virtual bool | store_tiny (longlong from, uint32 zerofill)=0 |
virtual bool | store_short (longlong from, uint32 zerofill)=0 |
virtual bool | store_long (longlong from, uint32 zerofill)=0 |
virtual bool | store_longlong (longlong from, bool unsigned_flag, uint32 zerofill)=0 |
virtual bool | store_decimal (const my_decimal *, uint, uint)=0 |
virtual bool | store_string (const char *from, size_t length, const CHARSET_INFO *fromcs)=0 |
virtual bool | store_float (float from, uint32 decimals, uint32 zerofill)=0 |
virtual bool | store_double (double from, uint32 decimals, uint32 zerofill)=0 |
virtual bool | store_datetime (const MYSQL_TIME &time, uint precision)=0 |
virtual bool | store_date (const MYSQL_TIME &time)=0 |
virtual bool | store_time (const MYSQL_TIME &time, uint precision)=0 |
virtual bool | store_field (const Field *field)=0 |
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) |
virtual ulong | get_client_capabilities ()=0 |
Returns the client capabilities stored on the protocol. More... | |
virtual bool | has_client_capability (unsigned long client_capability)=0 |
Checks if the client capabilities include the one specified as parameter. More... | |
virtual bool | connection_alive () const =0 |
Checks if the protocol's connection with the client is still alive. More... | |
virtual void | start_row ()=0 |
Result set sending functions. More... | |
virtual bool | end_row ()=0 |
virtual void | abort_row ()=0 |
virtual void | end_partial_result_set ()=0 |
virtual int | shutdown (bool server_shutdown=false)=0 |
Thread is being shut down, disconnect and free resources. More... | |
virtual uint | get_rw_status ()=0 |
Returns the read/writing status. More... | |
virtual bool | get_compression ()=0 |
Returns if the protocol is compressed or not. More... | |
virtual char * | get_compression_algorithm ()=0 |
Returns compression algorithm name. More... | |
virtual uint | get_compression_level ()=0 |
Returns compression level. More... | |
virtual bool | start_result_metadata (uint num_cols, uint flags, const CHARSET_INFO *resultcs)=0 |
Prepares the server for metadata sending. More... | |
virtual bool | send_field_metadata (Send_field *field, const CHARSET_INFO *charset)=0 |
Sends field metadata. More... | |
virtual bool | end_result_metadata ()=0 |
Signals the client that the metadata sending is done. More... | |
virtual bool | send_ok (uint server_status, uint statement_warn_count, ulonglong affected_rows, ulonglong last_insert_id, const char *message)=0 |
Send ok message to the client. More... | |
virtual bool | send_eof (uint server_status, uint statement_warn_count)=0 |
Send eof message to the client. More... | |
virtual bool | send_error (uint sql_errno, const char *err_msg, const char *sql_state)=0 |
Send error message to the client. More... | |
virtual bool | flush ()=0 |
Used for the classic protocol. More... | |
virtual bool | store_ps_status (ulong stmt_id, uint column_count, uint param_count, ulong cond_count)=0 |
Sends prepared statement's id and metadata to the client after prepare. More... | |
virtual bool | send_parameters (List< Item_param > *parameters, bool is_sql_prepare)=0 |
Sends the OUT-parameters to the client. More... | |
Static Public Member Functions | |
static Type | get_default () |
static Type | get_by_name (const std::string &name) |
Returns type of the protocol by its name. More... | |
static std::string | to_string (const Type &type) |
static uint16_t | get_default_port (Type type) |
Returns default port for the selected protocol. More... | |
Private Attributes | |
Protocol * | m_previous_protocol = nullptr |
Pointer to the Protocol below on the stack. More... | |
Static Private Attributes | |
static constexpr uint16_t | kClassicProtocolDefaultPort {3306} |
default server ports for supported protocols More... | |
static constexpr uint16_t | kXProtocolDefaultPort {33060} |
using Protocol::Type = BaseProtocol::Type |
anonymous enum |
|
virtualdefault |
|
pure virtual |
Implemented in Protocol_callback, Protocol_classic, Protocol_local, and Protocol_local_v2.
|
pure virtual |
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 |
Implemented in Protocol_callback, Protocol_classic, Protocol_local, and Protocol_local_v2.
|
pure virtual |
Implemented in Protocol_callback, Protocol_classic, Protocol_local, and Protocol_local_v2.
|
pure virtual |
Implemented in Protocol_callback, Protocol_classic, Protocol_local, and Protocol_local_v2.
|
pure virtual |
Signals the client that the metadata sending is done.
Clears the server after sending the metadata.
false | Ok |
true | An error occurred |
Implemented in Protocol_callback, Protocol_classic, Protocol_local, and Protocol_local_v2.
|
pure virtual |
Implemented in Protocol_callback, Protocol_classic, Protocol_local, and Protocol_local_v2.
|
pure virtual |
Used for the classic protocol.
Makes the protocol send the messages/data to the client.
false | The flush was successful. |
true | An error occurred. |
Implemented in Protocol_callback, Protocol_classic, Protocol_local, and Protocol_local_v2.
|
inlinestatic |
Returns type of the protocol by its name.
|
pure virtual |
Returns the client capabilities stored on the protocol.
The available capabilities are defined in mysql_com.h
Implemented in Protocol_callback, Protocol_classic, Protocol_local, and Protocol_local_v2.
|
pure virtual |
Reads the command from the protocol and creates a command.
com_data | out parameter |
cmd | out parameter |
Implemented in Protocol_local_v2, Protocol_callback, Protocol_classic, and Protocol_local.
|
pure virtual |
Returns if the protocol is compressed or not.
false | Not compressed |
true | Compressed |
Implemented in Protocol_callback, Protocol_classic, Protocol_local, and Protocol_local_v2.
|
pure virtual |
Returns compression algorithm name.
string | compression method name |
NULL | if no compression is enabled |
Implemented in Protocol_callback, Protocol_classic, Protocol_local, and Protocol_local_v2.
|
pure virtual |
Returns compression level.
Implemented in Protocol_callback, Protocol_classic, Protocol_local, and Protocol_local_v2.
|
inlinestatic |
|
inlinestatic |
Returns default port for the selected protocol.
|
pure virtual |
Returns the read/writing status.
1 | Read |
2 | Write |
0 | Other(Idle, Killed) |
Implemented in Protocol_callback, Protocol_classic, Protocol_local, and Protocol_local_v2.
|
pure virtual |
Checks if the client capabilities include the one specified as parameter.
true | if it includes the specified capability |
false | otherwise |
Implemented in Protocol_callback, Protocol_classic, Protocol_local, and Protocol_local_v2.
|
inline |
Remove the reference to the previous protocol and return it.
|
inline |
Set reference to "this" as the previous protocol on the protocol provided as argument.
protocol | Protocol to become the top of Protocol stack. |
|
pure virtual |
Read packet from client.
-1 | fatal error |
0 | ok |
1 | non-fatal error |
Implemented in Protocol_callback, Protocol_classic, Protocol_local, and Protocol_local_v2.
|
pure virtual |
Send eof message to the client.
server_status | The server status |
statement_warn_count | Total number of warnings |
false | The message was successfully sent |
true | An error occurred and the messages wasn't sent properly |
Implemented in Protocol_classic, Protocol_local, Protocol_local_v2, and Protocol_callback.
|
pure virtual |
Send error message to the client.
sql_errno | The error code to send |
err_msg | A pointer to the error message |
sql_state | SQL state |
false | The message was successfully sent |
true | An error occurred and the messages wasn't sent properly |
Implemented in Protocol_callback, Protocol_classic, Protocol_local, and Protocol_local_v2.
|
pure virtual |
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 |
Implemented in Protocol_local, Protocol_local_v2, Protocol_callback, and Protocol_classic.
|
pure virtual |
Send ok message to the client.
server_status | The server status |
statement_warn_count | Total number of warnings |
affected_rows | Number of rows changed by statement |
last_insert_id | Last insert id (Auto_increment id for first row if used) |
message | Message to send to the client |
false | The message was successfully sent |
true | An error occurred and the messages wasn't sent properly |
Implemented in Protocol_classic, Protocol_local, Protocol_local_v2, and Protocol_callback.
|
pure virtual |
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. |
Implemented in Protocol_local, Protocol_local_v2, Protocol_callback, Protocol_binary, and Protocol_text.
|
pure virtual |
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. |
Implemented in Protocol_callback, Protocol_classic, Protocol_local, and Protocol_local_v2.
|
pure virtual |
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 |
Implemented in Protocol_callback, Protocol_classic, Protocol_binary, Protocol_local, and Protocol_local_v2.
|
pure virtual |
Result set sending functions.
Server uses following schema to send result: ... sending metadata ... | start_result_metadata(...) | start_row() | send_field_metadata(...) | end_row() ... same for each field sent ... | end_result_metadata(...) | ... sending result ... | start_row(...) | store_xxx(...) ... store_xxx(..) is called for each field ... | end_row(...) ... same for each row, until all rows are sent ... | send_ok/eof/error(...) However, a protocol implementation might use different schema. For example, Protocol_callback ignores start/end_row when metadata is being sent.
Implemented in Protocol_callback, Protocol_text, Protocol_binary, Protocol_local, and Protocol_local_v2.
|
inline |
Send \0 end terminated string.
from | NullS or \0 terminated string. |
fromcs | Character set of the from string. |
false | ok |
true | error |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
pure virtual |
Implemented in Protocol_callback, Protocol_text, Protocol_binary, Protocol_local, and Protocol_local_v2.
|
pure virtual |
Implemented in Protocol_callback, Protocol_text, Protocol_binary, Protocol_local, and Protocol_local_v2.
|
pure virtual |
Implemented in Protocol_text, Protocol_binary, Protocol_local, Protocol_local_v2, and Protocol_callback.
Implemented in Protocol_text, Protocol_binary, Protocol_callback, Protocol_local, and Protocol_local_v2.
|
pure virtual |
Implemented in Protocol_classic, Protocol_callback, Protocol_local, and Protocol_local_v2.
Implemented in Protocol_callback, Protocol_text, Protocol_binary, Protocol_local, and Protocol_local_v2.
|
inline |
Implemented in Protocol_text, Protocol_binary, Protocol_callback, Protocol_callback, Protocol_local, and Protocol_local_v2.
|
inline |
|
pure virtual |
Implemented in Protocol_callback, Protocol_text, Protocol_binary, Protocol_local, and Protocol_local_v2.
|
pure virtual |
Implemented in Protocol_callback, Protocol_text, Protocol_binary, Protocol_local, and Protocol_local_v2.
|
pure virtual |
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. |
Implemented in Protocol_callback, Protocol_classic, Protocol_local, and Protocol_local_v2.
|
inline |
Implemented in Protocol_text, Protocol_binary, Protocol_callback, Protocol_callback, Protocol_local, and Protocol_local_v2.
|
pure virtual |
Implemented in Protocol_classic, Protocol_local, Protocol_local_v2, and Protocol_callback.
|
pure virtual |
Implemented in Protocol_callback, Protocol_text, Protocol_binary, Protocol_local, and Protocol_local_v2.
|
inline |
Implemented in Protocol_text, Protocol_binary, Protocol_callback, Protocol_local, and Protocol_local_v2.
|
inlinestatic |
|
pure virtual |
Implemented in Protocol_callback, Protocol_text, Protocol_binary, Protocol_local, and Protocol_local_v2.
|
staticconstexprprivate |
default server ports for supported protocols
|
staticconstexprprivate |
Pointer to the Protocol below on the stack.