My Project
|
Public Types | |
enum | flag_values { IS_IN_USE = 1, IS_SQL_PREPARE = 2 } |
Public Member Functions | |
Prepared_statement (THD *thd_arg) | |
virtual | ~Prepared_statement () |
void | setup_set_params () |
virtual Query_arena::Type | type () const |
virtual void | cleanup_stmt () |
bool | set_name (LEX_STRING *name) |
void | close_cursor () |
bool | is_in_use () |
bool | is_sql_prepare () const |
void | set_sql_prepare () |
bool | prepare (const char *packet, uint packet_length) |
bool | execute_loop (String *expanded_query, bool open_cursor, uchar *packet_arg, uchar *packet_end_arg) |
bool | execute_server_runnable (Server_runnable *server_runnable) |
void | deallocate () |
Public Attributes | |
THD * | thd |
Select_fetch_protocol_binary | result |
Item_param ** | param_array |
Server_side_cursor * | cursor |
uint | param_count |
uint | last_errno |
uint | flags |
char | last_error [MYSQL_ERRMSG_SIZE] |
bool(* | set_params )(Prepared_statement *st, uchar *data, uchar *data_end, uchar *read_pos, String *expanded_query) |
bool(* | set_params_from_vars )(Prepared_statement *stmt, List< LEX_STRING > &varnames, String *expanded_query) |
Prepared_statement: a statement that can contain placeholders.
Prepared_statement::~Prepared_statement | ( | ) | [virtual] |
Destroy this prepared statement, cleaning up all used memory and resources.
This is called from ::deallocate() to handle COM_STMT_CLOSE and DEALLOCATE PREPARE or when THD ends and all prepared statements are freed.
void Prepared_statement::deallocate | ( | ) |
Common part of DEALLOCATE PREPARE and mysqld_stmt_close.
bool Prepared_statement::execute_loop | ( | String * | expanded_query, |
bool | open_cursor, | ||
uchar * | packet, | ||
uchar * | packet_end | ||
) |
Execute a prepared statement. Re-prepare it a limited number of times if necessary.
Try to execute a prepared statement. If there is a metadata validation error, prepare a new copy of the prepared statement, swap the old and the new statements, and try again. If there is a validation error again, repeat the above, but perform no more than MAX_REPREPARE_ATTEMPTS.
TRUE | either MAX_REPREPARE_ATTEMPTS has been reached, or some general error |
FALSE | successfully executed the statement, perhaps after having reprepared it a few times. |
bool Prepared_statement::prepare | ( | const char * | packet, |
uint | packet_len | ||
) |
Parse statement text, validate the statement, and prepare it for execution.
You should not change global THD state in this function, if at all possible: it may be called from any context, e.g. when executing a COM_* command, and SQLCOM_* command, or a stored procedure.
packet | statement text |
packet_len |