mysql_reset_connection(3)

πŸ“¦
version 13.0.2 Β· 4 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 ✨

mysql_reset_connection β€” resets the connection and clears all the session state, bestie πŸ’…

(this one lives in the MariaDB Connector/C manual, page mysql_reset_connection(3), and it's giving "factory reset but make it chill")


🌸 Synopsis 🌸

#include <mysql.h>

int mysql_reset_connection(MYSQL * mysql);

πŸ¦‹ Description πŸ¦‹

Okay so picture this: your connection is a whole mess, but you don't wanna hang up and call back. That's literally what mysql_reset_connection() is for. It resets the current connection and clears the session state. It's similar to mysql_change_user(3) or mariadb_reconnect(3) β€” it resets session status, but here's the slay part: it does it without disconnecting, without opening, and without reauthenticating. No goodbye, no awkward reintroduction. Just a clean slate. periodt ✨

So what's actually getting wiped? Let's do a vibe check on the client side first. mysql_reset_connection():

  • clears pending or unprocessed result sets 🧹
  • clears status like affected_rows, info or last_insert_id πŸ’€
  • invalidates active prepared statements

And now the server side, because she does the work on both ends, no cap:

  • drops temporary table(s)
  • rollbacks active transaction
  • resets autocommit mode
  • releases table locks
  • initializes session variables (and sets them to the value of corresponding global variables)
  • closes active prepared statements
  • clears user variables
Heads up bestie: that's a LOT of state going poof. If you had a transaction in flight, it's getting rolled back, and those temp tables are not coming back. Read the list twice before you call her. 😭

πŸŽ€ Parameter πŸŽ€


πŸ‘‘ Return value πŸ‘‘

Returns zero on success, non zero if an error occurred. Simple as. If you get a zero, she ate. πŸ”₯


🌈 History 🌈

This function was added in MariaDB Connector/C 3.0.0. Baby's been around a minute. ⭐


πŸ’œ See also πŸ’œ


And that's the whole page, no notes. This was Version 3.4 of the MariaDB Connector/C docs, and yes the page is literally named mysql_reset_connection(3) β€” go forth and reset responsibly, you main character. πŸŽ€πŸ’–βœ¨

πŸ“¦ where this page comes from