mariadb_get_infov(3)
π NAME π
mariadb_get_infov β it grabs generic info or connection-related info for you. That's it, that's the whole job, and she does it flawlessly. This page lives in the MariaDB Connector/C manual, section 3. π
β¨ SYNOPSIS β¨
#include <mysql.h>
int mariadb_get_infov(MYSQL * mysql,
enum mariadb_value value,
void * arg,
...);
π¦ DESCRIPTION π¦
okay so bestie, this one retrieves generic or connection specific information. arg (and any further arguments after it) must be a pointer to a variable of the type that matches whatever you passed as value. Match them up wrong and it's not gonna go how you want, so let's line them up properly:
unsigned intβMARIADB_CLIENT_VERSION_ID,MARIADB_CONNECTION_ASYNC_TIMEOUT,MARIADB_CONNECTION_ASYNC_TIMEOUT_MS,MARIADB_CONNECTION_ERROR_ID,MARIADB_CONNECTION_PORT,MARIADB_CONNECTION_PROTOCOL_VERSION_ID,MARIADB_CONNECTION_PVIO_TYPE,MARIADB_CONNECTION_SERVER_STATUS,MARIADB_CONNECTION_SERVER_VERSION_ID,MARIADB_CONNECTION_TLS_VERSION_IDunsigned longβMARIADB_CONNECTION_CLIENT_CAPABILITIES,MARIADB_CONNECTION_EXTENDED_SERVER_CAPABILITIES,MARIADB_CONNECTION_SERVER_CAPABILITIESsize_tβMARIADB_MAX_ALLOWED_PACKET,MARIADB_NET_BUFFER_LENGTHconst char *βMARIADB_CLIENT_VERSION,MARIADB_TLS_LIBRARY,MARIADB_CONNECTION_ERROR,MARIADB_CONNECTION_HOST,MARIADB_CONNECTION_INFO,MARIADB_CONNECTION_SCHEMA,MARIADB_CONNECTION_SERVER_TYPE,MARIADB_CONNECTION_SERVER_VERSION,MARIADB_CONNECTION_SQLSTATE,MARIADB_CONNECTION_SSL_CIPHER,MARIADB_CONNECTION_TLS_VERSION,MARIADB_CONNECTUION_UNIX_SOCKET,MARIADB_CONNECTION_USER,const char **βMARIADB_CLIENT_ERRORSconst *MY_CHARSET_INFOβMARIADB_CHARSET_NAME,MARIADB_CONNECTION_CHARSET_INFOmy_socketβMARIADB_CONNECTION_SOCKETMARIADB_X509_INFO *βMARIADB_TLS_PEER_CERT_INFO
yes bestie,MARIADB_CONNECTUION_UNIX_SOCKETreally is spelled like that in that list, and yes,const *MY_CHARSET_INFOis exactly how it's written too. we are transcribing, not editing. π
πΈ Value types πΈ
π Generic information
For all of these, the mysql parameter needs to be set to NULL. No connection, no problem.
MARIADB_CHARSET_NAMEβ retrieves the charset information for a character set by its literal representation. it's giving "tell me about this charset by name."MARIADB_CLIENT_ERRORSβ retrieves an array of client errors. this one is for plugins, so they can set global error messages (which are not exported by MariaDB Connector/C). iykyk.MARIADB_CLIENT_VERSIONβ the client version, in literal representation.MARIADB_CLIENT_VERSION_IDβ the client version, but numeric this time.MARIADB_MAX_ALLOWED_PACKETβ retrieves the value of the maximum allowed packet size.MARIADB_NET_BUFFER_LENGTHβ retrieves the length of the net buffer.
π Connection and TLS related information
For these, mysql must represent a valid connection handle, one that was allocated by mysql_init(3). no valid handle, no info, no vibes.
MARIADB_CONNECTION_ASYNC_TIMEOUTβ retrieves the timeout for non blocking calls, in seconds.MARIADB_CONNECTION_ASYNC_TIMEOUT_MSβ retrieves the timeout for non blocking calls, in milliseconds. (same energy, smaller units β¨)MARIADB_CONNECTION_CHARSET_INFOβ retrieves character set information for the given connection.MARIADB_CONNECTION_CLIENT_CAPABILITIESβ returns the capability flags of the client.MARIADB_CONNECTION_ERRORβ retrieves the error message for the last used command.MARIADB_CONNECTION_ERROR_IDβ retrieves the error number for the last used command.MARIADB_CONNECTION_EXTENDED_SERVER_CAPABILITIESβ returns the extended capability flags of the connected MariaDB server.MARIADB_CONNECTION_HOSTβ returns the host name of the connected MariaDB server.MARIADB_CONNECTION_INFOβ retrieves generic info for the last used command.MARIADB_CONNECTION_PORTβ retrieves the port number of the server host.MARIADB_CONNECTION_PROTOCOL_VERSION_IDβ retrieves the protocol version number.MARIADB_CONNECTION_PVIO_TYPEβ retrieves the pvio plugin used for the specified connection.MARIADB_CONNECTION_SCHEMAβ retrieves the current schema.MARIADB_CONNECTION_SERVER_CAPABILITIESβ retrieves the capability flags of the connected server.MARIADB_CONNECTION_SERVER_STATUSβ returns the server status after the last operation.MARIADB_CONNECTION_SERVER_TYPEβ retrieves the type of the server.MARIADB_CONNECTION_SERVER_VERSIONβ retrieves the server version in literal format.MARIADB_CONNECTION_SERVER_VERSION_IDβ retrieves the server version in numeric format.MARIADB_CONNECTION_SOCKETβ retrieves the handle (socket) for the given connection.MARIADB_CONNECTION_SQLSTATEβ retrieves the current sqlstate information for the last used command.MARIADB_CONNECTION_SSL_CIPHERβ retrieves the TLS/SSL cipher in use.MARIADB_TLS_LIBRARYβ retrieves the name of the TLS library.MARIADB_CONNECTION_TLS_VERSIONβ retrieves the TLS protocol version used, in literal format.MARIADB_CONNECTION_TLS_VERSION_IDβ retrieves the TLS protocol version used, in numeric format.MARIADB_CONNECTION_UNIX_SOCKETβ retrieves the file name of the unix socket.MARIADB_CONNECTION_USERβ retrieves the connection's user name.MARIADB_TLS_PEER_CERT_INFOβ retrieves peer certificate information for TLS connections. the returned pointer to aMARIADB_X509_INFOstructure becomes invalid after the connection has been closed. (added in version 3.4.0) π«ΆMARIADB_TLS_VERIFY_STATUSβ retrieves the status of a previous peer certificate verification. the status is represented as a combination of TLS verification flags. this option was added in version 3.4.1.
β οΈ bestie, listen to me: that MARIADB_X509_INFO pointer goes stale the second the connection closes. do not hold onto it, do not pass it around, do not be cute with it. π
π₯ RETURNS π₯
Returns zero on success, non zero if an error occurred (like if you specified an invalid option). so like, zero is the slay outcome here. periodt.
π SOURCE FILE π
libmariadb/mariadb_lib.c
π HISTORY π
This function was added in MariaDB Connector/C 3.0. she's been iconic for a while.
β EXAMPLES β
/* get server port for current connection */
unsigned int port;
mariadb_get_infov(mysql, MARIADB_CONNECTION_PORT, (void *)&port);
/* get user name for current connection */
const char *user;
mariadb_get_infov(mysql, MARIADB_CONNECTION_USER, (void *)&user);
see how the variable type matches the value type? that's the whole bit. match the type, cast the pointer, get the info. ate. π
π§ SEE ALSO π§
mysql_get_optionv(3)
Version 3.4, from the MariaDB Connector/C era β that's a wrap bestie, go forth and retrieve information responsibly πΈππ¦
π¦ where this page comes from
- alpine 3.22: mariadb-doc 11.4.13-r0 Β· GPL-2.0-or-later
- alpine 3.23: mariadb-doc 11.4.13-r0 Β· GPL-2.0-or-later
- alpine 3.24: mariadb-doc 11.8.9-r0 Β· GPL-2.0-only
- arch rolling: mariadb 13.0.2-2 Β· GPL-2.0-only
- arch rolling: mariadb-lts 12.3.3-2 Β· GPL-2.0-only
- centos-stream 10: mariadb-connector-c-doc 3.4.4-2.el10 Β· LGPL-2.1-or-later
- debian trixie: libmariadb-dev 1:11.8.6-0+deb13u1 Β· GPL-2.0-only
- fedora 43: mariadb-connector-c-doc 3.4.5-2.fc43 Β· LGPL-2.1-or-later AND PHP-3.0 AND PHP-3.01
- fedora 43: mariadb-connector-c-doc 3.4.9-2.fc43 Β· LGPL-2.1-or-later AND PHP-3.0 AND PHP-3.01 AND LicenseRef-Fedora-Public-Domain
- fedora 44: mariadb-connector-c-doc 3.4.8-3.fc44 Β· LGPL-2.1-or-later AND PHP-3.0 AND PHP-3.01
- fedora 44: mariadb-connector-c-doc 3.4.9-2.fc44 Β· LGPL-2.1-or-later AND PHP-3.0 AND PHP-3.01 AND LicenseRef-Fedora-Public-Domain
- nixpkgs unstable: mariadb-server 11.8.8
- opensuse-leap 16.0: libmariadb-devel 3.4.9-160000.1.1 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: libmariadb-devel 3.4.9-160000.1.1 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: libmariadb-devel 3.4.9-160000.1.1 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: libmariadb-devel 3.4.9-160000.1.1 Β· LGPL-2.1-or-later
- ubuntu questing: libmariadb-dev 1:11.8.3-1build1
- ubuntu resolute: libmariadb-dev 1:11.8.6-5 Β· GPL-2.0-only
- ubuntu resolute: libmariadb-dev 1:11.8.6-5ubuntu0.1 Β· GPL-2.0-only
- ubuntu stonking: libmariadb-dev 1:11.8.9+ds-4ubuntu2 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms