'\" t .\" Automatically generated by Pandoc 3.5 .\" .TH "mysql_optionsv" "3" "" "Version 3.4" "MariaDB Connector/C" .SS Name mysql_optionsv \- Used to set extra connect options and affect behavior of a connection .SS Synopsis .IP .EX #include \f[B]\f[R] int mysql_optionsv(MYSQL * mysql, \f[B]enum\f[R] mysql_option, const void * arg, ...); .EE .SS Description Used to set extra connect options and affect behavior for a connection. This function may be called multiple times to set several options. \f[CR]mysql_optionsv()\f[R] should be called after \f[B]mysql_init(3)\f[R]. .SS Options The following table shows which variable type to use for each option. .PP .TS tab(@); lw(35.0n) lw(35.0n). T{ Variable Type T}@T{ Values T} _ T{ \f[CR]my_bool\f[R] T}@T{ \f[CR]MYSQL_OPT_RECONNECT\f[R], \f[CR]MYSQL_SECURE_AUTH\f[R], \f[CR]MYSQL_REPORT_DATA_TRUNCATION\f[R], \f[CR]MYSQL_OPT_SSL_ENFORCE\f[R], \f[CR]MYSQL_OPT_SSL_VERIFY_SERVER_CERT\f[R], \f[CR]MARIADB_OPT_SKIP_READ_RESPONSE\f[R] T} T{ \f[CR]unsigned int\f[R] T}@T{ \f[CR]MYSQL_OPT_PORT\f[R], \f[CR]MYSQL_OPT_LOCAL_INFILE\f[R], \f[CR]MYSQL_OPT_CONNECT_TIMEOUT\f[R], \f[CR]MYSQL_OPT_PROTOCOL\f[R], \f[CR]MYSQL_OPT_READ_TIMEOUT\f[R], \f[CR]MYSQL_OPT_WRITE_TIMEOUT\f[R] T} T{ \f[CR]unsigned long\f[R] T}@T{ \f[CR]MYSQL_OPT_NET_BUFFER_LENGTH\f[R], \f[CR]MYSQL_OPT_MAX_ALLOWED_PACKET\f[R] T} T{ \f[CR]const char *\f[R] T}@T{ \f[CR]MYSQL_INIT_COMMAND\f[R], \f[CR]MARIADB_OPT_UNIXSOCKET\f[R], \f[CR]MARIADB_OPT_PASSWORD\f[R] , \f[CR]MARIADB_OPT_USER\f[R], \f[CR]MARIADB_OPT_HOST\f[R], \f[CR]MARIADB_OPT_SCHEMA\f[R], \f[CR]MYSQL_OPT_SSL_KEY\f[R], \f[CR]MYSQL_OPT_SSL_CERT\f[R], \f[CR]MYSQL_OPT_SSL_CA\f[R], \f[CR]MYSQL_OPT_SSL_CAPATH\f[R], \f[CR]MYSQL_SET_CHARSET_NAME\f[R], \f[CR]MYSQL_SET_CHARSET_DIR\f[R], \f[CR]MYSQL_OPT_SSL_CIPHER\f[R], \f[CR]MYSQL_SHARED_MEMORY_BASE_NAME\f[R], \f[CR]MYSQL_PLUGIN_DIR\f[R], \f[CR]MYSQL_DEFAULT_AUTH\f[R], \f[CR]MARIADB_OPT_SSL_FP\f[R], \f[CR]MARIADB_OPT_SSL_FP_LIST\f[R], \f[CR]MARIADB_OPT_TLS_PASSPHRASE\f[R], \f[CR]MARIADB_OPT_TLS_VERSION\f[R], \f[CR]MYSQL_OPT_BIND\f[R], \f[CR]MYSQL_OPT_CONNECT_ATTR_DELETE\f[R], \f[CR]MYSQL_OPT_CONNECT_ATTR_ADD\f[R], \f[CR]MARIADB_OPT_CONNECTION_HANDLER\f[R], \f[CR]MYSQL_SERVER_PUBLIC_KEY\f[R], \f[CR]MARIADB_OPT_RESTRICTED_AUTH\f[R] T} T{ \f[CR]const char*, unsigned int\f[R] T}@T{ \f[CR]MARIADB_OPT_RPL_REGISTER_REPLICA\f[R] T} T{ \- T}@T{ \f[CR]MYSQL_OPT_CONNECT_ATTR_RESET\f[R] T} T{ void * T}@T{ \f[CR]MARIADB_OPT_PROXY_HEADER\f[R] T} .TE .IP \[bu] 2 \f[CR]MYSQL_OPT_SSL_ENFORCE\f[R] .PD 0 .P .PD Enable or disable TLS. This option can be used to enable TLS without having to provide TLS certificates, keys or CAs. .PD 0 .P .PD \f[B]Note\f[R]: currenty this does not enforce TLS like the option name would suggest. If the server does not support TLS, the protocol will fall back to unencrypted communication. To enforce the use of TLS, use \f[CR]MYSQL_OPT_SSL_VERIFY_SERVER_CERT\f[R] instead. .IP \[bu] 2 \f[CR]MYSQL_INIT_COMMAND\f[R] .PD 0 .P .PD Command(s) which will be executed when connecting and reconnecting to the server. .IP \[bu] 2 \f[CR]MYSQL_OPT_COMPRESS\f[R] .PD 0 .P .PD Use the compressed protocol for client server communication. If the server doesn\[cq]t support compressed protocol, the default protocol will be used. .IP \[bu] 2 \f[CR]MYSQL_OPT_CONNECT_TIMEOUT\f[R] .PD 0 .P .PD Connect timeout in seconds. This value will be passed as an unsigned ##int## parameter. .IP \[bu] 2 \f[CR]MYSQL_OPT_LOCAL_INFILE\f[R] .PD 0 .P .PD Enable or disable the use of \f[CR]LOAD DATA LOCAL INFILE\f[R] .IP \[bu] 2 \f[CR]MYSQL_OPT_NAMED_PIPE\f[R] .PD 0 .P .PD For Windows operating systems only: Use named pipes for client/server communication. .IP \[bu] 2 \f[CR]MYSQL_PROGRESS_CALLBACK\f[R] .PD 0 .P .PD Specifies a callback function which will be able to visualize the progress of certain long running statements (i.e.\ \f[CR]LOAD DATA LOCAL INFILE\f[R] or \f[CR]ALTER TABLE\f[R]). The callback function must be defined as followed: .IP .EX 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))) .EE .IP \[bu] 2 \f[CR]MYSQL_OPT_PROTOCOL\f[R] .PD 0 .P .PD Specify the type of client/server protocol. Possible values are: \f[CR]MYSQL_PROTOCOL_TCP\f[R], \f[CR]MYSQL_PROTOCOL_SOCKET\f[R], \f[CR]MYSQL_PROTOCOL_PIPE\f[R] and \f[CR]MYSQL_PROTOCOL_MEMORY\f[R]. .IP \[bu] 2 \f[CR]MYSQL_OPT_RECONNECT\f[R] .PD 0 .P .PD Enable or disable automatic reconnect. .IP \[bu] 2 \f[CR]MYSQL_OPT_READ_TIMEOUT\f[R] .PD 0 .P .PD Specifies the timeout in seconds for reading packets from the server. .IP \[bu] 2 \f[CR]MYSQL_OPT_WRITE_TIMEOUT\f[R] .PD 0 .P .PD Specifies the timeout in seconds for sending packets to the server. .IP \[bu] 2 \f[CR]MYSQL_READ_DEFAULT_FILE\f[R] .PD 0 .P .PD Read options from the specified configuration file. If an empty string is passed, the default configuration files (such as /etc/my.cnf, /etc/mysql/my.cnf) will be read. By default, configuration files are not processed unless this option is specified. .IP \[bu] 2 \f[CR]MYSQL_READ_DEFAULT_GROUP\f[R] Read options from the specified group within the default configuration file or the file specified by MYSQL_READ_DEFAULT_FILE. Passing an empty string will result in all sections being processed. If no specific file is provided via MYSQL_READ_DEFAULT_FILE, all available default configuration files will be considered. .RS 2 .PP \f[B]Note:\f[R] In addition to a specified group the following groups will be always processed: .IP \[bu] 2 [client] .IP \[bu] 2 [client\-server] .IP \[bu] 2 [client\-mariadb] .RE .IP \[bu] 2 \f[CR]MYSQL_REPORT_DATA_TRUNCATION\f[R] .PD 0 .P .PD Enable or disable reporting data truncation errors for prepared statements. .IP \[bu] 2 \f[CR]MYSQL_OPT_BIND\f[R] .PD 0 .P .PD Specify the network interface from which to connect to MariaDB Server. .IP \[bu] 2 \f[CR]MYSQL_PLUGIN_DIR\f[R] .PD 0 .P .PD Specify the location of client plugins. .IP \[bu] 2 \f[CR]MYSQL_OPT_NONBLOCK\f[R] .PD 0 .P .PD 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. .IP \[bu] 2 \f[CR]MYSQL_OPT_NET_BUFFER_LENGTH\f[R] .PD 0 .P .PD Initial network buffer size in bytes. The default value is 16777216 (16MiB). .IP \[bu] 2 \f[CR]MYSQL_OPT_MAX_ALLOWED_PACKET\f[R] .PD 0 .P .PD Maximum allowed packet length. The default value is 1073741824 (1GiB) on the client side. If the limit is exceeded by a packet sent by the server, an error is generated. .IP \[bu] 2 \f[CR]MARIADB_OPT_CONNECTION_HANDLER\f[R] .PD 0 .P .PD Specify the name of a connection handler plugin. .IP \[bu] 2 \f[CR]MARIADB_OPT_USERDATA\f[R] .PD 0 .P .PD 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: .IP .EX mysql_optionsv(mysql, MARIADB_OPT_USERDATA, (void *)\[dq]my_key\[dq], (void *)value); .EE .IP \[bu] 2 \f[CR]MARIADB_OPT_CONNECTION_READ_ONLY\f[R] .PD 0 .P .PD This option is used by connection handler plugins and indicates that the current connection will be used for read operations only. .IP \[bu] 2 \f[CR]MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS\f[R] .PD 0 .P .PD If this option is set, the client indicates that it will be able to handle expired passwords by setting the \f[CR]CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS\f[R] capability flag. If the password has expired and \f[CR]CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS\f[R] 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 (\f[CR]ER_MUST_CHANGE_PASSWORD\f[R]) unless a new password was set. This option was added in MariaDB Connector/C 3.0.4 .IP \[bu] 2 \f[CR]MARIADB_OPT_STATUS_CALLBACK\f[R] .PD 0 .P .PD Specifies a callback function which will be called whenever the server status changes or the server sent session_track information to the client: .IP .EX mysql_optionsv(mysql, MARIADB_OPT_STATUS_CALLBACK, function, data) .EE .PP The callback function must be defined as follows: .IP .EX void status_callback(void *data, \f[B]enum\f[R] enum_mariadb_status_info type, ..) .EE .PP Parameters: .IP .EX \- data Pointer passed with registration of callback function (usually a connection handle) \- type Information type STATUS_TYPE or SESSION_TRACK_TYPE .EE .PP Variadic Parameters: .IP .EX if (type == STATUS_TYPE): \- server status (unsigned int) if (type == SESSION_TRACK_TYPE) \- enum enum_session_state_type track_type \- session track type if (track_type == SESSION_TRACK_SYSTEM_VARIABLES) \- MARIADB_CONST_STRING *key \- MARIADB_CONST_STRING *value else \- MARIADB_CONST_STRING *value .EE .PP \[ga] Note: Specifying a callback function overwrites the internal session tracking function, so API functions mysql_session_track_get_first()/next() can\[cq]t be used. .PP An example can be found in unittest/libmariadb/connection.c (test_status_callback) .PP Addid in version 3.3.2 .IP \[bu] 2 \f[CR]MARIADB_OPT_SKIP_READ_RESPONSE\f[R] .PD 0 .P .PD Don\[cq]t read response packets in binary protocol. .PP Added in version 3.1.13 .SS Replication/Binlog API options .IP \[bu] 2 \f[CR]MARIADB_OPT_RPL_REGISTER_REPLICA\f[R] .PD 0 .P .PD Specifies host name and port for Binlog/API. When this option was set, rpl_open() will register replica with server_id, host and port to the connected server. This information can be retrieved by \f[CR]SHOW SLAVE STATUS\f[R] command. This option was added in version 3.3.1 .SS TLS/SSL and Security options .IP \[bu] 2 \f[CR]MYSQL_OPT_SSL_KEY\f[R] .PD 0 .P .PD 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 \f[CR]MARIADB_OPT_PASSPHRASE\f[R] option. .IP \[bu] 2 \f[CR]MYSQL_OPT_SSL_CERT\f[R] .PD 0 .P .PD Specify the name of a certificate for a secure connection. .IP \[bu] 2 \f[CR]MYSQL_OPT_SSL_CA\f[R] .PD 0 .P .PD Specify the name of a file which contains one or more trusted CAs. .IP \[bu] 2 \f[CR]MYSQL_OPT_SSL_CAPATH\f[R] .PD 0 .P .PD Specify the path which contains trusted CAs. .IP \[bu] 2 \f[CR]MYSQL_OPT_SSL_CIPHER\f[R] .PD 0 .P .PD 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. .IP \[bu] 2 \f[CR]MYSQL_OPT_SSL_CRL\f[R] .PD 0 .P .PD Specify a file with a certificate revocation list. .IP \[bu] 2 \f[CR]MYSQL_OPT_SSL_CRLPATH\f[R] .PD 0 .P .PD Specify a directory with contains files with certificate revocation lists. .IP \[bu] 2 \f[CR]MARIADB_OPT_SSL_FP\f[R] .PD 0 .P .PD Specify the fingerprint hash of a server certificate for validation during the TLS handshake. For versions prior to 3.4.0 the hash is a SHA1 hash, for versions 3.4.0 and newer SHA256,SHA384 or SHA512. .IP \[bu] 2 \f[CR]MARIADB_OPT_SSL_FP_LIST\f[R] .PD 0 .P .PD Specify a file which contains one or more fingerprint hashes of server certificates for validation during the TLS handshake. For versions prior to 3.4.0 the hash is a SHA1 hash, for versions 3.4.0 and newer SHA256,SHA384 or SHA512. .IP \[bu] 2 \f[CR]MARIADB_OPT_SSL_PASPHRASE\f[R] .PD 0 .P .PD Specify a passphrase for a passphrase protected client key. .IP \[bu] 2 \f[CR]MYSQL_OPT_SSL_VERIFY_SERVER_CERT\f[R] .PD 0 .P .PD Enable (or disable) the verification of the host name against common name (CN) of the server\[cq]s host certificate. .IP \[bu] 2 \f[CR]MYSQL_SERVER_PUBLIC_KEY\f[R] .PD 0 .P .PD 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 .IP \[bu] 2 \f[CR]MARIADB_OPT_TLS_CIPHER_STRENGTH\f[R] .PD 0 .P .PD This option is not in use anymore. .IP \[bu] 2 \f[CR]MARIADB_OPT_RESTRICTED_AUTH\f[R] .PD 0 .P .PD Specifies one or more comma separated authentication plugins which are allowed for authentication. If the database server asks for an authentication plugin not listed in this option, MariaDB Connector/C will return an error. This option was added in MariaDB Connector/C 3.3.0 .SS Proxy settings As per the proxy protocol specification, the connecting client can prefix its first packet with a proxy protocol header. The server will parse the header and assume the client\[cq]s IP address is the one set in the proxy header. * \f[CR]MARIADB_OPT_PROXY_HEADER\f[R] \- specifies the proxy header which will be prefixed to the first packet. Parameters are void * for the prefix buffer and size_t for length of the buffer: .IP .EX const char *hdr=\[dq]PROXY TCP4 192.168.0.1 192.168.0.11 56324 443\[rs]r\[rs]n\[dq]; mysql_optionsv(mysql, MARIADB_OPT_PROXY_HEADER, hdr, strlen(hdr)); .EE .SS Connection Attributes Connection attributes are stored in the \f[CR]session_connect_attrs\f[R] and \f[CR]session_account_connect_attrs\f[R]Performance Schema tables. By default, MariaDB Connector/C sends the following connection attributes to the server: * \f[CR]_client_name\f[R]: always \[lq]libmariadb\[rq] * \f[CR]_client_version\f[R]: version of MariaDB Connector/C * \f[CR]_os\f[R]: operation system * _pid: process id * \f[CR]_platform\f[R]: e.g.\ x86 or x64 * \f[CR]_server_host\f[R]: the host name (as specified in mysql_real_connect). This attribute was added in Connector/C 3.0.5 .PP \f[B]Note:\f[R] If the Performance Schema is disabled, connection attributes will not be stored on server. .IP \[bu] 2 \f[CR]MYSQL_OPT_CONNECT_ATTR_DELETE\f[R] .PD 0 .P .PD Deletes a connection attribute for the given key. .IP \[bu] 2 \f[CR]MYSQL_OPT_CONNECT_ATTR_ADD\f[R] .PD 0 .P .PD Adds a key/value pair to connection attributes. The total length of the stored connection attributes is limited to a maximum of 65535 bytes. .IP \[bu] 2 \f[CR]MYSQL_OPT_CONNECT_ATTR_RESET\f[R] .PD 0 .P .PD Clears the current list of connection attributes. .SS See Also \f[I]\f[BI]mysql_init(3)\f[I] \f[R]\f[B]mysql_real_connect(3)\f[R]