OceanBase Connector/C is an OceanBase client development component based on C/C++. OceanBase Connector/C supports the C API library.
OceanBase Connector/C allows C/C++ applications to access OceanBase distributed database clusters from the underlying layer. Then, the applications can perform operations such as database connection, data access, error processing, and prepared statement processing.
OceanBase Connector/C is also called LibobClient and is used as an independent server process for applications to communicate with OBServers based on network connections. A client references the C API header file during compilation and can connect to the C API library file.
Functions and objects
The following table lists the supported C API functions.
For more information about the following functions, see the topic about C API functions of OceanBase Connection/C.
| Function | Description |
|---|---|
| my_init | Initializes the global variables required by OceanBase Database. |
| mysql_affected_rows | Returns the number of rows modified, deleted, or inserted by the UPDATE, DELETE, or INSERT statement that was last executed. |
| mysql_autocommit | Sets the autocommit mode. |
| mysql_change_user | Changes the user and sets the specified database as the default database on the specified connection. |
| mysql_character_set_name | Returns the name of the default character set for the current connection. |
| mysql_client_find_plugin | Returns a pointer to a plugin that is loaded. |
| mysql_client_register_plugin | Adds a plugin structure to the list of plugins that are loaded. |
| mysql_close | Closes a connection that was previously opened. |
| mysql_commit | Commits the current transaction. |
| mysql_connect | Connects to an OBServer. |
| mysql_create_db | Creates the database that is named by the db parameter. |
| mysql_data_seek | Searches for an arbitrary row in a query result set. |
| mysql_debug | Uses a specified string to perform a DEBUG_PUSH operation. |
| mysql_drop_db | Deletes the database that is named by the db parameter. |
| mysql_dump_debug_info | Notifies an OBServer to write debugging information to the error log. |
| mysql_eof | Checks whether the last row of a result set has been read. |
| mysql_errno | Returns the error code for the most recently invoked API function. |
| mysql_error | Returns a string ending with a null character and containing the error message for the most recently invoked API function that failed. |
| mysql_escape_string | Escapes special characters in a string to be used in SQL statements. |
| mysql_fetch_field | Returns the next field. |
| mysql_fetch_field_direct | Returns the field with the specified field number. |
| mysql_fetch_fields | Returns all MYSQL_FIELD structures in a result set as an array. The MYSQL_FIELD structure provides field definitions for columns of the result set. |
| mysql_fetch_lengths | Returns the lengths of columns in the current row of a result set. |
| mysql_fetch_row | Obtains the next row of a result set. |
| mysql_field_count | Returns the number of columns that were most recently queried. |
| mysql_field_seek | Searches for columns in a row of a result set. |
| mysql_field_tell | Returns the position of the field cursor used for the last call to the mysql_fetch_field() function. |
| mysql_free_result | Frees the memory allocated to a result set. |
| mysql_get_character_set_info | Returns information about the default character set. |
| mysql_get_client_info | Returns a string that represents the OBClient version. |
| mysql_get_client_version | Returns the OBClient version as an integer. |
| mysql_get_host_info | Returns a string that describes the current connection type, including the server host name. |
| mysql_get_proto_info | Returns the protocol version used for the current connection. |
| mysql_get_server_info | Returns a string that represents the OBServer version. |
| mysql_get_server_version | Returns the OBServer version as an integer. |
| mysql_get_ssl_cipher | Returns the encryption cipher used for a specified connection to the OBServer. |
| mysql_hex_string | Creates a hexadecimal string that can be used in SQL statements. |
| mysql_info | Returns a string that provides information about the most recently executed statement. |
| mysql_init | Assigns or initializes a MySQL object that is suitable for the mysql_real_connect() function. |
| mysql_insert_id | Returns the value generated for an auto-increment column by the previous INSERT or UPDATE statement. |
| mysql_kill | Notifies an OBServer to kill the thread specified by pid. |
| mysql_library_end | Finalizes the C API library. |
| mysql_library_init | Initializes the C API library. |
| mysql_list_dbs | Returns a result set that consists of the database names matching the simple regular expression specified by the wild parameter. |
| mysql_list_fields | Returns a field that matches the simple regular expression specified by the wild parameter. |
| mysql_list_processes | Returns a result set that describes the current server thread. |
| mysql_list_tables | Returns a result set that consists of the table names matching the simple regular expression specified by the wild parameter. An H3+ parsing library is added. |
| mysql_load_plugin | Loads an OBClient plugin with the specified name and type. |
| mysql_load_plugin_v | Loads an OBClient plugin. |
| mysql_more_results | Checks whether more results exist. |
| mysql_next_result | Reads the next statement result to check whether more results exist. You can use this function when you execute multiple statements that are specified as a single statement string, or when you use CALL statements to execute stored procedures. Stored procedures can return multiple result sets. |
| mysql_num_fields | Returns the number of columns in a specified result set. |
| mysql_num_rows | Returns the number of rows in a specified result set. |
| mysql_options | Sets extra connection options and affects the behaviors of a connection. |
| mysql_options4 | Sets extra connection options and affects the behaviors of a connection. |
| mysql_ping | Checks whether a connection to an OBServer works as expected. |
| mysql_plugin_options | Passes an option type and value to a plugin. |
| mysql_query | Executes the SQL statement to which the null termination string stmt_str points. |
| mysql_real_connect | Establishes a connection to the OBServer where the host is running. |
| mysql_real_escape_string | Escapes special characters in the string of a statement to generate a hexadecimal string that can be used in SQL statements. |
| mysql_real_query | Executes the SQL statement to which stmt_str points. |
| mysql_refresh | Refreshes or resets the tables and caches. |
| mysql_reload | Notifies an OBServer to reload the privilege tables. |
| mysql_rollback | Rolls back the current transaction. |
| mysql_row_seek | Searches for an arbitrary row in a query result set. |
| mysql_row_tell | Returns the current position of the row cursor for a result set. |
| mysql_select_db | Sets the database specified by db as the default database (current database) of the specified connection. |
| mysql_server_end | Finalizes the C API library. |
| mysql_server_init | Initializes the OBClient library. |
| mysql_set_character_set | Sets the default character set for the current connection. |
| mysql_set_local_infile_default | Sets the LOAD DATA LOCAL callback functions to the default values internally used by the C client library. |
| mysql_set_local_infile_handler | Installs the callbacks to be fired during the execution of LOAD DATA LOCAL statements. |
| mysql_set_server_option | Enables or disables a connection option. |
| mysql_shutdown | Shuts down an OBServer. |
| mysql_sqlstate | Returns a string that ends with a null character and contains the SQLSTATE error code for the most recently executed SQL statement. |
| mysql_ssl_set | Establishes an encrypted connection by using SSL. |
| mysql_stat | Returns a string containing server information similar to that provided by the mysqladmin status command. The information includes the uptime in seconds and the number of running threads, questions, reloads, and open tables. |
| mysql_stmt_affected_rows | Returns the number of rows modified, deleted, or inserted by the UPDATE, DELETE, or INSERT statement that was last executed. |
| mysql_stmt_attr_get | Obtains the current value for a statement attribute. |
| mysql_stmt_attr_set | Sets an attribute value for a prepared statement. |
| mysql_stmt_bind_param | Associates the input data with the parameter markers of a prepared statement. |
| mysql_stmt_bind_result | Associates output columns in the result set with data buffers and length buffers. |
| mysql_stmt_close | Closes a prepared statement. |
| mysql_stmt_data_seek | Searches for an arbitrary row in a statement result set. |
| mysql_stmt_errno | Returns the error code generated for the most recently revoked statement API function. |
| mysql_stmt_error | Returns the error message generated for the most recently revoked statement API function. |
| mysql_stmt_execute | Executes the prepared query associated with a statement handle. |
| mysql_stmt_fetch | Returns the next row of a result set and returns the values of all associated columns. |
| mysql_stmt_fetch_column | Returns a column from the current result set row. |
| mysql_stmt_field_count | Returns the number of columns in the current result set of a prepared statement. |
| mysql_stmt_free_result | Releases memory associated with the result set generated by executing a prepared statement. |
| mysql_stmt_init | Creates and returns a MYSQL_STMT handler. |
| mysql_stmt_insert_id | Returns the value generated for an auto-increment column by a prepared INSERT or UPDATE statement. |
| mysql_stmt_next_result | Checks whether more results exist for a prepared statement. |
| mysql_stmt_num_rows | Returns the number of rows in a result set. |
| mysql_stmt_param_count | Returns the number of parameters in a prepared statement. |
| mysql_stmt_param_metadata | Returns parameter metadata as a result set. |
| mysql_stmt_prepare | Prepares the SQL statement to which the stmt_str string points and returns a status value. |
| mysql_stmt_reset | Resets a statement on an OBServer, the data sent by the mysql_stmt_send_long_data() function, unbuffered result sets, and current errors. |
| mysql_stmt_result_metadata | Obtains the result set metadata of a prepared statement. |
| mysql_stmt_row_seek | Searches for an arbitrary row in the result set of a prepared statement. |
| mysql_stmt_row_tell | Returns the current position of the row cursor for the result set of a prepared statement. |
| mysql_stmt_send_long_data | Allows an application to send parameter data to an OBServer in pieces or chunks. |
| mysql_stmt_sqlstate | Returns the SQLSTATE value for the most recently invoked prepared statement API function. |
| mysql_stmt_store_result | Retrieves and stores a result set. |
| mysql_store_result | Queries and stores a result set. |
| mysql_thread_end | Finalizes a thread handle. |
| mysql_thread_id | Returns the thread ID for the current connection. |
| mysql_thread_init | Initializes a thread handle. |
| mysql_thread_safe | Indicates whether the OBClient library is compiled as thread-safe. |
| mysql_use_result | Retrieves a result set row by row. |
| mysql_warning_count | Returns the number of errors, warnings, and notes generated by the execution of the previous SQL statement. |
C API data structures
| Object | Description |
|---|---|
| MYSQL | The handler for a database connection. |
| MYSQL_RES | The result of a query. |
| MYSQL_ROW | The representation of a data row. |
| MYSQL_FIELD | The metadata of a column. |
| MYSQL_FIELD_OFFSET | The representation of an offset into a column list. |
| my_ulonglong | A basic type. |
| my_bool | A basic type. |
More information
For more information about OceanBase Connector/C, see OceanBase Connector/C.