You are here : cpp0mysql_options4

mysql_options4() - 0

 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.mysql_options4()mysql_options4()mysql_options()mysql_options()The following list describes the permitted options, their
        effect, and how arg1 and
        arg2 are used.arg1arg2MYSQL_OPT_CONNECT_ATTR_ADD (argument
            types: char *, char *)
          
            This option adds an attribute 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 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 application programs. This
            convention permits new attributes to be introduced by MySQL
            without colliding with application attributes.
          
mysql_options4() imposes a
            limit of 64KB on the aggregate size of connection attribute
            data it will accept. For calls that cause this limit to be
            exceeded, a
            CR_INVALID_PARAMETER_NO
            error occurs. Attribute size-limit checks also occur on the
            server side. For details, see
            Section 23.9.9, “Performance Schema Connection Attribute Tables”,
            which also describes how the Performance Schema exposes
            connection attributes through the
            session_connect_attrs and
            session_account_connect_attrs
            tables.
          
            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.MYSQL_OPT_CONNECT_ATTR_ADD (argument
            types: char *, char *)
          
            This option adds an attribute 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 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 application programs. This
            convention permits new attributes to be introduced by MySQL
            without colliding with application attributes.
          
mysql_options4() imposes a
            limit of 64KB on the aggregate size of connection attribute
            data it will accept. For calls that cause this limit to be
            exceeded, a
            CR_INVALID_PARAMETER_NO
            error occurs. Attribute size-limit checks also occur on the
            server side. For details, see
            Section 23.9.9, “Performance Schema Connection Attribute Tables”,
            which also describes how the Performance Schema exposes
            connection attributes through the
            session_connect_attrs and
            session_account_connect_attrs
            tables.
          
            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.MYSQL_OPT_CONNECT_ATTR_ADD (argument
            types: char *, char *)
          
            This option adds an attribute 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 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 application programs. This
            convention permits new attributes to be introduced by MySQL
            without colliding with application attributes.
          
mysql_options4() imposes a
            limit of 64KB on the aggregate size of connection attribute
            data it will accept. For calls that cause this limit to be
            exceeded, a
            CR_INVALID_PARAMETER_NO
            error occurs. Attribute size-limit checks also occur on the
            server side. For details, see
            Section 23.9.9, “Performance Schema Connection Attribute Tables”,
            which also describes how the Performance Schema exposes
            connection attributes through the
            session_connect_attrs and
            session_account_connect_attrs
            tables.
          
            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.MYSQL_OPT_CONNECT_ATTR_ADD (argument
            types: char *, char *)MYSQL_OPT_CONNECT_ATTR_ADDchar *, char *This option adds an attribute 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 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 application programs. This
            convention permits new attributes to be introduced by MySQL
            without colliding with application attributes._mysql_options4() imposes a
            limit of 64KB on the aggregate size of connection attribute
            data it will accept. For calls that cause this limit to be
            exceeded, a
            CR_INVALID_PARAMETER_NO
            error occurs. Attribute size-limit checks also occur on the
            server side. For details, see
            Section 23.9.9, “Performance Schema Connection Attribute Tables”,
            which also describes how the Performance Schema exposes
            connection attributes through the
            session_connect_attrs and
            session_account_connect_attrs
            tables.mysql_options4()mysql_options4()CR_INVALID_PARAMETER_NOCR_INVALID_PARAMETER_NOSection 23.9.9, “Performance Schema Connection Attribute Tables”session_connect_attrssession_connect_attrssession_account_connect_attrssession_account_connect_attrsSee also the descriptions for the
            MYSQL_OPT_CONNECT_ATTR_RESET
MYSQL_OPT_CONNECT_ATTR_DELETE options in
            the description of the
            mysql_options() function.MYSQL_OPT_CONNECT_ATTR_RESETMYSQL_OPT_CONNECT_ATTR_DELETEmysql_options()mysql_options()


Syntax

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


Example

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));
}


Output / Return Value

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


Limitations


Alternatives / See Also


Reference