My Project
|
Public Types | |
enum | { SEND_NUM_ROWS = 1, SEND_DEFAULTS = 2, SEND_EOF = 4 } |
enum | enum_protocol_type { PROTOCOL_TEXT = 0, PROTOCOL_BINARY = 1, PROTOCOL_LOCAL = 2 } |
Public Member Functions | |
Protocol (THD *thd_arg) | |
void | init (THD *thd_arg) |
virtual bool | send_result_set_metadata (List< Item > *list, uint flags) |
bool | send_result_set_row (List< Item > *row_items) |
bool | store (I_List< i_string > *str_list) |
bool | store (const char *from, const CHARSET_INFO *cs) |
String * | storage_packet () |
void | free () |
virtual bool | write () |
bool | store (int from) |
bool | store (uint32 from) |
bool | store (longlong from) |
bool | store (ulonglong from) |
bool | store (String *str) |
virtual bool | prepare_for_send (uint num_columns) |
virtual bool | flush () |
virtual void | end_partial_result_set (THD *thd) |
virtual void | prepare_for_resend ()=0 |
virtual bool | store_null ()=0 |
virtual bool | store_tiny (longlong from)=0 |
virtual bool | store_short (longlong from)=0 |
virtual bool | store_long (longlong from)=0 |
virtual bool | store_longlong (longlong from, bool unsigned_flag)=0 |
virtual bool | store_decimal (const my_decimal *)=0 |
virtual bool | store (const char *from, size_t length, const CHARSET_INFO *cs)=0 |
virtual bool | store (const char *from, size_t length, const CHARSET_INFO *fromcs, const CHARSET_INFO *tocs)=0 |
virtual bool | store (float from, uint32 decimals, String *buffer)=0 |
virtual bool | store (double from, uint32 decimals, String *buffer)=0 |
virtual bool | store (MYSQL_TIME *time, uint precision)=0 |
virtual bool | store_date (MYSQL_TIME *time)=0 |
virtual bool | store_time (MYSQL_TIME *time, uint precision)=0 |
virtual bool | store (Field *field)=0 |
virtual bool | send_out_parameters (List< Item_param > *sp_params)=0 |
void | remove_last_row () |
virtual enum enum_protocol_type | type ()=0 |
void | end_statement () |
Protected Member Functions | |
bool | net_store_data (const uchar *from, size_t length) |
bool | net_store_data (const uchar *from, size_t length, const CHARSET_INFO *fromcs, const CHARSET_INFO *tocs) |
bool | store_string_aux (const char *from, size_t length, const CHARSET_INFO *fromcs, const CHARSET_INFO *tocs) |
virtual bool | send_ok (uint server_status, uint statement_warn_count, ulonglong affected_rows, ulonglong last_insert_id, const char *message) |
virtual bool | send_eof (uint server_status, uint statement_warn_count) |
virtual bool | send_error (uint sql_errno, const char *err_msg, const char *sql_state) |
Protected Attributes | |
THD * | thd |
String * | packet |
String * | convert |
uint | field_pos |
enum enum_field_types * | field_types |
uint | field_count |
void Protocol::end_partial_result_set | ( | THD * | thd_arg | ) | [virtual] |
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.
void Protocol::end_statement | ( | ) |
Send the status of the current statement execution over network.
thd | in fact, carries two parameters, NET for the transport and Diagnostics_area as the source of status information. |
In MySQL, there are two types of SQL statements: those that return a result set and those that return status information only.
If a statement returns a result set, it consists of 3 parts:
Once the client has seen the meta-data information, it always expects an EOF or ERROR to terminate the result set. If ERROR is received, the result set rows are normally discarded (this is up to the client implementation, libmysql at least does discard them). EOF, on the contrary, means "successfully evaluated the entire result set". Since we don't know how many rows belong to a result set until it's evaluated, EOF/ERROR is the indicator of the end of the row stream. Note, that we can not buffer result set rows on the server -- there may be an arbitrary number of rows. But we do buffer the last packet (EOF/ERROR) in the Diagnostics_area and delay sending it till the very end of execution (here), to be able to change EOF to an ERROR if commit failed or some other error occurred during the last cleanup steps taken after execution.
A statement that does not return a result set doesn't send result set meta-data either. Instead it returns one of:
bool Protocol::send_eof | ( | uint | server_status, |
uint | statement_warn_count | ||
) | [protected, virtual] |
A default implementation of "EOF" packet response to the client.
Binary and text protocol do not differ in their EOF packet format.
Reimplemented in Protocol_local.
bool Protocol::send_error | ( | uint | sql_errno, |
const char * | err_msg, | ||
const char * | sql_state | ||
) | [protected, virtual] |
A default implementation of "ERROR" packet response to the client.
Binary and text protocol do not differ in ERROR packet format.
Reimplemented in Protocol_local.
bool Protocol::send_ok | ( | uint | server_status, |
uint | statement_warn_count, | ||
ulonglong | affected_rows, | ||
ulonglong | last_insert_id, | ||
const char * | message | ||
) | [protected, virtual] |
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.
Reimplemented in Protocol_local.
bool Protocol::send_result_set_metadata | ( | List< Item > * | list, |
uint | flags | ||
) | [virtual] |
Send name and type of result to client.
Sum fields has table name empty and field_name.
THD | Thread data object |
list | List of items to send to client |
flag | Bit mask with the following functions:
|
0 | ok |
1 | Error (Note that in this case the error is not sent to the client) |
Reimplemented in Protocol_local.
bool Protocol::send_result_set_row | ( | List< Item > * | row_items | ) |
Send one result set row.
row_items | a collection of column values for that row |
TRUE | Error. |
FALSE | Success. |
bool Protocol::store | ( | I_List< i_string > * | str_list | ) |
Send a set of strings as one long string with ',' in between.
bool Protocol::store | ( | const char * | from, |
const CHARSET_INFO * | cs | ||
) |
Send \0 end terminated string.
from | NullS or \0 terminated string |
0 | ok |
1 | error |
bool Protocol::store_string_aux | ( | const char * | from, |
size_t | length, | ||
const CHARSET_INFO * | fromcs, | ||
const CHARSET_INFO * | tocs | ||
) | [protected] |
Auxilary function to convert string to the given character set and store in network buffer.