MySQL 9.1.0
Source Code Documentation
Protocol_local_v2 Class Referencefinal

This is extention of Protocol_local. More...

#include <protocol_local_v2.h>

Inheritance diagram for Protocol_local_v2:
[legend]

Public Member Functions

 Protocol_local_v2 (THD *thd, Statement_handle *execute_statement)
 
 ~Protocol_local_v2 () override
 
int read_packet () override
 Read packet from client. More...
 
int get_command (COM_DATA *, enum_server_command *) 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...
 
void set_result_set_capacity (size_t capacity)
 Set the capacity in bytes allowed for caching results. More...
 
size_t get_result_set_capacity ()
 Get the capacity in bytes allowed for caching results. More...
 
void clear_resultset_mem_root ()
 Clear MEM_ROOT and related members. More...
 
- Public Member Functions inherited from Protocol
virtual ~Protocol ()=default
 
Protocolpop_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
 
bool store_short (longlong from, uint32) override
 
bool store_long (longlong from, uint32) override
 
bool store_longlong (longlong from, bool unsigned_flag, uint32) override
 
bool store_decimal (const my_decimal *, uint, uint) override
 
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
 
bool store_time (const MYSQL_TIME &time, uint precision) override
 
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
 Send eof message to the client. More...
 
bool send_error (uint sql_errno, const char *err_msg, const char *sqlstate) override
 Called at the end of a result set. More...
 
uint get_current_column_number ()
 

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_longlong (longlong value)
 
bool store_floating_type (double value)
 
bool store_temporal (const MYSQL_TIME &time)
 
void add_row_to_result_set ()
 
template<typename T , typename V >
bool allocate_type (V *value)
 

Private Attributes

Statement_handlem_execute_statement
 
MEM_ROOT m_result_set_mem_root
 
Result_setm_result_set = nullptr
 
List< Row< value_t > > * m_data_rows
 
Row< Column_metadata > * m_fields
 
value_tm_current_row
 
value_tm_current_column
 
Column_metadatam_metadata_row
 
Column_metadatam_current_metadata_column
 
bool m_send_metadata
 
size_t m_column_count
 
THDm_thd
 
uint m_current_row_index = 0
 
Result_set_capacity m_result_set_capacity
 

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...
 

Detailed Description

This is extention of Protocol_local.

We support reading field metadata and field data attributes.

Constructor & Destructor Documentation

◆ Protocol_local_v2()

Protocol_local_v2::Protocol_local_v2 ( THD thd,
Statement_handle execute_statement 
)

◆ ~Protocol_local_v2()

Protocol_local_v2::~Protocol_local_v2 ( )
inlineoverride

Member Function Documentation

◆ abort_row()

void Protocol_local_v2::abort_row ( )
inlineoverridevirtual

Implements Protocol.

◆ add_row_to_result_set()

void Protocol_local_v2::add_row_to_result_set ( )
private

◆ allocate_type()

template<typename T , typename V >
bool Protocol_local_v2::allocate_type ( V *  value)
private

◆ clear_resultset_mem_root()

void Protocol_local_v2::clear_resultset_mem_root ( )

Clear MEM_ROOT and related members.

◆ connection_alive()

bool Protocol_local_v2::connection_alive ( ) const
overridevirtual

Checks if the protocol's connection with the client is still alive.

It should always return true unless the protocol closed the connection.

Return values
trueif the connection is still alive
falseotherwise

Implements Protocol.

◆ connection_type()

enum enum_vio_type Protocol_local_v2::connection_type ( ) const
inlineoverrideprotectedvirtual

Implements Protocol.

◆ end_partial_result_set()

void Protocol_local_v2::end_partial_result_set ( )
overridevirtual

Implements Protocol.

◆ end_result_metadata()

bool Protocol_local_v2::end_result_metadata ( )
overridevirtual

Signals the client that the metadata sending is done.

Clears the server after sending the metadata.

Return values
falseOk
trueAn error occurred

Implements Protocol.

◆ end_row()

bool Protocol_local_v2::end_row ( )
overridevirtual

Add the current row to the result set.

Implements Protocol.

◆ flush()

bool Protocol_local_v2::flush ( )
inlineoverridevirtual

Used for the classic protocol.

Makes the protocol send the messages/data to the client.

Return values
falseThe flush was successful.
trueAn error occurred.

Implements Protocol.

◆ get_client_capabilities()

ulong Protocol_local_v2::get_client_capabilities ( )
overridevirtual

Returns the client capabilities stored on the protocol.

The available capabilities are defined in mysql_com.h

Implements Protocol.

◆ get_command()

int Protocol_local_v2::get_command ( COM_DATA com_data,
enum_server_command cmd 
)
inlineoverridevirtual

Reads the command from the protocol and creates a command.

Parameters
com_dataout parameter
cmdout parameter
Returns
-1 fatal protocol error 0 ok 1 non-fatal protocol or parsing error

Implements Protocol.

◆ get_compression()

bool Protocol_local_v2::get_compression ( )
overridevirtual

Returns if the protocol is compressed or not.

Return values
falseNot compressed
trueCompressed

Implements Protocol.

◆ get_compression_algorithm()

char * Protocol_local_v2::get_compression_algorithm ( )
overridevirtual

Returns compression algorithm name.

Return values
stringcompression method name
NULLif no compression is enabled

Implements Protocol.

◆ get_compression_level()

uint Protocol_local_v2::get_compression_level ( )
overridevirtual

Returns compression level.

Returns
compression level

Implements Protocol.

◆ get_current_column_number()

uint Protocol_local_v2::get_current_column_number ( )
inlineprotected

◆ get_result_set_capacity()

size_t Protocol_local_v2::get_result_set_capacity ( )
inline

Get the capacity in bytes allowed for caching results.

◆ get_rw_status()

uint Protocol_local_v2::get_rw_status ( )
overridevirtual

Returns the read/writing status.

Return values
1Read
2Write
0Other(Idle, Killed)

Implements Protocol.

◆ has_client_capability()

bool Protocol_local_v2::has_client_capability ( unsigned long  client_capability)
overridevirtual

Checks if the client capabilities include the one specified as parameter.

Return values
trueif it includes the specified capability
falseotherwise

Implements Protocol.

◆ read_packet()

int Protocol_local_v2::read_packet ( )
overridevirtual

Read packet from client.

Return values
-1fatal error
0ok
1non-fatal error

Implements Protocol.

◆ send_eof()

bool Protocol_local_v2::send_eof ( uint  server_status,
uint  statement_warn_count 
)
overrideprotectedvirtual

Send eof message to the client.

Parameters
server_statusThe server status
statement_warn_countTotal number of warnings
Return values
falseThe message was successfully sent
trueAn error occurred and the messages wasn't sent properly

Implements Protocol.

◆ send_error()

bool Protocol_local_v2::send_error ( uint  sql_errno,
const char *  err_msg,
const char *  sqlstate 
)
overrideprotectedvirtual

Called at the end of a result set.

Append a complete result set to the list.

Don't send anything to the client, but instead finish building of the result set at hand. Called to send an error to the client at the end of a statement.

Implements Protocol.

◆ send_field_metadata()

bool Protocol_local_v2::send_field_metadata ( Send_field field,
const CHARSET_INFO charset 
)
overridevirtual

Sends field metadata.

Parameters
fieldField metadata to be send to the client
charsetField'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
Return values
falseThe metadata was successfully sent
trueAn error occurred

Implements Protocol.

◆ send_ok()

bool Protocol_local_v2::send_ok ( uint  server_status,
uint  statement_warn_count,
ulonglong  affected_rows,
ulonglong  last_insert_id,
const char *  message 
)
overrideprotectedvirtual

Called for statements that don't have a result set, at statement end.

Implements Protocol.

◆ send_parameters()

bool Protocol_local_v2::send_parameters ( List< Item_param > *  parameters,
bool  is_sql_prepare 
)
inlineoverridevirtual

Sends the OUT-parameters to the client.

Parameters
parametersList of PS/SP parameters (both input and output).
is_sql_prepareUsed for the legacy protocol. If we're dealing with sql prepare then text protocol will be used.
Returns
Error status.
Return values
falseSuccess.
trueError.

Implements Protocol.

◆ set_result_set_capacity()

void Protocol_local_v2::set_result_set_capacity ( size_t  capacity)
inline

Set the capacity in bytes allowed for caching results.

Parameters
capacitycapacity of the result set

◆ shutdown()

int Protocol_local_v2::shutdown ( bool  server_shutdown = false)
overridevirtual

Thread is being shut down, disconnect and free resources.

Parameters
server_shutdownIf false then this is normal thread shutdown. If true then the server is shutting down.

Implements Protocol.

◆ start_result_metadata()

bool Protocol_local_v2::start_result_metadata ( uint  num_cols,
uint  flags,
const CHARSET_INFO resultcs 
)
overridevirtual

Prepares the server for metadata sending.

Notifies the client that the metadata sending will start.

Parameters
num_colsNumber of columns that will be sent
flagsFlags to alter the metadata sending Can be any of the following: SEND_NUM_ROWS, SEND_DEFAULTS, SEND_EOF
resultcsCharset to convert to
Return values
falseOk
trueAn error occurred

Implements Protocol.

◆ start_row()

void Protocol_local_v2::start_row ( )
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

See also
store_column().

Implements Protocol.

◆ store_date()

bool Protocol_local_v2::store_date ( const MYSQL_TIME time)
overrideprotectedvirtual

Implements Protocol.

◆ store_datetime()

bool Protocol_local_v2::store_datetime ( const MYSQL_TIME time,
uint  precision 
)
overrideprotectedvirtual

Implements Protocol.

◆ store_decimal()

bool Protocol_local_v2::store_decimal ( const my_decimal value,
uint  prec,
uint  dec 
)
overrideprotectedvirtual

Implements Protocol.

◆ store_double()

bool Protocol_local_v2::store_double ( double  value,
uint32  decimals,
uint32  zerofill 
)
overrideprotectedvirtual

Implements Protocol.

◆ store_field()

bool Protocol_local_v2::store_field ( const Field field)
overrideprotectedvirtual

Implements Protocol.

◆ store_float()

bool Protocol_local_v2::store_float ( float  value,
uint32  decimals,
uint32  zerofill 
)
overrideprotectedvirtual

Implements Protocol.

◆ store_floating_type()

bool Protocol_local_v2::store_floating_type ( double  value)
private

◆ store_long()

bool Protocol_local_v2::store_long ( longlong  from,
uint32   
)
overrideprotectedvirtual

Implements Protocol.

◆ store_longlong() [1/2]

bool Protocol_local_v2::store_longlong ( longlong  from,
bool  unsigned_flag,
uint32   
)
overrideprotectedvirtual

Implements Protocol.

◆ store_longlong() [2/2]

bool Protocol_local_v2::store_longlong ( longlong  value)
private

◆ store_null()

bool Protocol_local_v2::store_null ( )
overrideprotectedvirtual

Add a NULL column to the current row.

Implements Protocol.

◆ store_ps_status()

bool Protocol_local_v2::store_ps_status ( ulong  stmt_id,
uint  column_count,
uint  param_count,
ulong  cond_count 
)
inlineoverridevirtual

Sends prepared statement's id and metadata to the client after prepare.

Parameters
stmt_idStatement id.
column_countNumber of columns.
param_countNumber of parameters.
cond_countNumber of conditions raised by the current statement.
Returns
Error status.
Return values
falseThe send was successful.
trueAn error occurred.

Implements Protocol.

◆ store_short()

bool Protocol_local_v2::store_short ( longlong  from,
uint32   
)
overrideprotectedvirtual

Implements Protocol.

◆ store_string() [1/2]

bool Protocol_local_v2::store_string ( const char *  from,
size_t  length,
const CHARSET_INFO cs 
)
overrideprotectedvirtual

Convert to cs_results and store a string.

Implements Protocol.

◆ store_string() [2/2]

bool Protocol_local_v2::store_string ( const char *  str,
size_t  length,
const CHARSET_INFO src_cs,
const CHARSET_INFO dst_cs 
)
private

Store a string value in a result set column, optionally having converted it to character_set_results.

◆ store_temporal()

bool Protocol_local_v2::store_temporal ( const MYSQL_TIME time)
private

◆ store_time()

bool Protocol_local_v2::store_time ( const MYSQL_TIME time,
uint  precision 
)
overrideprotectedvirtual

Implements Protocol.

◆ store_tiny()

bool Protocol_local_v2::store_tiny ( longlong  from,
uint32   
)
overrideprotectedvirtual

Implements Protocol.

◆ type()

enum enum_protocol_type Protocol_local_v2::type ( ) const
inlineoverrideprotectedvirtual

Implements Protocol.

Member Data Documentation

◆ m_column_count

size_t Protocol_local_v2::m_column_count
private

◆ m_current_column

value_t* Protocol_local_v2::m_current_column
private

◆ m_current_metadata_column

Column_metadata* Protocol_local_v2::m_current_metadata_column
private

◆ m_current_row

value_t* Protocol_local_v2::m_current_row
private

◆ m_current_row_index

uint Protocol_local_v2::m_current_row_index = 0
private

◆ m_data_rows

List<Row<value_t> >* Protocol_local_v2::m_data_rows
private

◆ m_execute_statement

Statement_handle* Protocol_local_v2::m_execute_statement
private

◆ m_fields

Row<Column_metadata>* Protocol_local_v2::m_fields
private

◆ m_metadata_row

Column_metadata* Protocol_local_v2::m_metadata_row
private

◆ m_result_set

Result_set* Protocol_local_v2::m_result_set = nullptr
private

◆ m_result_set_capacity

Result_set_capacity Protocol_local_v2::m_result_set_capacity
private

◆ m_result_set_mem_root

MEM_ROOT Protocol_local_v2::m_result_set_mem_root
private

◆ m_send_metadata

bool Protocol_local_v2::m_send_metadata
private

◆ m_thd

THD* Protocol_local_v2::m_thd
private

The documentation for this class was generated from the following files: