mysql_stmt_fetch(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_fetch(3) β€” the MariaDB Connector/C one, bestie

okay so. welcome to mysql_stmt_fetch, a manual page from the MariaDB Connector/C crew (version 3.4, if you were wondering πŸ‘‘). pull up a chair, we're fetching rows out here.


✨ NAME ✨

mysql_stmt_fetch β€” fetches a result set row from a prepared statement. yes. that's the whole job. she's got one task and she ate πŸ’…


🌸 SYNOPSIS 🌸

#include <mysql.h>

int mysql_stmt_fetch(MYSQL_STMT * stmt);

πŸ¦‹ DESCRIPTION πŸ¦‹

so what she does is: fetch the result from a prepared statement, and drop it straight into the buffer you already bound with mysql_stmt_bind_result(). that's it, that's the vibe β€” you bound the buffers, she fills them.

lowkey the whole relationship is: you set up the bindings, she hands you the data. iconic duo behavior 🫢


πŸŽ€ PARAMETER πŸŽ€

  • stmt β€” a statement handle. and not just any handle, bestie, it's one that was previously allocated by mysql_stmt_init(3). no hand-wavy "some handle", we need the real one that came out of init. periodt.

⭐ RETURN VALUE ⭐

here's the scoreboard, no cap:

  • returns 0 for success πŸŽ‰
  • returns MYSQL_NO_DATA if the end of the result set has been reached (that's the "we're done here, go home" signal πŸ’€)
  • returns MYSQL_DATA_TRUNCATION if one or more values are truncated (translation: something got cut off, and she's telling you 😭)

πŸ’… NOTES πŸ’…

  • note that all columns must be bound by the application before calling mysql_stmt_fetch(). all of them. every single one. not "most of them". bind first, fetch after. that's the order, i don't make the rules 🌈
  • data are transferred unbuffered, without calling mysql_stmt_store_result(3) β€” which can decrease performance, but it reduces memory cost. so like, it's giving tradeoff energy. pick your fighter.
  • truncation reporting must be enabled by the function mysql_optionsv(3), with the option MYSQL_REPORT_DATA_TRUNCATION. if you want to know about truncation, you gotta turn the reporting on first, fr fr. πŸ™ˆ

πŸ‘‘ SEE ALSO πŸ‘‘


ok real talk: if you skipped the bind step, none of this works. bind your columns. that's the main character move.

and that's the page, bestie ✨ this was mysql_stmt_fetch(3) from the MariaDB Connector/C manual, version 3.4. go fetch some rows responsibly, ily, bye πŸŽ€πŸ’œ

πŸ“¦ where this page comes from