mysql_stmt_close(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_stmt_close(3) πŸ’–

okay bestie, welcome to the MariaDB Connector/C manual β€” this one's all about putting your prepared statement to bed πŸ›οΈβœ¨


🌸 Name 🌸

mysql_stmt_close β€” closes a prepared statement. that's it, that's the whole vibe. it's the goodbye function 🫢


✨ Synopsis ✨

#include <mysql.h>

my_bool mysql_stmt_close(MYSQL_STMT * stmt);

look at that signature. clean. iconic. no notes. πŸ’…


πŸŽ€ Description πŸŽ€

so like, this function closes a prepared statement and deallocates the statement handle. meaning: once you call it, that handle is gone, deceased, no longer with us, we said our goodbyes πŸ¦‹

and here's the part that's lowkey important β€” if the current statement has pending or unread results, this function cancels them so that the next query can be executed. so it's not just a polite wave, it's a full cleanup. the leftovers get swept, the runway is clear, and your next query can take off ✈️✨


πŸ“ Parameter πŸ“

  • stmt β€” a statement handle, which was previously allocated by mysql_stmt_init(3). like, this has to be a handle that mysql_stmt_init(3) made for you. you can't just bring a random pointer to the function and expect it to slay πŸ’€

🌈 Return value 🌈

  • Returns zero on success βœ…
  • nonzero on error β€” specifically when communicating with the server 😭

and here's the caveat, bestie, so listen up: the statement is deallocated, regardless of the error. so even if the server comms go sideways, that handle is still gone. don't go reusing it afterward, it's not coming back πŸ’€


πŸ¦‹ Notes πŸ¦‹

  • If you want to reuse the statement handle with a different SQL command, use mysql_stmt_reset(3) β€” that's the refresh button, this function is the close tab button. know the difference, it's giving main character energy ✨

πŸ‘‘ See Also πŸ‘‘


and that's the whole page, bestie!! this was Version 3.4 of the MariaDB Connector/C manual, so if you ever need to cite it: version 3.4, mysql_stmt_close(3), MariaDB Connector/C πŸŽ€ now go forth and close your statements responsibly, iykyk πŸ’–πŸŒΈβœ¨

πŸ“¦ where this page comes from