mysql_stmt_init(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_init πŸ’–

okay so bestie, welcome to the MariaDB Connector/C section of the manual, page mysql_stmt_init(3), and honestly? this one's a lil gateway drug. it's giving "before anything else can happen, we gotta make the thing exist." ✨


🌸 NAME 🌸

mysql_stmt_init β€” initializes a prepared statement handle πŸŽ€


✨ SYNOPSIS ✨

#include <mysql.h>

MYSQL_STMT * mysql_stmt_init(MYSQL * mysql);

πŸ’… DESCRIPTION πŸ’…

So what does it do, you ask? It initializes and allocates memory for a prepared statement. That's it, that's the whole vibe. You're basically handing the universe a lil blank canvas for a statement, and the universe (malloc, king) is like "say less." 🫢


πŸ¦‹ PARAMETER πŸ¦‹

  • mysql β€” a mysql handle, which was previously allocated by mysql_init(3) and connected by mysql_real_connect(3). like, it has to be a real handle that's already been init'd AND connected. no shortcuts, no "I'll connect later", she needs to be ready. 😌

πŸ‘‘ RETURN VALUE πŸ‘‘

It returns a pointer to a MYSQL_STMT structure β€” slay, iconic, we love a successful allocation. πŸ’–

Or it returns NULL if an error occurred. 😭 and if you get NULL, do NOT proceed, bestie. check that. periodt.


🌈 NOTES 🌈

  • Members of the MYSQL_STMT structure are not intended for application use. like, don't touch. it's giving "look but don't touch" but honestly also "don't even look." πŸš«πŸ‘€
  • A statement handle which was allocated by mysql_stmt_init() needs to be freed with mysql_stmt_close(3). no cap. if you don't free it, that's a leak, and leaks are not the vibe. 🫠
  • Any subsequent calls to any mysql_stmt function will fail until mysql_stmt_prepare(3) was called. read that again bestie. any of them. will fail. you gotta mysql_stmt_prepare(3) first or the whole thing is a no-op situation. πŸ’€

πŸŽ€ SEE ALSO πŸŽ€


Version 3.4 of the MariaDB Connector/C manual, babes. that's the whole page, hope it ate, now go free your statement handles and hydrate πŸ’§ mwah πŸ’‹

πŸ“¦ where this page comes from