MySQL 8.4.2
Source Code Documentation
|
A service that provides the API to get information about statement metadata including the number of the parameters in a prepared statement and their metatdata. More...
#include <mysql_statement_service.h>
Public Attributes | |
mysql_service_status_t(* | param_count )(my_h_statement statement, uint32_t *parameter_count) |
Get the number of parameters in the prepared statement. More... | |
mysql_service_status_t(* | param_metadata )(my_h_statement statement, uint32_t index, const char *metadata, void *data) |
Get the metadata of a parameter in a prepared statement. More... | |
A service that provides the API to get information about statement metadata including the number of the parameters in a prepared statement and their metatdata.
For prepared statement, to get the number of parameters uint64_t num_parameters; SERVICE_PLACEHOLDER(mysql_stmt_metadata)->param_count(statement, &num_parameters)
mysql_service_status_t(* s_mysql_mysql_stmt_metadata::param_count) (my_h_statement statement, uint32_t *parameter_count) |
Get the number of parameters in the prepared statement.
[in] | statement | A handle to the statement |
[out] | parameter_count | The number of parameters |
false | success |
true | failure |
mysql_service_status_t(* s_mysql_mysql_stmt_metadata::param_metadata) (my_h_statement statement, uint32_t index, const char *metadata, void *data) |
Get the metadata of a parameter in a prepared statement.
The metadata specifies whether the parameter can be null, the type of the parameter, whether the value is signed.
For example, in this query, "SELECT * FROM table WHERE col = ?", we need to know the parameter specified by '?' is null or not, its type, and if it is integer, whether it is signed. MySQL will provide this information and this function is to get these info.
auto is_nullable = bool{}; if (SERVICE_PLACEHOLDER(mysql_stmt_metadata) ->param_metadata(statement, index, "null_bit", &is_nullable)) return {}; auto sql_type = Sql_type{}; if (SERVICE_PLACEHOLDER(mysql_stmt_metadata) ->param_metadata(statement, index, "type", &sql_type)) return {}; auto is_unsigned = bool{}; if (SERVICE_PLACEHOLDER(mysql_stmt_metadata) ->param_metadata(statement, index, "is_unsigned", &is_unsigned)) return {};
[in] | statement | A handle to the statement |
[in] | index | 0-based index of the parameter |
[in] | metadata | The metadata argument is the attribute that you want to get |
The following attributes are supported:
[out] | data | The data argument is the value for the member |
false | success |
true | failure |