Syntax

int mysql_get_optionv(MYSQL * mysql,
                      enum mysql_option,
                      void * arg,
                      ...);
  • mysql - a mysql handle, which was previously allocated by mysql_init() or mysql_real_connect().
  • mysql_option - the option you want to retrieve. See description below.
  • arg - pointer to a variable for storing value of the specified option.
  • ... - variable argument list

Description

Retrieves the value for a given option which was previously set by mysql_optionsv.

Returns zero on success, non zero if an error occurred (invalid option).

This function was added in MariaDB Connector/C 3.0.0.

Options

Boolean values (my_bool)

  • MYSQL_OPT_COMPRESS
  • MYSQL_OPT_NAMED_PIPE
  • MYSQL_OPT_RECONNECT
  • MYSQL_REPORT_DATA_TRUNCATION
  • MYSQL_OPT_NONBLOCK
  • MYSQL_OPT_SSL_VERIFY_SERVER_CERT
  • MARIADB_OPT_CONNECTION_READ_ONLY
  • MYSQL_SECURE_AUTH

Integer values

  • MYSQL_OPT_CONNECT_TIMEOUT
  • MYSQL_OPT_READ_TIMEOUT
  • MYSQL_OPT_WRITE_TIMEOUT
  • MYSQL_OPT_LOCAL_INFILE
  • MYSQL_OPT_PROTOCOL

Character values

  • MYSQL_INIT_COMMAND
  • MYSQL_READ_DEFAULT_FILE
  • MYSQL_READ_DEFAULT_GROUP
  • MYSQL_SET_CHARSET_NAME
  • MYSQL_PLUGIN_DIR
  • MYSQL_OPT_SSL_KEY
  • MYSQL_OPT_SSL_CERT
  • MYSQL_OPT_SSL_CA
  • MYSQL_OPT_SSL_CAPATH
  • MYSQL_OPT_SSL_CRL
  • MYSQL_OPT_SSL_CRLPATH
  • MYSQL_OPT_SSL_CIPHER
  • MARIADB_OPT_SSL_FP
  • MARIADB_OPT_SSL_FPLIST
  • MARIADB_OPT_SSL_PASSPHRASE
  • MYSQL_DEFAULT_AUTH
  • MYSQL_OPT_BIND
  • MARIADB_OPT_CONNECTION_HANDLER

Misc

  • MYSQL_PROGRESS_CALLBACK: requires a function pointer *(const MYSQL *, uint, uint, double, const char *, uint))arg)
  • MYSQL_CONNECT_ATTRS: this option requires 5 parameters:
/* get number of connection attributes */
int i, elements= 0;
char **key, **value;

mysql_get_optionv(mysql, MYSQL_CONNECT_ATTRS, NULL, NULL, (void *)&elements);
key= (char **)malloc(sizeof(char *) * elements);
val= (char **)malloc(sizeof(char *) * elements);
mysql_get_optionv(mysql, MYSQL_OPT_CONNECT_ATTRS, &key, &val, &elements);
for (i=0; i < elements; i++)
  printf("key: %s value: %s", key[i], val[i]);
  • MARIADB_OPT_USERDATA: retrieves userdata for a given key.
const char *ssh_user;
mysql_get_optionv(mysql, MARIADB_OPT_USERDATA, "ssh_user", (void *)ssh_user);

See also

Comments

Comments loading...
Loading