mariadb_get_infov(3)

πŸ“¦
version 13.0.2 Β· 5 versions
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, debian trixie, fedora 43, fedora 44, nixpkgs unstable, opensuse-leap 16.0, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸŽ€ 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_ID
  • unsigned long β€” MARIADB_CONNECTION_CLIENT_CAPABILITIES, MARIADB_CONNECTION_EXTENDED_SERVER_CAPABILITIES, MARIADB_CONNECTION_SERVER_CAPABILITIES
  • size_t β€” MARIADB_MAX_ALLOWED_PACKET, MARIADB_NET_BUFFER_LENGTH
  • const 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_ERRORS
  • const *MY_CHARSET_INFO β€” MARIADB_CHARSET_NAME, MARIADB_CONNECTION_CHARSET_INFO
  • my_socket β€” MARIADB_CONNECTION_SOCKET
  • MARIADB_X509_INFO * β€” MARIADB_TLS_PEER_CERT_INFO
yes bestie, MARIADB_CONNECTUION_UNIX_SOCKET really is spelled like that in that list, and yes, const *MY_CHARSET_INFO is 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.

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 a MARIADB_X509_INFO structure 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