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

πŸ’… mysql_kill β€” bestie, we're ending this connection's whole career

okay so this is mysql_kill(3), straight out of the MariaDB Connector/C manual. yeah, manual section 3, the C library girlies. let's get into it πŸŽ€


✨ NAME ✨

mysql_kill β€” kills a connection. that's it. that's the whole vibe. it's giving executioner but make it a function call πŸ’€


🌸 SYNOPSIS 🌸

#include <mysql.h>

int mysql_kill(MYSQL * mysql,
               unsigned long);

yes bestie, that second param is literally just unsigned long with no name. the manual said what it said, and we're keeping it exactly. no notes 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

so basically you use this function to ask the server to kill a MariaDB thread, and you pick which thread with the processid parameter. key word: ask. the server does the actual yeeting πŸ”₯

and where do you get that processid from, you ask? you gotta retrieve it with SHOW PROCESSLIST. that's the plug. no cap.

but wait β€” if the thread you're trying to kill is your own connection? then you use mysql_thread_id(3) instead. don't be out here trying to kill yourself with the wrong function, that's embarrassing 😭


πŸ’– PARAMETER πŸ’–

  • mysql β€” a connection identifier, which was previously allocated by mysql_init(3) and connected by mysql_real_connect(3). returns 0 on success, otherwise nonzero.
  • long β€” process id. that's the one. the target. the chosen one ✨

πŸ‘‘ NOTES πŸ‘‘

  • if you just wanna stop a running command without killing the whole connection, use KILL QUERY instead. like, calm down, you don't have to end everything πŸ’…
  • lowkey important: mysql_kill() only kills a connection. it does not free any memory. none. zero. nada. you have to free that yourself, explicitly, by calling mysql_close(3). don't forget or the memory just sits there haunting you πŸ™ˆ

🌈 RETURN VALUE 🌈

returns zero on success, non zero on error. simple as that, fr fr.


πŸŽ€ SEE ALSO πŸŽ€


ok that's the whole page bestie, go forth and kill connections responsibly 🫢✨

Version 3.4 of the MariaDB Connector/C manual, babes β€” that's the source and the version, and honestly? iconic. slay πŸ’œπŸ‘‘

πŸ“¦ where this page comes from