You can call the mysql_options4() function to set extra connect options and affect the behavior for a connection.
Syntax
int
mysql_options4(MYSQL *mysql,
enum mysql_option option,
const void *arg1,
const void *arg2)
Return values
0 is returned for an execution success, and a non-zero value is returned if an unknown option is specified.
Errors
CR_DUPLICATE_CONNECTION_ATTR: A duplicate attribute name was specified.CR_INVALID_PARAMETER_NO: A key name was empty or the amount of key-value connection attribute data exceeds the limit of 64 KB.CR_OUT_OF_MEMORY: The memory is insufficient.
Notes
mysql_options4() is similar to mysql_options() but it has an extra fourth argument so that two values can be passed for the option specified in the second argument.
The available option for mysql_options4() is MYSQL_OPT_CONNECT_ATTR_ADD (argument type: char *, char *). The following list describes how to use this option and the arg1 and arg2 arguments.
This option adds an attribute key-value pair to the current set of connection attributes to pass to the server when the connection is created. Both arguments are pointers to null-terminated strings. The first and second strings indicate the key and value respectively. If the key is empty or already exists in the current set of connection attributes, an error occurs. Comparison of the key name with existing keys is case-sensitive.
Key names that begin with an underscore (_) are reserved for internal use and should not be created by applications. This convention allows OceanBase to introduce new attributes without conflicting with application attributes.
mysql_options4()has a limit of 64 KB on the aggregate size of connection attribute data that it accepts. For calls that cause this limit to be exceeded, aCR_INVALID_PARAMETER_NOerror occurs. Attribute size-limit checks also occur on the server side.