MySQL 8.4.3
Source Code Documentation
|
#include <protocol_classic.h>
Public Member Functions | |
Protocol_classic () | |
Protocol_classic (THD *thd) | |
void | init (THD *thd_arg) |
bool | store_field (const Field *field) final |
bool | store_string (const char *from, size_t length, const CHARSET_INFO *cs) final |
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... | |
bool | create_command (COM_DATA *com_data, enum_server_command cmd, uchar *pkt, size_t length) |
Parses the passed parameters and creates a command. More... | |
bool | flush () override |
Used for the classic protocol. More... | |
void | end_partial_result_set () override |
Finish the result set with EOF packet, as is expected by the client, if there is an error evaluating the next row and a continue handler for the error. More... | |
bool | end_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 *item_charset) override |
Sends a single column metadata. More... | |
void | abort_row () override |
enum enum_vio_type | connection_type () const override |
Returns the type of the connection. More... | |
my_socket | get_socket () |
bool | init_net (Vio *vio) |
void | claim_memory_ownership (bool claim) |
void | end_net () |
bool | write (const uchar *ptr, size_t len) |
uchar | get_error () |
void | set_max_packet_size (ulong max_packet_size) |
int | shutdown (bool server_shutdown=false) override |
Thread is being shut down, disconnect and free resources. More... | |
void | wipe_net () |
bool | connection_alive () const override |
Checks if the protocol's connection with the client is still alive. More... | |
ulong | get_client_capabilities () override |
Returns the client capabilities stored on the protocol. More... | |
void | set_client_capabilities (ulong client_capabilities) |
void | add_client_capability (ulong client_capability) |
void | remove_client_capability (unsigned long capability) |
bool | has_client_capability (unsigned long client_capability) override |
Checks if the client capabilities include the one specified as parameter. More... | |
NET * | get_net () |
Vio * | get_vio () |
const Vio * | get_vio () const |
void | set_vio (Vio *vio) |
void | set_output_pkt_nr (uint pkt_nr) |
uint | get_output_pkt_nr () |
String * | get_output_packet () |
ulong | get_packet_length () |
uchar * | get_raw_packet () |
virtual void | set_read_timeout (ulong read_timeout, bool on_full_packet=false) |
virtual void | set_write_timeout (ulong write_timeout) |
void | set_result_character_set (const CHARSET_INFO *charset) |
Sets the character set expected by the client. 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... | |
virtual enum enum_protocol_type | 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_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 |
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 void | start_row ()=0 |
Result set sending functions. More... | |
virtual bool | send_parameters (List< Item_param > *parameters, bool is_sql_prepare)=0 |
Sends the OUT-parameters to the client. More... | |
Public Attributes | |
bool | bad_packet |
Protected Member Functions | |
bool | send_ok (uint server_status, uint statement_warn_count, ulonglong affected_rows, ulonglong last_insert_id, const char *message) override |
A default implementation of "OK" packet response to the client. More... | |
bool | send_eof (uint server_status, uint statement_warn_count) override |
A default implementation of "EOF" packet response to the client. More... | |
bool | send_error (uint sql_errno, const char *err_msg, const char *sql_state) override |
A default implementation of "ERROR" packet response to the client. More... | |
bool | store_ps_status (ulong stmt_id, uint column_count, uint param_count, ulong cond_count) override |
Sends prepared statement's id and metadata to the client after prepare. More... | |
Protected Attributes | |
THD * | m_thd |
String * | packet |
String | convert |
uint | field_pos |
bool | send_metadata |
enum enum_field_types * | field_types |
uint | count |
uint | field_count |
uint | sending_flags |
ulong | input_packet_length |
uchar * | input_raw_packet |
const CHARSET_INFO * | result_cs |
Private Member Functions | |
bool | parse_packet (union COM_DATA *data, enum_server_command cmd) |
bool | net_store_data_with_conversion (const uchar *from, size_t length, const CHARSET_INFO *fromcs, const CHARSET_INFO *tocs) |
net_store_data() - extended version with character set conversion. More... | |
Private Attributes | |
ulong | m_client_capabilities |
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 std::string | to_string (const Type &type) |
static uint16_t | get_default_port (Type type) |
Returns default port for the selected protocol. More... | |
|
inline |
|
inline |
|
inlineoverridevirtual |
Implements Protocol.
|
inline |
void Protocol_classic::claim_memory_ownership | ( | bool | claim | ) |
|
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.
|
inlineoverridevirtual |
bool Protocol_classic::create_command | ( | COM_DATA * | com_data, |
enum_server_command | cmd, | ||
uchar * | pkt, | ||
size_t | length | ||
) |
Parses the passed parameters and creates a command.
com_data | out parameter |
cmd | in parameter |
pkt | packet to be parsed |
length | size of the packet |
false | ok |
true | error |
void Protocol_classic::end_net | ( | ) |
|
overridevirtual |
Finish the result set with EOF packet, as is expected by the client, if there is an error evaluating the next row and a continue handler for the error.
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 |
Implements Protocol.
|
overridevirtual |
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.
|
inlineoverridevirtual |
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 |
uchar Protocol_classic::get_error | ( | ) |
NET * Protocol_classic::get_net | ( | ) |
String * Protocol_classic::get_output_packet | ( | ) |
uint Protocol_classic::get_output_pkt_nr | ( | ) |
|
inline |
|
inline |
|
overridevirtual |
Returns the read/writing status.
1 | Read |
2 | Write |
0 | Other(Idle, Killed) |
Implements Protocol.
my_socket Protocol_classic::get_socket | ( | ) |
Vio * Protocol_classic::get_vio | ( | ) |
const Vio * Protocol_classic::get_vio | ( | ) | const |
|
inlineoverridevirtual |
Checks if the client capabilities include the one specified as parameter.
true | if it includes the specified capability |
false | otherwise |
Implements Protocol.
void Protocol_classic::init | ( | THD * | thd_arg | ) |
bool Protocol_classic::init_net | ( | Vio * | vio | ) |
|
private |
net_store_data() - extended version with character set conversion.
It is optimized for short strings whose length after conversion is guaranteed to be less than 251, which occupies exactly one byte to store length. It allows not to use the "convert" member as a temporary buffer, conversion is done directly to the "packet" member. The limit 251 is good enough to optimize send_result_set_metadata() because column, table, database names fit into this limit.
|
private |
|
overridevirtual |
|
inline |
|
overrideprotectedvirtual |
A default implementation of "EOF" packet response to the client.
Binary and text protocol do not differ in their EOF packet format.
Implements Protocol.
|
overrideprotectedvirtual |
A default implementation of "ERROR" packet response to the client.
Binary and text protocol do not differ in ERROR packet format.
Implements Protocol.
|
overridevirtual |
Sends a single column metadata.
field | Field description |
item_charset | Character set to use |
false | success |
true | error |
See Column Definition for the format
Implements Protocol.
|
overrideprotectedvirtual |
A default implementation of "OK" packet response to the client.
Currently this implementation is re-used by both network-oriented protocols – the binary and text one. They do not differ in their OK packet format, which allows for a significant simplification on client side.
Implements Protocol.
|
inline |
void Protocol_classic::set_max_packet_size | ( | ulong | max_packet_size | ) |
void Protocol_classic::set_output_pkt_nr | ( | uint | pkt_nr | ) |
|
virtual |
|
inline |
Sets the character set expected by the client.
This function is for unit tests. It should usually be set by calling start_result_metadata().
void Protocol_classic::set_vio | ( | Vio * | vio | ) |
|
virtual |
|
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.
Reimplemented in Protocol_binary.
|
overrideprotectedvirtual |
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.
|
finalvirtual |
Implements Protocol.
void Protocol_classic::wipe_net | ( | ) |
bool Protocol_classic::write | ( | const uchar * | ptr, |
size_t | len | ||
) |
bool Protocol_classic::bad_packet |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
private |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |