mysql_send_query(3)

πŸ“¦
version 13.0.2 Β· 5 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

✨ NAME ✨

mysql_send_query β€” bestie, this one fires off a SQL statement and then dips before the server even answers πŸ’… no waiting around, no resultset, just vibes and a promise

(it's a page from the MariaDB Connector/C manual, if you were wondering who wrote this banger)


🌸 SYNOPSIS 🌸

#include <mysql.h>

int mysql_send_query(MYSQL * mysql,
                     const char *query,
                     unsigned long length);

πŸ’– DESCRIPTION πŸ’–

Okay so here's the tea: mysql_send_query sends a statement to the server and then literally does not wait for the Server OK packet and/or the resultset to come back. She said "sent πŸ’Œ" and moved on with her life. That's the whole personality.


πŸŽ€ PARAMETERS πŸŽ€

  • mysql β€” a mysql handle 🫢 the one you already got from mysql_init(3) and then connected with mysql_real_connect(3). Can't skip those steps, she needs a real connection to talk to.
  • query β€” the SQL statement itself. The whole reason we're here ✨
  • length β€” how long that SQL statement is. Yes, you have to tell her. She's not counting for you.

πŸ¦‹ NOTES πŸ¦‹

  • The OK packet and the result set package? Those don't just appear, bestie β€” you have to go get them yourself using the mysql_read_query_result(3) function. She sends, you retrieve. Teamwork 🫢
  • mysql_send_query() can be used for semi asynchronous operation. And like, yes, the function itself is blocking 😭, but an event driven application can go do other tasks in the meantime until the result set is available. Multitasking queen behavior πŸ‘‘

🌈 EXAMPLE 🌈

Wanna see how mysql_send_query() plays out in an event driven model? Then go read Jan Kneschke's article, β€œAsync MySQL Queries with C-API”. It's the blueprint, fr fr πŸ“–βœ¨


πŸ‘‘ SEE ALSO πŸ‘‘

  • mysql_real_query
  • mysql_read_query_result

Version 3.4 β€” yeah that's the one, that's the version πŸ’– and with that, this little mysql_send_query(3) page is a wrap. Stay async, stay iconic, and go read your result sets, bestie πŸŽ€πŸ¦‹βœ¨

πŸ“¦ where this page comes from