mysql_stmt_store_result() retrieves and stores a result set.
Syntax
int
mysql_stmt_store_result(MYSQL_STMT *stmt)
Return values
If the function is executed, zero is returned. If an error occurs, a non-zero value is returned.
Error messages
CR_COMMANDS_OUT_OF_SYNC: Commands are executed in an incorrect order.CR_OUT_OF_MEMORY: The memory is insufficient.CR_SERVER_GONE_ERROR: The connection to the OBServer was interrupted.CR_SERVER_LOST: The connection to the server was lost during the query.CR_UNKNOWN_ERROR: An unknown error occurred.
Notes
You call mysql_stmt_execute() to execute prepared SQL statements, such as SELECT, SHOW, DESCRIBE, and EXPLAIN, to generate a result set. By default, the result set of the executed prepared statements is not buffered at the client. Therefore, mysql_stmt_fetch() obtains one result set at a time from the server. To buffer the complete result set at the client, use mysql_stmt_bind_result() to bind the data buffer and call mysql_stmt_store_result() before calling mysql_stmt_fetch() to obtain rows.
A searchable result set is required only when you call mysql_stmt_data_seek(), mysql_stmt_row_seek(), or mysql_stmt_row_tell(). In this case, you can call mysql_stmt_store_result().
After you execute an SQL statement that does not generate a result set, you do not need to call mysql_stmt_store_result(), which does not cause any harm or significant performance problems even if you call it. You can check whether the statement generates a result set by checking whether mysql_stmt_result_metadata() returns NULL.
By default, OceanBase Database does not calculate MYSQL_FIELD->max_length for all columns of mysql_stmt_store_result() because this greatly slows down the execution speed of mysql_stmt_store_result(), and max_length is not required for most applications. To update max_length, you can call mysql_stmt_attr_set(MYSQL_STMT, STMT_ATTR_UPDATE_MAX_LENGTH, &flag).