mysql_reset_connection(3)
β¨ 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,infoorlast_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 π
mysqlβ a mysql handle, which was previously allocated bymysql_init(3)and connected bymysql_real_connect(3). iykyk π«Ά
π 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
- 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