My Project
|
Public Member Functions | |
Ed_connection (THD *thd) | |
bool | execute_direct (LEX_STRING sql_text) |
bool | execute_direct (Server_runnable *server_runnable) |
ulong | get_field_count () const |
ulonglong | get_affected_rows () const |
ulonglong | get_last_insert_id () const |
ulong | get_warn_count () const |
const char * | get_last_error () const |
unsigned int | get_last_errno () const |
const char * | get_last_sqlstate () const |
Ed_result_set * | use_result_set () |
Ed_result_set * | store_result_set () |
bool | has_next_result () const |
bool | move_to_next_result () |
Friends | |
class | Protocol_local |
Ed_connection::Ed_connection | ( | THD * | thd | ) |
Construct a new "execute direct" connection.
The connection can be used to execute SQL statements. If the connection failed to initialize, the error will be returned on the attempt to execute a statement.
Create a new "execute direct" connection.
bool Ed_connection::execute_direct | ( | LEX_STRING | sql_text | ) |
Execute one SQL statement.
Until this method is executed, no other methods of Ed_connection can be used. Life cycle of Ed_connection is:
Initialized -> a statement has been executed -> look at result, move to next result -> look at result, move to next result -> ... moved beyond the last result == Initialized.
This method can be called repeatedly. Once it's invoked, results of the previous execution are lost.
A result of execute_direct() can be either:
FALSE | success, use get_field_count() to determine what to do next. |
TRUE | error, use get_last_error() to see the error number. |
A simple wrapper that uses a helper class to execute SQL statements.
bool Ed_connection::execute_direct | ( | Server_runnable * | server_runnable | ) |
Same as the previous, but takes an instance of Server_runnable instead of SQL statement text.
FALSE | success, use get_field_count() if your code fragment is supposed to return a result set |
TRUE | failure |
Execute a fragment of server functionality without an effect on thd, and store results in memory.
Conventions:
server_runnable | A code fragment to execute. |
ulonglong Ed_connection::get_affected_rows | ( | ) | const [inline] |
Get the number of affected (deleted, updated) rows for the current statement. Can be used for statements with get_field_count() == 0.
ulong Ed_connection::get_field_count | ( | ) | const [inline] |
Get the number of result set fields.
This method is valid only if we have a result: execute_direct() has been called. Otherwise the returned value is undefined.
const char* Ed_connection::get_last_error | ( | ) | const [inline] |
The following members are only valid if execute_direct() or move_to_next_result() returned an error. They never fail, but if they are called when there is no result, or no error, the result is not defined.
ulonglong Ed_connection::get_last_insert_id | ( | ) | const [inline] |
Get the last insert id, if any.
ulong Ed_connection::get_warn_count | ( | ) | const [inline] |
Get the total number of warnings for the last executed statement. Note, that there is only one warning list even if a statement returns multiple results.
bool Ed_connection::has_next_result | ( | ) | const [inline] |
If the query returns multiple results, this method can be checked if there is another result beyond the next one. Never fails.
bool Ed_connection::move_to_next_result | ( | ) | [inline] |
Only valid to call if has_next_result() returned true. Otherwise the result is undefined.
Provided get_field_count() is not 0, this never fails. You must free the returned result set. This can be called only once after execute_direct(). Should be used when you would like to get the results and destroy the connection.
Release ownership of the current result set to the client.
Since we use a simple linked list for result sets, this method uses a linear search of the previous result set to exclude the released instance from the list.
XXX: This has never been tested with more than one result set!
Ed_result_set* Ed_connection::use_result_set | ( | ) | [inline] |
Provided get_field_count() is not 0, this never fails. You don't need to free the result set, this is done automatically when you advance to the next result set or destroy the connection. Not returning const because of List iterator not accepting Should be used when you would like Ed_connection to manage result set memory for you.