MySQL 9.1.0
Source Code Documentation
|
#include <assert.h>
#include <stddef.h>
#include <sys/types.h>
#include "lex_string.h"
#include "my_alloc.h"
#include "my_command.h"
#include "my_dbug.h"
#include "my_inttypes.h"
#include "my_psi_config.h"
#include "mysql/components/services/bits/psi_statement_bits.h"
#include "mysql_com.h"
#include "sql/sql_class.h"
Go to the source code of this file.
Classes | |
class | Reprepare_observer |
An interface that is used to take an action when the locking module notices that a table version has changed since the last execution. More... | |
class | Prepared_statement |
Prepared_statement: a statement that can contain placeholders. More... | |
Functions | |
void | rewrite_query (THD *thd) |
Rewrite the current query (to obfuscate passwords etc.). More... | |
void | log_execute_line (THD *thd) |
Unless we're doing dynamic SQL, write the current query to the general query log if it's open. More... | |
bool | ask_to_reprepare (THD *thd) |
Requests for repreparation of statement. More... | |
bool | mysql_stmt_precheck (THD *thd, const COM_DATA *com_data, enum enum_server_command cmd, Prepared_statement **stmt) |
Searches for the statement with the specified id and validates it. More... | |
void | mysqld_stmt_prepare (THD *thd, const char *query, uint length, Prepared_statement *stmt) |
COM_STMT_PREPARE handler. More... | |
void | mysqld_stmt_execute (THD *thd, Prepared_statement *stmt, bool has_new_types, ulong execute_flags, PS_PARAM *parameters) |
COM_STMT_EXECUTE handler: execute a previously prepared statement. More... | |
void | mysqld_stmt_close (THD *thd, Prepared_statement *stmt) |
Delete a prepared statement from memory. More... | |
void | mysql_sql_stmt_prepare (THD *thd) |
SQLCOM_PREPARE implementation. More... | |
void | mysql_sql_stmt_execute (THD *thd) |
SQLCOM_EXECUTE implementation. More... | |
void | mysql_sql_stmt_close (THD *thd) |
SQLCOM_DEALLOCATE implementation. More... | |
void | mysqld_stmt_fetch (THD *thd, Prepared_statement *stmt, ulong num_rows) |
COM_STMT_FETCH handler: fetches requested amount of rows from cursor. More... | |
void | mysqld_stmt_reset (THD *thd, Prepared_statement *stmt) |
Reset a prepared statement in case there was a recoverable error. More... | |
void | mysql_stmt_get_longdata (THD *thd, Prepared_statement *stmt, uint param_number, uchar *longdata, ulong length) |
Handle long data in pieces from client. More... | |
bool | select_like_stmt_cmd_test (THD *thd, class Sql_cmd_dml *cmd, ulong setup_tables_done_option) |
void | reset_stmt_parameters (Prepared_statement *stmt) |
Clears parameters from data left from previous execution or long data. More... | |
bool ask_to_reprepare | ( | THD * | thd | ) |
Requests for repreparation of statement.
void log_execute_line | ( | THD * | thd | ) |
Unless we're doing dynamic SQL, write the current query to the general query log if it's open.
If we have a rewritten version of the query, use that instead of the "raw" one.
Side-effect: query may be written to general log if it's open.
thd | thread handle |
void mysql_sql_stmt_close | ( | THD * | thd | ) |
SQLCOM_DEALLOCATE implementation.
Close an SQL prepared statement. As this can be called from Dynamic SQL, we should be careful to not close a statement that is currently being executed.
OK packet is sent in case of success, otherwise an error message is set in THD.
void mysql_sql_stmt_execute | ( | THD * | thd | ) |
SQLCOM_EXECUTE implementation.
Execute prepared statement using parameter values from lex->prepared_stmt_params and send result to the client using text protocol. This is called from mysql_execute_command and therefore should behave like an ordinary query (e.g. not change global THD data, such as warning count, server status, etc). This function uses text protocol to send a possible result set.
In case of success, OK (or result set) packet is sent to the client, otherwise an error is set in THD.
thd | thread handle |
void mysql_sql_stmt_prepare | ( | THD * | thd | ) |
SQLCOM_PREPARE implementation.
Prepare an SQL prepared statement. This is called from mysql_execute_command and should therefore behave like an ordinary query (e.g. should not reset any global THD data).
In case of success, OK packet is sent to the client, otherwise an error message is set in THD.
thd | thread handle |
void mysql_stmt_get_longdata | ( | THD * | thd, |
Prepared_statement * | stmt, | ||
uint | param_number, | ||
uchar * | str, | ||
ulong | length | ||
) |
Handle long data in pieces from client.
Get a part of a long data. To make the protocol efficient, we are not sending any return packets here. If something goes wrong, then we will send the error on 'execute' We assume that the client takes care of checking that all parts are sent to the server. (No checking that we get a 'end of column' in the server is performed).
thd | Thread handle |
stmt | Pointer to Prepared_statement |
param_number | Number of parameters |
str | String to append |
length | Length of string (including end \0) |
bool mysql_stmt_precheck | ( | THD * | thd, |
const COM_DATA * | com_data, | ||
enum enum_server_command | cmd, | ||
Prepared_statement ** | stmt | ||
) |
Searches for the statement with the specified id and validates it.
thd | [in] thread handle |
com_data | [in] command data |
cmd | [in] command type to be executed |
stmt | [out] pointer to Prepared_statement to store it if found |
void mysqld_stmt_close | ( | THD * | thd, |
Prepared_statement * | stmt | ||
) |
Delete a prepared statement from memory.
void mysqld_stmt_execute | ( | THD * | thd, |
Prepared_statement * | stmt, | ||
bool | has_new_types, | ||
ulong | execute_flags, | ||
PS_PARAM * | parameters | ||
) |
COM_STMT_EXECUTE handler: execute a previously prepared statement.
If there are any parameters, then replace parameter markers with the data supplied from the client, and then execute the statement. This function uses binary protocol to send a possible result set to the client.
In case of success OK packet or a result set is sent to the client, otherwise an error message is set in THD.
thd | current thread |
stmt | prepared statement |
has_new_types | true if parsed parameters have data types defined, otherwise types from last execution will be used |
execute_flags | flag used to decide if a cursor should be used |
parameters | prepared statement's parsed parameters |
void mysqld_stmt_fetch | ( | THD * | thd, |
Prepared_statement * | stmt, | ||
ulong | num_rows | ||
) |
COM_STMT_FETCH handler: fetches requested amount of rows from cursor.
thd | Thread handle. |
stmt | Pointer to the prepared statement. |
num_rows | Number of rows to fetch. |
void mysqld_stmt_prepare | ( | THD * | thd, |
const char * | query, | ||
uint | length, | ||
Prepared_statement * | stmt | ||
) |
COM_STMT_PREPARE handler.
Given a query string with parameter markers, create a prepared statement from it and send PS info back to the client.
If parameter markers are found in the query, then store the information using Item_param along with maintaining a list in lex->param_array, so that a fast and direct retrieval can be made without going through all field items.
In case of success a new statement id and metadata is sent to the client, otherwise an error message is set in THD.
thd | thread handle |
query | query to be prepared |
length | query string length, including ignored trailing NULL or quote char. |
stmt | Prepared_statement to be used for preparation. |
void mysqld_stmt_reset | ( | THD * | thd, |
Prepared_statement * | stmt | ||
) |
Reset a prepared statement in case there was a recoverable error.
This function resets statement to the state it was right after prepare. It can be used to:
thd | Thread handle |
stmt | Pointer to the Prepared_statement |
void reset_stmt_parameters | ( | Prepared_statement * | stmt | ) |
Clears parameters from data left from previous execution or long data.
stmt | prepared statement for which parameters should be reset |
void rewrite_query | ( | THD * | thd | ) |
Rewrite the current query (to obfuscate passwords etc.).
Side-effect: thd->rewritten_query() may be populated with a rewritten query. If the query is not of a rewritable type, thd->rewritten_query() will be empty.
thd | thread handle |
bool select_like_stmt_cmd_test | ( | THD * | thd, |
class Sql_cmd_dml * | cmd, | ||
ulong | setup_tables_done_option | ||
) |