MySQL 9.1.0
Source Code Documentation
Statement_handle Class Referenceabstract

Statement_handle is similar to Ed_connection. More...

#include <statement.h>

Inheritance diagram for Statement_handle:
[legend]

Public Member Functions

 Statement_handle (THD *thd, const char *query, size_t length)
 
bool is_error () const
 Check if error is reported. More...
 
LEX_CSTRING get_last_error ()
 Check if error is reported. More...
 
unsigned int get_last_errno () const
 Get the last mysql errno. More...
 
LEX_CSTRING get_mysql_state ()
 Get the mysql error state. More...
 
ulonglong warning_count () const
 Get number of warnings generated. More...
 
Warningget_warnings ()
 Get list of all warnings. More...
 
Result_setget_result_sets ()
 Get the next result sets generated while executing the statement. More...
 
Result_setget_current_result_set ()
 Get the current result set object. More...
 
void next_result_set ()
 Make the next result set the current result set. More...
 
virtual bool execute ()=0
 Execute the SQL command. More...
 
virtual bool is_prepared_statement ()=0
 Check if we are processing a prepared statement. More...
 
virtual bool is_executed_or_prepared ()=0
 Check if the statement has been executed or prepared. More...
 
void free_old_result ()
 Feel all the result collected so far, from query execution. More...
 
std::string_view get_query ()
 Get the query string being executed. More...
 
void set_capacity (size_t capacity)
 Set the capacity in bytes allowed for caching results. More...
 
size_t get_capacity ()
 Get the capacity in bytes allowed for caching results. More...
 
void set_use_thd_protocol (bool use_thd_protocol)
 Set thd protocol to enable result pass through. More...
 
bool is_using_thd_protocol () const
 Check if thd protocol is used. More...
 
void set_thd_protocol ()
 Set either Protocol_local_v2 when m_use_thd_protocol is not set or or classical protocol when m_use_thd_protocol is set to THD. More...
 
void reset_thd_protocol ()
 Reset THD protocol. More...
 
void set_expected_charset (const char *charset_name)
 Set the expected charset. More...
 
const char * get_expected_charset ()
 Get the expected charset. More...
 
size_t get_num_rows_per_fetch ()
 Get the num rows per fetch. More...
 
void set_num_rows_per_fetch (size_t num_rows_per_fetch)
 Set the num of rows to be retrieved per fetch. More...
 
virtual ~Statement_handle ()
 Destroy the Statement_handle object. More...
 

Protected Member Functions

void send_statement_status ()
 Send statement execution status after execute(). More...
 
void add_result_set (Result_set *result_set)
 
void set_result_set (Result_set *result_set)
 
void copy_warnings ()
 Copy the warnings generated for the query from the diagnostics area. More...
 
 Statement_handle (const Statement_handle &)=delete
 
 Statement_handle (Statement_handle &&)=delete
 
Statement_handleoperator= (const Statement_handle &)=delete
 
Statement_handleoperator= (Statement_handle &&)=delete
 

Protected Attributes

std::string m_query
 
MEM_ROOT m_warning_mem_root
 
Warningm_warnings
 
ulonglong m_warnings_count = 0
 
Diagnostics_aream_diagnostics_area
 
THDm_thd
 
Result_setm_result_sets
 
Result_setm_current_rset
 
bool m_use_thd_protocol = false
 
size_t m_num_rows_per_fetch = 1
 
CHARSET_INFOm_expected_charset
 
Protocol_local_v2 m_protocol
 
Protocolm_saved_protocol {nullptr}
 

Friends

class Protocol_local_v2
 

Detailed Description

Statement_handle is similar to Ed_connection.

Some of the limitations in Ed_connection is that,

  • It does not support reading result metadata
  • It does not support prepared statement, parameters and cursors.

Above limitation leads to implementation of this interface.

Statement_handle supports both execution of regular and prepared statement.

Note that we can get rid of Ed_connection implementation as we support more functionality with Statement_handle.

Constructor & Destructor Documentation

◆ Statement_handle() [1/3]

Statement_handle::Statement_handle ( THD thd,
const char *  query,
size_t  length 
)

◆ ~Statement_handle()

virtual Statement_handle::~Statement_handle ( )
inlinevirtual

Destroy the Statement_handle object.

◆ Statement_handle() [2/3]

Statement_handle::Statement_handle ( const Statement_handle )
protecteddelete

◆ Statement_handle() [3/3]

Statement_handle::Statement_handle ( Statement_handle &&  )
protecteddelete

Member Function Documentation

◆ add_result_set()

void Statement_handle::add_result_set ( Result_set result_set)
protected

◆ copy_warnings()

auto Statement_handle::copy_warnings ( )
protected

Copy the warnings generated for the query from the diagnostics area.

◆ execute()

virtual bool Statement_handle::execute ( )
pure virtual

Execute the SQL command.

This can be either Regular or Prepared statement.

Returns
true upon failure.
false upon success.

Implemented in Regular_statement_handle, and Prepared_statement_handle.

◆ free_old_result()

void Statement_handle::free_old_result ( )

Feel all the result collected so far, from query execution.

◆ get_capacity()

size_t Statement_handle::get_capacity ( )
inline

Get the capacity in bytes allowed for caching results.

Returns
size_t

◆ get_current_result_set()

Result_set * Statement_handle::get_current_result_set ( )
inline

Get the current result set object.

Returns
Result_set*

◆ get_expected_charset()

const char * Statement_handle::get_expected_charset ( )
inline

Get the expected charset.

Returns
const char* the expected charset name

◆ get_last_errno()

unsigned int Statement_handle::get_last_errno ( ) const
inline

Get the last mysql errno.

Returns
unsigned int

◆ get_last_error()

LEX_CSTRING Statement_handle::get_last_error ( )
inline

Check if error is reported.

Returns
true of error is reported.

◆ get_mysql_state()

LEX_CSTRING Statement_handle::get_mysql_state ( )
inline

Get the mysql error state.

Returns
const char*

◆ get_num_rows_per_fetch()

size_t Statement_handle::get_num_rows_per_fetch ( )
inline

Get the num rows per fetch.

Returns
size_t

◆ get_query()

std::string_view Statement_handle::get_query ( )
inline

Get the query string being executed.

Returns
std::string_view

◆ get_result_sets()

Result_set * Statement_handle::get_result_sets ( )
inline

Get the next result sets generated while executing the statement.

Returns
Result_set*

◆ get_warnings()

auto Statement_handle::get_warnings ( )

Get list of all warnings.

Returns
Warning*

◆ is_error()

bool Statement_handle::is_error ( ) const
inline

Check if error is reported.

Returns
true of error is reported.

◆ is_executed_or_prepared()

virtual bool Statement_handle::is_executed_or_prepared ( )
pure virtual

Check if the statement has been executed or prepared.

Returns
true upon executed or prepared
false otherwise

Implemented in Regular_statement_handle, and Prepared_statement_handle.

◆ is_prepared_statement()

virtual bool Statement_handle::is_prepared_statement ( )
pure virtual

Check if we are processing a prepared statement.

Returns
true upon failure.
false upon success.

Implemented in Regular_statement_handle, and Prepared_statement_handle.

◆ is_using_thd_protocol()

bool Statement_handle::is_using_thd_protocol ( ) const
inline

Check if thd protocol is used.

Returns
true if enabled.
false if not.

◆ next_result_set()

void Statement_handle::next_result_set ( )
inline

Make the next result set the current result set.

We do it once we have read the current result set.

◆ operator=() [1/2]

Statement_handle & Statement_handle::operator= ( const Statement_handle )
protecteddelete

◆ operator=() [2/2]

Statement_handle & Statement_handle::operator= ( Statement_handle &&  )
protecteddelete

◆ reset_thd_protocol()

void Statement_handle::reset_thd_protocol ( )

Reset THD protocol.

◆ send_statement_status()

void Statement_handle::send_statement_status ( )
protected

Send statement execution status after execute().

◆ set_capacity()

void Statement_handle::set_capacity ( size_t  capacity)
inline

Set the capacity in bytes allowed for caching results.

Parameters
capacityof the result set

◆ set_expected_charset()

void Statement_handle::set_expected_charset ( const char *  charset_name)
inline

Set the expected charset.

Parameters
charset_nameName of the charset

◆ set_num_rows_per_fetch()

void Statement_handle::set_num_rows_per_fetch ( size_t  num_rows_per_fetch)
inline

Set the num of rows to be retrieved per fetch.

Parameters
num_rows_per_fetchnumber of rows per fetch

◆ set_result_set()

void Statement_handle::set_result_set ( Result_set result_set)
protected

◆ set_thd_protocol()

void Statement_handle::set_thd_protocol ( )

Set either Protocol_local_v2 when m_use_thd_protocol is not set or or classical protocol when m_use_thd_protocol is set to THD.

◆ set_use_thd_protocol()

void Statement_handle::set_use_thd_protocol ( bool  use_thd_protocol)
inline

Set thd protocol to enable result pass through.

Parameters
use_thd_protocol- parameter that decides if THD protocol should be used

◆ warning_count()

ulonglong Statement_handle::warning_count ( ) const
inline

Get number of warnings generated.

Returns
ulonglong

Friends And Related Function Documentation

◆ Protocol_local_v2

friend class Protocol_local_v2
friend

Member Data Documentation

◆ m_current_rset

Result_set* Statement_handle::m_current_rset
protected

◆ m_diagnostics_area

Diagnostics_area* Statement_handle::m_diagnostics_area
protected

◆ m_expected_charset

CHARSET_INFO* Statement_handle::m_expected_charset
protected

◆ m_num_rows_per_fetch

size_t Statement_handle::m_num_rows_per_fetch = 1
protected

◆ m_protocol

Protocol_local_v2 Statement_handle::m_protocol
protected

◆ m_query

std::string Statement_handle::m_query
protected

◆ m_result_sets

Result_set* Statement_handle::m_result_sets
protected

◆ m_saved_protocol

Protocol* Statement_handle::m_saved_protocol {nullptr}
protected

◆ m_thd

THD* Statement_handle::m_thd
protected

◆ m_use_thd_protocol

bool Statement_handle::m_use_thd_protocol = false
protected

◆ m_warning_mem_root

MEM_ROOT Statement_handle::m_warning_mem_root
protected

◆ m_warnings

Warning* Statement_handle::m_warnings
protected

◆ m_warnings_count

ulonglong Statement_handle::m_warnings_count = 0
protected

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