mariadb_reconnect(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

πŸ’– mariadb_reconnect β€” reconnects to a server πŸ’–

okay bestie, welcome to mariadb_reconnect(3) from the MariaDB Connector/C manual, and no cap this one is lowkey a lifesaver when your connection just… ghosts you. let's get into it 🫢


✨ Name ✨

mariadb_reconnect β€” reconnects to a server πŸ”Œ


🌸 Synopsis 🌸

#include <mysql.h>

my_bool  mariadb_reconnect(MYSQL * mysql)

πŸ¦‹ Description πŸ¦‹

so like, mariadb_reconnect() tries to reconnect to a server in case the connection died β€” think timeout or literally any other error that yeeted your session into the void 😭. the way that it does this is it reuses the same credentials you already specified over in mysql_real_connect(3), so you don't have to re-type anything. it's giving "we're so back" energy πŸ’…


πŸŽ€ Return value πŸŽ€

  • the function returns 0 on success βœ…
  • and a non-zero value on error πŸ’€
note: it will return an error if the option MYSQL_OPT_RECONNECT wasn't set before. so fr fr, set that option first or this whole thing is not it πŸ™ˆ

πŸ‘‘ History πŸ‘‘

mariadb_reconnect() was added in MariaDB Connector/C 3.0 ⭐ she's an icon, she's a legend, and she is the moment.


🌈 See also 🌈


that's the whole page, bestie β€” go forth and reconnect slayfully πŸ§šπŸ’œ

Version 3.4 of the MariaDB Connector/C docs, and yes mariadb_reconnect(3) is the main character of this page πŸŽ€βœ¨ mwah, bye! πŸ’–

πŸ“¦ where this page comes from