25.2.3.48. mysql_options()
int mysql_options(MYSQL *mysql, enum mysql_option
option, const char *arg)
Description
Can be used to set extra connect options and affect behavior
for a connection. This function may be called multiple times
to set several options.
mysql_options()
should be called after
mysql_init()
and before
mysql_connect()
or
mysql_real_connect()
.
The option
argument is the option that you
want to set; the arg
argument is the value
for the option. If the option is an integer, then
arg
should point to the value of the
integer.
Possible option values:
Note that the client
group is always read
if you use MYSQL_READ_DEFAULT_FILE
or
MYSQL_READ_DEFAULT_GROUP
.
The specified group in the option file may contain the
following options:
Note that timeout
has been replaced by
connect-timeout
, but
timeout
is still supported in MySQL
5.1.7-beta for backward compatibility.
For more information about option files, see
Section 4.3.2, “Using Option Files”.
Return Values
Zero for success. Non-zero if you used an unknown option.
Example
MYSQL mysql;
mysql_init(&mysql);
mysql_options(&mysql,MYSQL_OPT_COMPRESS,0);
mysql_options(&mysql,MYSQL_READ_DEFAULT_GROUP,"odbc");
if (!mysql_real_connect(&mysql,"host","user","passwd","database",0,NULL,0))
{
fprintf(stderr, "Failed to connect to database: Error: %s\n",
mysql_error(&mysql));
}
This code requests the client to use the compressed
client/server protocol and read the additional options from
the odbc
section in the
my.cnf
file.