Documentation Home
MySQL 9.3 C API Developer Guide
Download this Manual
PDF (US Ltr) - 1.4Mb
PDF (A4) - 1.4Mb


5.4.32 mysql_get_option()

intmysql_get_option(MYSQL *mysql,                 enum mysql_option option,                 const void *arg)

Description

Returns the current value of an option settable usingmysql_options(). The value should be treated as read only.

Theoption argument is the option for which you want its value. Thearg argument is a pointer to a variable in which to store the option value.arg must be a pointer to a variable of the type appropriate for theoption argument. The following table shows which variable type to use for eachoption value.

ForMYSQL_OPT_MAX_ALLOWED_PACKET, it is possible to set a session or global maximum buffer size, depending on whether themysql argument tomysql_options() is non-NULL orNULL,mysql_get_option() similarly returns the session or global value depending on itsmysql argument.

arg TypeApplicableoption Values
unsigned intMYSQL_OPT_CONNECT_TIMEOUT,MYSQL_OPT_PROTOCOL,MYSQL_OPT_READ_TIMEOUT,MYSQL_OPT_RETRY_COUNT,MYSQL_OPT_SSL_FIPS_MODE,MYSQL_OPT_SSL_MODE,MYSQL_OPT_WRITE_TIMEOUT,MYSQL_OPT_ZSTD_COMPRESSION_LEVEL
unsigned longMYSQL_OPT_MAX_ALLOWED_PACKET,MYSQL_OPT_NET_BUFFER_LENGTH
boolMYSQL_ENABLE_CLEARTEXT_PLUGIN,MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS,MYSQL_OPT_GET_SERVER_PUBLIC_KEY,MYSQL_OPT_LOCAL_INFILE,MYSQL_OPT_OPTIONAL_RESULTSET_METADATA,MYSQL_OPT_RECONNECT (deprecated),MYSQL_REPORT_DATA_TRUNCATION
const char *MYSQL_DEFAULT_AUTH,MYSQL_OPT_BIND,MYSQL_OPT_COMPRESSION_ALGORITHMS,MYSQL_OPT_LOAD_DATA_LOCAL_DIR,MYSQL_OPT_SSL_CA,MYSQL_OPT_SSL_CAPATH,MYSQL_OPT_SSL_CERT,MYSQL_OPT_SSL_CIPHER,MYSQL_OPT_SSL_CRL,MYSQL_OPT_SSL_CRLPATH,MYSQL_OPT_SSL_KEY,MYSQL_OPT_TLS_CIPHERSUITES,MYSQL_OPT_TLS_SNI_SERVERNAME,MYSQL_OPT_TLS_VERSION,MYSQL_PLUGIN_DIR,MYSQL_READ_DEFAULT_FILE,MYSQL_READ_DEFAULT_GROUP,MYSQL_SERVER_PUBLIC_KEY,MYSQL_SET_CHARSET_DIR,MYSQL_SET_CHARSET_NAME,MYSQL_SHARED_MEMORY_BASE_NAME
voidMYSQL_OPT_SSL_SESSION_DATA
argument not usedMYSQL_OPT_COMPRESS
cannot be queried (error is returned)MYSQL_INIT_COMMAND,MYSQL_OPT_CONNECT_ATTR_DELETE,MYSQL_OPT_CONNECT_ATTR_RESET,MYSQL_OPT_NAMED_PIPE

Return Values

Zero for success. Nonzero if an error occurred; this occurs foroption values that cannot be queried.

Example

The following call tests theMYSQL_OPT_LOCAL_INFILE option. After the call returns successfully, the value ofinfile is true or false to indicate whether local_infile is enabled.

bool infile;if (mysql_get_option(mysql, MYSQL_OPT_LOCAL_INFILE, &infile))  fprintf(stderr, "mysql_get_option() failed\n");