OceanBase
English日本語简体中文
Docs Home
Products
Integrations
Release Notes

Databases

OceanBase DatabaseOceanBase Cloud OceanBase Best Practices

Tools

OceanBase Cloud PlatformOceanBase Migration ServiceOceanBase Developer CenterOceanBase Migration AssessmentOceanBase Admin ToolOceanBase Loader and DumperOceanBase DeployerKubernetes operator for OceanBaseOceanBase Diagnostic Tool OceanBase Binlog Service

Connectors and Middleware

OceanBase Database Proxy OceanBase Connector/C OceanBase Connector/J OceanBase Connector/ODBC OceanBase Connector/NETOceanBase Command-Line Client

Databases

OceanBase DatabaseOceanBase Cloud OceanBase Best Practices

Connectors and Middleware

OceanBase Database Proxy OceanBase Connector/C OceanBase Connector/J OceanBase Connector/ODBC OceanBase Connector/NETOceanBase Command-Line Client

Tools

OceanBase Cloud PlatformOceanBase Migration ServiceOceanBase Developer CenterOceanBase Migration AssessmentOceanBase Admin ToolOceanBase Loader and DumperOceanBase DeployerKubernetes operator for OceanBaseOceanBase Diagnostic Tool OceanBase Binlog Service
OceanBase DatabaseOceanBase Cloud ToolsConnectors and MiddlewareLifecycle Support Policy

OceanBase Connector/C

V2.0.0
  • Overview
  • Installation guide
  • User Guide
    • Basic data structures
    • Basic operations
      • Basic API operations
      • API operations on prepared statements
  • C API functions
    • Overview
    • my_init()
    • mysql_affected_rows()
    • mysql_autocommit()
    • mysql_change_user()
    • mysql_character_set_name()
    • mysql_client_find_plugin()
    • mysql_client_register_plugin()
    • mysql_close()
    • mysql_commit()
    • mysql_connect()
    • mysql_create_db()
    • mysql_data_seek()
    • mysql_debug()
    • mysql_drop_db()
    • mysql_dump_debug_info()
    • mysql_eof()
    • mysql_errno()
    • mysql_error()
    • mysql_escape_string()
    • mysql_fetch_field()
    • mysql_fetch_field_direct()
    • mysql_fetch_fields()
    • mysql_fetch_lengths()
    • mysql_fetch_row()
    • mysql_field_count()
    • mysql_field_seek()
    • mysql_field_tell()
    • mysql_free_result()
    • mysql_get_character_set_info()
    • mysql_get_client_info()
    • mysql_get_client_version()
    • mysql_get_host_info()
    • mysql_get_proto_info()
    • mysql_get_server_info()
    • mysql_get_server_version()
    • mysql_get_ssl_cipher()
    • mysql_hex_string()
    • mysql_info()
    • mysql_init()
    • mysql_insert_id()
    • mysql_kill()
    • mysql_library_end()
    • mysql_library_init()
    • mysql_list_dbs()
    • mysql_list_fields()
    • mysql_list_processes()
    • mysql_list_tables()
    • mysql_load_plugin()
    • mysql_load_plugin_v()
    • mysql_more_results()
    • mysql_next_result()
    • mysql_num_fields()
    • mysql_num_rows()
    • mysql_options()
    • mysql_options4()
    • mysql_ping()
    • mysql_plugin_options()
    • mysql_query()
    • mysql_real_connect()
    • mysql_real_escape_string()
    • mysql_real_query()
    • mysql_refresh()
    • mysql_reload()
    • mysql_rollback()
    • mysql_row_seek()
    • mysql_row_tell()
    • mysql_select_db()
    • mysql_server_end()
    • mysql_server_init()
    • mysql_set_character_set()
    • mysql_set_local_infile_default()
    • mysql_set_local_infile_handler()
    • mysql_set_server_option()
    • mysql_shutdown()
    • mysql_sqlstate()
    • mysql_ssl_set()
    • mysql_stat()
    • mysql_stmt_affected_rows()
    • mysql_stmt_attr_get()
    • mysql_stmt_attr_set()
    • mysql_stmt_bind_param()
    • mysql_stmt_bind_result()
    • mysql_stmt_close()
    • mysql_stmt_data_seek()
    • mysql_stmt_errno()
    • mysql_stmt_error()
    • mysql_stmt_execute()
    • mysql_stmt_fetch()
    • mysql_stmt_fetch_column()
    • mysql_stmt_field_count()
    • mysql_stmt_free_result()
    • mysql_stmt_init()
    • mysql_stmt_insert_id()
    • mysql_stmt_next_result()
    • mysql_stmt_num_rows()
    • mysql_stmt_param_count()
    • mysql_stmt_param_metadata()
    • mysql_stmt_prepare()
    • mysql_stmt_reset()
    • mysql_stmt_result_metadata()
    • mysql_stmt_row_seek()
    • mysql_stmt_row_tell()
    • mysql_stmt_send_long_data()
    • mysql_stmt_sqlstate()
    • mysql_stmt_store_result()
    • mysql_store_result()
    • mysql_thread_end()
    • mysql_thread_id()
    • mysql_thread_init()
    • mysql_thread_safe()
    • mysql_use_result()
    • mysql_warning_count()

Download PDF

Document Feedback
  1. Documentation Center
  2. OceanBase Connector/C
  3. V2.0.0

mysql_use_result()

Last Updated:2026-09-04 08:24:09

Syntax
Return values
Error messages
Notes

mysql_use_result() retrieves a result set row by row.

Syntax

MYSQL_RES *
mysql_use_result(MYSQL *mysql)

Return values

A MYSQL_RES result structure. If an error occurs, NULL is returned.

Error messages

If mysql_use_result() is executed, it resets mysql_error() and mysql_errno().

  • 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

After you call mysql_real_query() or mysql_query(), you must call mysql_store_result() or mysql_use_result() for each of the following statement that generates a result set: SELECT, SHOW, DESCRIBE, EXPLAIN, and CHECK TABLE. After you process the result set, you must call mysql_free_result().

mysql_use_result() can start a result set retrieval. However, it does not read the result set to the client like mysql_store_result() does. Instead, you must call mysql_fetch_row() to retrieve each row. In this way, query results are read directly from the server without being stored in temporary tables or local buffers. This is faster and less memory is used compared with mysql_store_result(). The client allocates memory only to the current row and communication buffers whose byte size is specified by max_allowed_packet.

If the client needs to perform lots of operations on each row or output each row to a screen on which the user can type ^S to stop scrolling, we recommend that you do not call mysql_use_result() to lock reads. It is because some server threads will be occupied and other threads will be prevented from updating tables that are used to obtain data.

When you use mysql_use_result(), you must execute mysql_fetch_row() until NULL is returned. Otherwise, the unobtained rows are returned as part of the result set for the next query. If you forget to perform the preceding operation, the C API returns the following error message: Commands out of sync; you can't run this command now!

You cannot use the results returned by mysql_use_result() in conjunction with mysql_data_seek(), mysql_row_seek(), mysql_row_tell(), mysql_num_rows(), or mysql_affected_rows(). In addition, you cannot initiate other queries before mysql_use_result() is executed.

After you process the result set, you must call mysql_free_result().

Previous topic

mysql_thread_safe()
Last

Next topic

mysql_warning_count()
Next
on this page
Syntax
Return values
Error messages
Notes