Documentation Home
MySQL 5.6 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 31.4Mb
PDF (A4) - 31.5Mb
PDF (RPM) - 30.0Mb
EPUB - 7.7Mb
HTML Download (TGZ) - 7.5Mb
HTML Download (Zip) - 7.5Mb
HTML Download (RPM) - 6.5Mb
Eclipse Doc Plugin (TGZ) - 8.2Mb
Eclipse Doc Plugin (Zip) - 10.1Mb
Man Pages (TGZ) - 181.3Kb
Man Pages (Zip) - 292.3Kb
Info (Gzip) - 2.8Mb
Info (Zip) - 2.8Mb
Excerpts from this Manual

23.8.7.50 mysql_options4()

int mysql_options4(MYSQL *mysql, enum mysql_option option, const void *arg1, const void *arg2)

Description

mysql_options4() is similar to mysql_options() but has an extra fourth argument so that two values can be passed for the option specified in the second argument. This function was added in MySQL 5.6.6.

The following list describes the permitted options, their effect, and how arg1 and arg2 are used.

  • MYSQL_OPT_CONNECT_ATTR_ADD (argument types: char *, char *)

    This option adds a key/value pair to the current set of connection attributes to pass to the server at connect time. Both arguments are pointers to null-terminated strings. The first and second strings indicate the key and value, respectively. If the key 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 used by application programs.

    See also the descriptions for the MYSQL_OPT_CONNECT_ATTR_RESET MYSQL_OPT_CONNECT_ATTR_DELETE options in the description of the mysql_options() function.

    Connection attributes are exposed through the session_connect_attrs and session_account_connect_attrs Performance Schema tables. See Section 22.9.8, “Performance Schema Connection Attribute Tables”.

Return Values

Zero for success. Nonzero if you specify an unknown option.

Example

This example demonstrates the calls that specify connection attributes:

MYSQL mysql;

mysql_init(&mysql);
mysql_options(&mysql,MYSQL_OPT_CONNECT_ATTR_RESET, 0);
mysql_options4(&mysql,MYSQL_OPT_CONNECT_ATTR_ADD, "key1", "value1");
mysql_options4(&mysql,MYSQL_OPT_CONNECT_ATTR_ADD, "key2", "value2");
mysql_options4(&mysql,MYSQL_OPT_CONNECT_ATTR_ADD, "key3", "value3");
mysql_options(&mysql,MYSQL_OPT_CONNECT_ATTR_DELETE, "key1");
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));
}
mysql_options(&mysql,MYSQL_OPT_CONNECT_ATTR_RESET, 0);

User Comments
Sign Up Login You must be logged in to post a comment.