MySQL 9.1.0
Source Code Documentation
s_mysql_mysql_stmt_factory Struct Reference

A service that provides the API to create, and deallocate a statement. More...

#include <mysql_statement_service.h>

Public Attributes

mysql_service_status_t(* init )(my_h_statement *statement)
 Construct a new statement object. More...
 
mysql_service_status_t(* close )(my_h_statement statement)
 Close and clean up resource related to a statement. More...
 

Detailed Description

A service that provides the API to create, and deallocate a statement.

Note
Users of the service can set the expected charset e.g SERVICE_PLACEHOLDER(mysql_stmt_attributes)->set("charset_name", "utf8mb4"); The service expects all the input strings to be in this charset and all the output strings from the service will be in this charset. The statement can be either a regular or a prepared statement.

Usage example for prepared statement: my_h_statement statement = nullptr; SERVICE_PLACEHOLDER(mysql_stmt_factory)->init(&statement);

SERVICE_PLACEHOLDER(mysql_stmt_attributes)->set("charset_name", "utf8mb4");

SERVICE_PLACEHOLDER(mysql_stmt_execute)->prepare("SELECT * FROM ?", statement);

uint32_t parameter_count; SERVICE_PLACEHOLDER(mysql_stmt_metadata)->param_count(statement, &parameter_count);

For first parameter SERVICE_PLACEHOLDER(mysql_stmt_bind)->bind_param(statement, 0, false, MYSQL_TYPE_LONG, false, 4, 1, nullptr, 0);

SERVICE_PLACEHOLDER(mysql_stmt_execute)->execute(statement)

my_h_row row = nullptr; SERVICE_PLACEHOLDER(mysql_stmt_result)->fetch(statement, &row); SERVICE_PLACEHOLDER(mysql_stmt_factory)->close(statement)

Usage example for regular statement: my_h_statement statement = nullptr; SERVICE_PLACEHOLDER(mysql_stmt_factory)->init(&statement);

SERVICE_PLACEHOLDER(mysql_stmt_attributes)->set("charset_name", "utf8mb4");

SERVICE_PLACEHOLDER(mysql_stmt_execute_direct)->execute("SELECT * FROM my_table", statement);

my_h_row row = nullptr; SERVICE_PLACEHOLDER(mysql_stmt_result)->fetch(statement, &row); SERVICE_PLACEHOLDER(mysql_stmt_factory)->close(statement)

Member Data Documentation

◆ close

mysql_service_status_t(* s_mysql_mysql_stmt_factory::close) (my_h_statement statement)

Close and clean up resource related to a statement.

Parameters
[in]statementA handle to the statement
Returns
Status of the performed operation
Return values
falsesuccess
truefailure

◆ init

mysql_service_status_t(* s_mysql_mysql_stmt_factory::init) (my_h_statement *statement)

Construct a new statement object.

Note
if the statement already exists, it is overwritten.
Parameters
[out]statementA handle to the statement
Returns
Status of the performed operation
Return values
falsesuccess
truefailure

The documentation for this struct was generated from the following file: