#include <sql_prepare.h>
◆ Ed_connection() [1/2]
Ed_connection::Ed_connection |
( |
THD * |
thd | ) |
|
Construct a new "execute direct" connection.
Create 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.
- Precondition
- thd must have no open tables while the connection is used. However, Ed_connection works okay in LOCK TABLES mode. Other properties of THD, such as the current warning information, errors, etc. do not matter and are preserved by Ed_connection. One thread may have many Ed_connections created for it.
◆ ~Ed_connection()
Ed_connection::~Ed_connection |
( |
| ) |
|
|
inline |
◆ Ed_connection() [2/2]
◆ add_result_set()
void Ed_connection::add_result_set |
( |
Ed_result_set * |
ed_result_set | ) |
|
|
private |
A helper method that is called only during execution.
Although Ed_connection doesn't support multi-statements, a statement may generate many result sets. All subsequent result sets are appended to the end.
- Precondition
- This is called only by Protocol_local.
◆ execute_direct() [1/2]
bool Ed_connection::execute_direct |
( |
LEX_STRING |
sql_text | ) |
|
Execute one SQL statement.
A simple wrapper that uses a helper class to execute SQL statements.
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:
- success, no result set rows. In this case get_field_count() returns 0. This happens after execution of INSERT, UPDATE, DELETE, DROP and similar statements. Some other methods, such as get_affected_rows() can be used to retrieve additional result information.
- success, there are some result set rows (maybe 0). E.g. happens after SELECT. In this case get_field_count() returns the number of columns in a result set and store_result() can be used to retrieve a result set..
- an error, methods to retrieve error information can be used.
- Returns
- execution status
- Return values
-
false | success, use get_field_count() to determine what to do next. |
true | error, use get_last_error() to see the error number. |
◆ execute_direct() [2/2]
Same as the previous, but takes an instance of Server_runnable instead of SQL statement text.
Execute a fragment of server functionality without an effect on thd, and store results in memory.
- Returns
- execution status
- Return values
-
false | success, use get_field_count() if your code fragment is supposed to return a result set |
true | failure |
Conventions:
- the code fragment must finish with OK, EOF or ERROR.
- the code fragment doesn't have to close thread tables, free memory, commit statement transaction or do any other cleanup that is normally done in the end of dispatch_command().
- Parameters
-
server_runnable | A code fragment to execute. |
◆ free_old_result()
void Ed_connection::free_old_result |
( |
| ) |
|
|
private |
Free all result sets of the previous statement, if any, and reset warnings and errors.
Called before execution of the next query.
◆ get_last_errno()
unsigned int Ed_connection::get_last_errno |
( |
| ) |
const |
|
inline |
◆ get_last_error()
const char * Ed_connection::get_last_error |
( |
| ) |
const |
|
inline |
The following three 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.
◆ get_result_sets()
◆ operator=()
◆ Protocol_local
◆ m_current_rset
◆ m_diagnostics_area
◆ m_rsets
◆ m_thd
THD* Ed_connection::m_thd |
|
private |
Execute direct interface does not support multi-statements, only multi-results.
So we never have a situation when we have a mix of result sets and OK or error packets. We either have a single result set, a single error, or a single OK, or we have a series of result sets, followed by an OK or error.
The documentation for this class was generated from the following files: