mysql_sqlstate(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_sqlstate πŸ’–

okay so bestie, we're in the MariaDB Connector/C manual, and this one is literally so handy β€” it's mysql_sqlstate, the girl who tells you what went wrong, in that fancy five-character SQLSTATE language ✨


✨ Name ✨

mysql_sqlstate β€” returns the SQLSTATE error code πŸŽ€


✨ Synopsis ✨

#include <mysql.h>

const char * mysql_sqlstate(MYSQL * mysql);

✨ Description ✨

So here's the tea πŸ“ β€” mysql_sqlstate() hands you back a string holding the SQLSTATE error code for the most recently invoked function that can succeed or fail. That's it, that's the whole vibe.

The error code is five characters long, no more no less. And the iconique one: 00000 means no error β€” like, we're fine, we're thriving, nothing to see here πŸ’…

The values themselves are specified by ANSI SQL and ODBC. iykyk.


✨ Parameter ✨

(fr fr there's nothing listed under this heading in the original β€” the parameter lives in the synopsis above, bestie 🫢)


✨ Notes ✨

okay important thing, don't come for me: not all client library error codes are mapped to SQLSTATE errors 😭

Any error that can't be mapped gets returned as the value HY000. So if you see HY000, that's the "we don't have a cute name for this one" bucket πŸͺ£βœ¨


✨ Return value ✨

A string containing the SQLSTATE error code. periodt πŸ‘‘


✨ See also ✨


Version 3.4 β€” and that's the whole page, bestie, go forth and debug with main character energy πŸ‘‘πŸ’–βœ¨ slay πŸ¦‹

πŸ“¦ where this page comes from