# MariaDB Connector/C API Functions

- [mariadb\_cancel](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mariadb_cancel.md): mariadb\_cancel immediately aborts a connection by making all subsequent read/write operations fail, without freeing the MYSQL structure or closing communication channels.
- [mariadb\_get\_infov](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mariadb_get_infov.md): mariadb\_get\_infov retrieves generic or connection-specific information from a MariaDB Connector/C handle, accepting a value-type enum and a pointer to store the result.
- [mariadb\_reconnect](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mariadb_reconnect.md): mariadb\_reconnect attempts to re-establish a dropped MariaDB Connector/C connection using the original credentials, and requires the MYSQL\_OPT\_RECONNECT option to be set.
- [mysql\_affected\_rows](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_affected_rows.md): mysql\_affected\_rows returns the number of rows affected by the last INSERT, UPDATE, DELETE, or REPLACE statement executed on a MariaDB Connector/C connection.
- [mysql\_autocommit](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_autocommit.md): mysql\_autocommit enables or disables autocommit mode for the current database connection, returning zero on success or nonzero on failure.
- [mysql\_change\_user](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_change_user.md): mysql\_change\_user changes the authenticated user and default database on an existing connection, resetting session state including transactions, temporary tables, and locks.
- [mysql\_character\_set\_name](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_character_set_name.md): mysql\_character\_set\_name returns the name of the default client character set for a specified MariaDB Connector/C connection.
- [mysql\_close](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_close.md): mysql\_close terminates an open database connection and releases the memory allocated for the MYSQL handle.
- [mysql\_commit](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_commit.md): mysql\_commit commits the current transaction on a MariaDB Connector/C connection, returning zero on success without affecting autocommit mode.
- [mysql\_data\_seek](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_data_seek.md): mysql\_data\_seek moves the result set pointer to an arbitrary row offset in a buffered result set obtained via mysql\_store\_result, enabling random row access.
- [mysql\_debug](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_debug.md): mysql\_debug enables debug output for a MariaDB Connector/C client using the DBUG library, accepting a colon-separated control string to configure trace and logging options.
- [mysql\_dump\_debug\_info](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_dump_debug_info.md): mysql\_dump\_debug\_info instructs a MariaDB server to write connection status information to the error log, and requires the SUPER privilege for the current user.
- [mysql\_errno](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_errno.md): mysql\_errno returns the numeric error code from the most recent MariaDB Connector/C function call, or zero if no error occurred.
- [mysql\_error](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_error.md): mysql\_error returns the error message string for the most recent failed MariaDB Connector/C function call, or an empty string if no error occurred.
- [mysql\_escape\_string](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_escape_string.md): mysql\_escape\_string encodes a string using the default character set for safe use in SQL statements. Deprecated — use mysql\_real\_escape\_string instead.
- [mysql\_fetch\_field](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_fetch_field.md): mysql\_fetch\_field returns the definition of one result set column as a MYSQL\_FIELD pointer; call it repeatedly to iterate over all columns in the result set.
- [mysql\_fetch\_field\_direct](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_fetch_field_direct.md): mysql\_fetch\_field\_direct returns a MYSQL\_FIELD pointer for a specific column in a result set, identified by its zero-based field number.
- [mysql\_fetch\_fields](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_fetch_fields.md): mysql\_fetch\_fields returns all column definitions for a MariaDB result set as an array of MYSQL\_FIELD structures, one entry per column.
- [mysql\_fetch\_lengths](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_fetch_lengths.md): mysql\_fetch\_lengths returns an array of byte lengths for each column in the current row of a MariaDB result set, valid only after mysql\_fetch\_row is called.
- [mysql\_fetch\_row](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_fetch_row.md): mysql\_fetch\_row retrieves the next row from a MariaDB result set as an array of char pointers, returning NULL when no more rows are available.
- [mysql\_field\_count](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_field_count.md): mysql\_field\_count returns the number of columns in the most recent query result for a MariaDB connection, useful for checking whether a result set is available.
- [mysql\_field\_seek](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_field_seek.md): mysql\_field\_seek sets the field cursor to a given column offset in a MariaDB result set, controlling which field mysql\_fetch\_field returns next.
- [mysql\_field\_tell](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_field_tell.md): mysql\_field\_tell retrieves the current field cursor position in a result set, which can be passed to mysql\_field\_seek to restore that position.
- [mysql\_free\_result](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_free_result.md): mysql\_free\_result releases the memory allocated for a MariaDB result set; row values obtained from prior mysql\_fetch\_row calls become invalid after this call.
- [mysql\_get\_character\_set\_info](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_get_character_set_info.md): mysql\_get\_character\_set\_info populates a MY\_CHARSET\_INFO structure with details about the current default character set for a MariaDB Connector/C connection.
- [mysql\_get\_client\_info](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_get_client_info.md): mysql\_get\_client\_info retrieves the client library version as a string; use mysql\_get\_client\_version for the equivalent numeric value.
- [mysql\_get\_client\_version](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_get_client_version.md): mysql\_get\_client\_version retrieves the client library version as an unsigned long; use mysql\_get\_client\_info for the string representation.
- [mysql\_get\_host\_info](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_get_host_info.md): mysql\_get\_host\_info returns a string describing the connection type and server hostname for a MariaDB Connector/C connection, or NULL if invalid.
- [mysql\_get\_optionv](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_get_optionv.md): mysql\_get\_optionv retrieves the current value of a connection option previously set with mysql\_optionsv, supporting boolean, integer, string, and miscellaneous option types.
- [mysql\_get\_proto\_info](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_get_proto_info.md): mysql\_get\_proto\_info returns the protocol version number used for a MariaDB Connector/C connection; versions 9 and below are not supported.
- [mysql\_get\_server\_info](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_get_server_info.md): mysql\_get\_server\_info retrieves the connected server version string; use mysql\_get\_server\_version for the equivalent numeric representation.
- [mysql\_get\_server\_version](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_get_server_version.md): mysql\_get\_server\_version retrieves the server version as an unsigned long; use mysql\_get\_server\_info for the equivalent string representation.
- [mysql\_get\_ssl\_cipher](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_get_ssl_cipher.md): mysql\_get\_ssl\_cipher returns the name of the TLS cipher in use for a MariaDB Connector/C connection, or NULL for non-TLS connections.
- [mysql\_hex\_string](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_hex_string.md): mysql\_hex\_string converts a binary buffer to a hex-encoded string for safe embedding in SQL; the output buffer must be at least 2\*length+1 bytes.
- [mysql\_info](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_info.md): mysql\_info returns a string with summary statistics about the last executed query, covering INSERT, UPDATE, ALTER TABLE, and LOAD DATA operations; returns NULL for SELECT.
- [mysql\_init](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_init.md): mysql\_init allocates and initializes a MYSQL structure for use with mysql\_real\_connect, and also initializes the thread subsystem if not already done.
- [mysql\_insert\_id](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_insert_id.md): mysql\_insert\_id returns the AUTO\_INCREMENT value generated by the last INSERT or UPDATE statement on a MariaDB connection, or zero if no such value was produced.
- [mysql\_kill](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_kill.md): mysql\_kill requests the MariaDB server to terminate the thread with the given process ID; use mysql\_thread\_id to obtain the ID of the current connection.
- [mysql\_library\_end](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_library_end.md): mysql\_library\_end finalizes the MariaDB Connector/C library after use, performing memory cleanup and shutting down the embedded server if applicable.
- [mysql\_library\_init](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_library_init.md): mysql\_library\_init initializes the MariaDB Connector/C library before any other functions are called, starting the embedded server if used in that configuration.
- [mysql\_more\_results](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_more_results.md): mysql\_more\_results indicates whether additional result sets remain from a previous multi-statement query, returning 1 if more results are available.
- [mysql\_next\_result](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_next_result.md): mysql\_next\_result advances to the next result set from a multi-statement query, making it available for retrieval via mysql\_store\_result or mysql\_use\_result.
- [mysql\_num\_fields](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_num_fields.md): mysql\_num\_fields retrieves the column count from a result set handle, useful for iterating over fields in a MariaDB query result.
- [mysql\_num\_rows](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_num_rows.md): mysql\_num\_rows returns the number of rows in a MariaDB result set; for unbuffered results the count is only accurate after all rows have been fetched.
- [mysql\_options](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_options.md): mysql\_options sets extra connection options on a MYSQL handle before calling mysql\_real\_connect. Deprecated since Connector/C 3.0 — use mysql\_optionsv instead.
- [mysql\_optionsv](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_optionsv.md): mysql\_optionsv sets connection, TLS, plugin, and option-file options on a MariaDB Connector/C handle before mysql\_real\_connect, supporting a variable argument list.
- [mysql\_ping](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_ping.md): mysql\_ping checks whether a MariaDB server connection is still active and attempts an automatic reconnect if the connection has dropped and reconnect is enabled.
- [mysql\_query](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_query.md): mysql\_query sends a null-terminated SQL string to the MariaDB server for execution, returning zero on success; use mysql\_real\_query for binary-safe operation.
- [mysql\_read\_query\_result](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_read_query_result.md): mysql\_read\_query\_result reads the result of a statement previously sent with mysql\_send\_query, and must be called once for each successful mysql\_send\_query call.
- [mysql\_real\_connect](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_real_connect.md): mysql\_real\_connect opens a connection to a MariaDB server and returns a MYSQL handle on success, or NULL if the connection could not be established.
- [mysql\_real\_escape\_string](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_real_escape_string.md): mysql\_real\_escape\_string encodes a string for safe use in a SQL statement, taking the connection's current character set into account when escaping special characters.
- [mysql\_real\_query](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_real_query.md): mysql\_real\_query sends a binary-safe SQL statement to a MariaDB server; use mysql\_num\_fields to determine whether the query returned a result set.
- [mysql\_refresh](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_refresh.md): mysql\_refresh flushes server-side caches and state using a bitmask of options such as REFRESH\_GRANT, REFRESH\_LOG, REFRESH\_TABLES, and REFRESH\_HOSTS.
- [mysql\_reset\_connection](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_reset_connection.md): mysql\_reset\_connection resets session state on a MariaDB Connector/C connection — rolling back transactions and clearing variables — without disconnecting or reauthenticating.
- [mysql\_rollback](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_rollback.md): mysql\_rollback undoes the current transaction for a database connection; it has no effect if autocommit is enabled or the engine is non-transactional.
- [mysql\_row\_seek](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_row_seek.md): mysql\_row\_seek repositions the row cursor in a buffered MariaDB result set to an arbitrary offset, returning the previous row position as a MYSQL\_ROW\_OFFSET.
- [mysql\_row\_tell](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_row_tell.md): mysql\_row\_tell returns the current row cursor offset for a buffered MariaDB result set, which can then be passed to mysql\_row\_seek to restore that position.
- [mysql\_select\_db](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_select_db.md): mysql\_select\_db changes the default database on an active connection; the current default can also be queried with the SELECT DATABASE() SQL function.
- [mysql\_send\_query](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_send_query.md): mysql\_send\_query dispatches a query asynchronously on a MariaDB connection; each call must be followed by mysql\_read\_query\_result to consume the response.
- [mysql\_server\_end](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_server_end.md): mysql\_server\_end is an alias for mysql\_library\_end in MariaDB Connector/C, used to finalize and clean up the client library.
- [mysql\_server\_init](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_server_init.md): mysql\_server\_init is an alias for mysql\_library\_init in MariaDB Connector/C, used to initialize the client library before making any other calls.
- [mysql\_session\_track\_get\_first](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_session_track_get_first.md): mysql\_session\_track\_get\_first retrieves the first session state change notification from the server, covering schema changes, system variables, and state flags. Added in Connector/C 3.0.
- [mysql\_session\_track\_get\_next](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_session_track_get_next.md): mysql\_session\_track\_get\_next retrieves subsequent session state change notifications after mysql\_session\_track\_get\_first, called repeatedly until a nonzero value signals end of data.
- [mysql\_set\_character\_set](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_set_character_set.md): mysql\_set\_character\_set sets the default character set for a MariaDB Connector/C connection, ensuring mysql\_real\_escape\_string uses the correct encoding.
- [mysql\_set\_server\_option](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_set_server_option.md): mysql\_set\_server\_option enables or disables multi-statement support on a MariaDB connection using MYSQL\_OPTION\_MULTI\_STATEMENTS\_ON or \_OFF.
- [mysql\_set\_local\_infile\_handler](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_set_local_infile_handler.md): mysql\_set\_local\_infile\_handler registers custom callback functions for init, read, end, and error phases of a LOAD DATA LOCAL INFILE operation in MariaDB Connector/C.
- [mysql\_set\_local\_infile\_default](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_set_local_infile_default.md): mysql\_set\_local\_infile\_default resets local infile callbacks to the Connector/C internal defaults, reversing any custom handler registered via mysql\_set\_local\_infile\_handler.
- [mysql\_shutdown](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_shutdown.md): mysql\_shutdown sends a shutdown request to the MariaDB server over the current connection, requiring the SHUTDOWN privilege for the authenticated user.
- [mysql\_sqlstate](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_sqlstate.md): mysql\_sqlstate returns the five-character SQLSTATE error code for the most recent MariaDB Connector/C function call, with 00000 indicating success.
- [mysql\_ssl\_set](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_ssl_set.md): mysql\_ssl\_set configures TLS parameters including key, certificate, CA, and cipher list for a MariaDB connection, and must be called before mysql\_real\_connect.
- [mysql\_stat](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_stat.md): mysql\_stat returns a status string from the MariaDB server covering uptime, active threads, query count, open tables, and queries per second.
- [mysql\_store\_result](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_store_result.md): mysql\_store\_result retrieves a complete buffered result set from the last executed MariaDB query, returning NULL on error or for non-SELECT statements.
- [mysql\_thread\_end](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_thread_end.md): mysql\_thread\_end releases thread-local memory allocated by mysql\_thread\_init and must be called explicitly before a thread exits to avoid memory leaks. Deprecated in Connector/C 3.0.
- [mysql\_thread\_id](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_thread_id.md): mysql\_thread\_id retrieves the thread identifier for an active connection; the value may change after a reconnect if the reconnect option is enabled.
- [mysql\_thread\_init](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_thread_init.md): mysql\_thread\_init initializes thread-local variables for multi-threaded Connector/C clients; called automatically by mysql\_init if not invoked explicitly. Deprecated in Connector/C 3.0.
- [mysql\_thread\_safe](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_thread_safe.md): mysql\_thread\_safe returns 1 if the MariaDB Connector/C client library was compiled with thread-safety support, or zero otherwise.
- [mysql\_use\_result](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_use_result.md): mysql\_use\_result initiates unbuffered retrieval of a query result set row by row from the MariaDB server, blocking the connection until all rows are fetched or freed.
- [mysql\_warning\_count](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_warning_count.md): mysql\_warning\_count retrieves the warning count from the most recent query execution; use SHOW WARNINGS for the full warning message text.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
