MySQL :: MySQL 8.0 C API Developer Guide :: 6.4.28 mysql_stmt_store_result() (original) (raw)
6.4.28 mysql_stmt_store_result()
int
mysql_stmt_store_result(MYSQL_STMT *stmt)
Description
Result sets are produced by callingmysql_stmt_execute() to executed prepared statements for SQL statements such asSELECT,SHOW,DESCRIBE, andEXPLAIN. By default, result sets for successfully executed prepared statements are not buffered on the client andmysql_stmt_fetch() fetches them one at a time from the server. To cause the complete result set to be buffered on the client, callmysql_stmt_store_result() after binding data buffers withmysql_stmt_bind_result() and before callingmysql_stmt_fetch() to fetch rows. (For an example, seeSection 6.4.11, “mysql_stmt_fetch()”.)
mysql_stmt_store_result() is optional for result set processing, unless you will callmysql_stmt_data_seek(),mysql_stmt_row_seek(), ormysql_stmt_row_tell(). Those functions require a seekable result set.
It is unnecessary to callmysql_stmt_store_result() after executing an SQL statement that does not produce a result set, but if you do, it does not harm or cause any notable performance problem. You can detect whether the statement produced a result set by checking whethermysql_stmt_result_metadata() returns NULL
. For more information, refer to Section 6.4.23, “mysql_stmt_result_metadata()”.
Return Values
Zero for success. Nonzero if an error occurred.
Errors
- CR_COMMANDS_OUT_OF_SYNC
Commands were executed in an improper order. - CR_OUT_OF_MEMORY
Out of memory. - CR_SERVER_GONE_ERROR
The MySQL server has gone away. - CR_SERVER_LOST
The connection to the server was lost during the query. - CR_UNKNOWN_ERROR
An unknown error occurred.