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

πŸ’… mariadb_cancel β€” the "girl, we're SO done here" function πŸ’…

okay bestie, welcome to mariadb_cancel(3) from the MariaDB Connector/C manual. yes we're in section 3, yes it's a library call, and yes it's about to make some queries ✨ regret everything ✨


πŸŽ€ Name πŸŽ€

mariadb_cancel β€” immediately aborts a connection. like, no goodbye text, no "we need to talk", just blocked πŸ’€


✨ Synopsis ✨

#include <mysql.h>

int mariadb_cancel(MYSQL * mysql);

that's it. that's the whole vibe. one include, one function call, one very dramatic exit πŸšͺπŸ’¨


🌸 Description 🌸

okay so here's the tea, bestie πŸ“

mariadb_cancel() immediately aborts a connection by making all subsequent read/write operations fail. it's giving "blocked and deleted", it's giving "this conversation is over", it's giving main character exit. every read and every write after this? failed. done. not happening. πŸ’…

BUT β€” and this is the important part, so listen up πŸ™ˆ β€” mariadb_cancel() does not invalidate the memory used for the mysql structure, and it does not close any communication channels. so the memory is still sitting there, being a lil freeloader, and the channels are still open. iconic of them honestly.

so if you actually wanna free that memory? you gotta call mysql_close(3). no cap. mariadb_cancel() is not the cleanup girl, she's the intervention girl.

and the way that mariadb_cancel() is useful is to break long queries in situations where sending KILL is not possible. like when KILL isn't even an option and you're just sitting there watching a query take forever, and you're like "bestie i cannot do this anymore". that's the moment. that's the function. 🫢


πŸ¦‹ Parameter πŸ¦‹

  • mysql β€” the mysql handle πŸŽ€ this lil guy was previously allocated by mysql_init(3) and connected by mysql_real_connect(3). so like, it's already had a whole journey before it gets here.

⭐ Return value ⭐

  • Returns zero on success πŸŽ‰
  • Returns a non-zero value on error 😭

that's the whole vibe check. zero = slay. non-zero = not slay.


πŸ‘‘ History πŸ‘‘

mariadb_cancel() was added in Connector/C 3.0. so she's not ancient, she's just ✨ established ✨


real talk though bestie: aborting a connection is a big deal. subsequent reads and writes will fail, and the memory is NOT freed until you call mysql_close(3). don't forget her, she's waiting πŸ’œ

Version 3.4 πŸŽ€ mariadb_cancel(3) πŸŽ€ and that's the whole page, bestie β€” go abort something (responsibly) πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from