mysql_optionsv - Used to set extra connect options and affect behavior of a connection
#include <mysql.h> int mysql_optionsv(MYSQL * mysql, enum mysql_option, const void * arg, ...);
Used to set extra connect options and affect behavior for a connection. This function may be called multiple times to set several options.
mysql_optionsv() should be called after mysql_init(3).
The following table shows which variable type to use for each option.
Command(s) which will be executed when connecting and reconnecting to the server.
Use the compressed protocol for client server communication. If the server doesn’t support compressed protocol, the default protocol will be used.
Connect timeout in seconds. This value will be passed as an unsigned ##int## parameter.
Enable or disable the use of
LOAD DATA LOCAL INFILE
For Windows operating systems only: Use named pipes for client/server communication.
Specifies a callback function which will be able to visualize the progress of certain long running statements (i.e.
LOAD DATA LOCAL INFILE or
ALTER TABLE). The callback function must be defined as followed:
static void report_progress(const MYSQL *mysql __attribute__((unused)), uint stage, uint max_stage, double progress __attribute__((unused)), const char *proc_info __attribute__((unused)), uint proc_info_length __attribute__((unused)))
Specify the type of client/server protocol. Possible values are:
Enable or disable automatic reconnect.
Specifies the timeout in seconds for reading packets from the server.
Specifies the timeout in seconds for sending packets to the server.
Read options from named configuration file. To read from default
my.cnf configuration file, a NULL pointer has to be passed with option MYSQL_READ_DEFAULT_GROUP. Note: MariaDB Connector/C will not read the configuration by default. If
MYSQL_READ_DEFAULT_FILE is specified the following sections will be always processed:
Read options from the named group from [[configuring-mariadb-with-mycnf|my.cnf]] or the file specified with MYSQL_READ_DEFAULT_FILE.
Enable or disable reporting data truncation errors for prepared statements.
Specify the network interface from which to connect to MariaDB Server.
Specify the location of client plugins.
Specify stack size for non blocking operations. The argument for MYSQL_OPT_NONBLOCK is the size of the stack used to save the state of a non-blocking operation while it is waiting for I/O and the application is doing other processing. Normally, applications will not have to change this, and it can be passed as zero to use the default value.
Specify the name of a connection handler plugin.
Bundle user data to the current connection, e.g. for use in connection handler plugins. This option requires 4 parameters: connection, option, key and value:
mysql_optionsv(mysql, MARIADB_OPT_USERDATA, (void *)"ssh_user", (void *)ssh_user);
This option is used by connection handler plugins and indicates that the current connection will be used for read operations only.
If this option is set, the client indicates that it will be able to handle expired passwords by setting the
CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS capability flag. If the password has expired and
CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS is set, the server will not return an error when connecting, but put the connection in sandbox mode, where all commands will return error 1820 (
ER_MUST_CHANGE_PASSWORD) unless a new password was set. This option was added in MariaDB Connector/C 3.0.4
TLS/SSL and Security options
Specify the name of a key for a secure connection. If the key is protected with a passphrase, the passphrase needs to be specified with
Specify the name of a certificate for a secure connection.
Specify the name of a file which contains one or more trusted CAs.
Specify the path which contains trusted CAs.
Specify one or more (SSLv3, TLSv1.0 or TLSv1.2) cipher suites for TLS encryption. Even if Connector/C supports TLSv1.3 protocol, it is not possible yet to specify TLSv1.3 cipher suites.
Specify a file with a certificate revocation list.
Specify a directory with contains files with certificate revocation lists.
Specify the SHA1 fingerprint of a server certificate for validation during the TLS handshake.
Specify a file which contains one or more SHA1 fingerprints of server certificates for validation during the TLS handshake.
Specify a passphrase for a passphrase protected client key.
Enable (or disable) the verification of the hostname against common name (CN) of the server’s host certificate.
Specifies the name of the file which contains the RSA public key of the database server. The format of this file must be in PEM format. This option is used by the caching_sha2_password plugin and was added in Connector/C 3.1.0
This option is not in use anymore.
Connection attributes are stored in the
session_account_connect_attrsPerformance Schema tables. By default, MariaDB Connector/C sends the following connection attributes to the server: *
_client_name: always “libmariadb” *
_client_version: version of MariaDB Connector/C *
_os: operation system * _pid: process id *
_platform: e.g. x86 or x64 *
_server_host: the hostname (as specified in mysql_real_connect). This attribute was added in Connector/C 3.0.5
Note: If the Performance Schema is disabled, connection attributes will not be stored on server.
Deletes a connection attribute for the given key.
Adds a key/value pair to connection attributes.
Clears the current list of connection attributes.
mariadb_reconnect(3), mysql_init(3), mysql_options(3), mysql_options4(3), mysql_ping(3), mysql_real_connect(3), mysql_stmt_fetch(3).