mysql_stmt_attr_get(3)
β¨ mysql_stmt_attr_get β¨
okay so this is a MariaDB Connector/C page, bestie π it lives in section 3 of the manual (that's the library-call girlies, not the shell-command ones), and it's literally the read-only twin of mysql_stmt_attr_set(3). Let's get into it π«Ά
πΈ Name πΈ
mysql_stmt_attr_get β gets the current value of a statement attribute. that's it, that's the whole job π
π Synopsis π
#include <mysql.h>
my_bool mysql_stmt_attr_get(MYSQL_STMT * stmt,
enum enum_stmt_attr_type,
void * attr);
π Description π
So you've got a prepared statement, right, and it has attributes β little settings hanging off it. This function is the peek button π It reads whatever the attribute is currently set to and hands it back to you.
Returns zero on success, non-zero on failure. no cap, that's the whole return contract fr fr.
π¦ Parameter π¦
stmtβ a statement handle, which was previously allocated bymysql_stmt_init(3). like, you can't just make one up out of nowhere, it has to come from there π±enum_stmt_attr_typeβ the attribute you're asking about. see below β¬οΈattrβ pointer to a variable, which will contain the attribute value. so you hand it an address and it fills that bad boy in β¨
π Attribute types π
the enum_stmt_attr_type parameter has the following possible values:
STMT_ATTR_UPDATE_MAX_LENGTHβ type ismy_bool *. Indicates ifmysql_stmt_store_result(3)will update themax_lengthvalue ofMYSQL_FIELDstructures. πSTMT_ATTR_CURSOR_TYPEβ type isunsigned long *. Possible values areCURSOR_TYPE_READ_ONLYor default valueCURSOR_TYPE_NO_CURSOR. π―STMT_ATTR_PREFETCH_ROWSβ type isunsigned long *. Number of rows which will be prefetched. The default value is1. πSTMT_ATTR_PREBIND_PARAMSβ type isunsigned int *. Number of parameters used formariadb_stmt_execute_direct(3). π§STMT_ATTR_STATEβ type isenum mysql_stmt_state *. Status of prepared statement. Possible values are defined inenum mysql_stmt_state. This option was added in MariaDB Connector/C 3.1.0 β
π Notes π
- Setting the number of prefetched rows will work only for read only cursors. just so you know, bestie, don't come for me when it doesn't do anything otherwise π
π See Also π
mysql_stmt_attr_set(3)β the one that writes instead of reads, iykyk π
quick vibe check: attr has to point at a variable of the matching type from the list above, or the universe (and your memory) will simply not be okay π match the type to the attribute, periodt.
and that's the tea, bestie π«Ά this was page mysql_stmt_attr_get(3) from Version 3.4 of the MariaDB Connector/C manual β go forth and get those attributes, you absolute icon ππ
π¦ where this page comes from
- alpine 3.22: mariadb-doc 11.4.13-r0 Β· GPL-2.0-or-later
- alpine 3.23: mariadb-doc 11.4.13-r0 Β· GPL-2.0-or-later
- alpine 3.24: mariadb-doc 11.8.9-r0 Β· GPL-2.0-only
- arch rolling: mariadb 13.0.2-2 Β· GPL-2.0-only
- arch rolling: mariadb-lts 12.3.3-2 Β· GPL-2.0-only
- centos-stream 10: mariadb-connector-c-doc 3.4.4-2.el10 Β· LGPL-2.1-or-later
- debian trixie: libmariadb-dev 1:11.8.6-0+deb13u1 Β· GPL-2.0-only
- fedora 43: mariadb-connector-c-doc 3.4.5-2.fc43 Β· LGPL-2.1-or-later AND PHP-3.0 AND PHP-3.01
- fedora 43: mariadb-connector-c-doc 3.4.9-2.fc43 Β· LGPL-2.1-or-later AND PHP-3.0 AND PHP-3.01 AND LicenseRef-Fedora-Public-Domain
- fedora 44: mariadb-connector-c-doc 3.4.8-3.fc44 Β· LGPL-2.1-or-later AND PHP-3.0 AND PHP-3.01
- fedora 44: mariadb-connector-c-doc 3.4.9-2.fc44 Β· LGPL-2.1-or-later AND PHP-3.0 AND PHP-3.01 AND LicenseRef-Fedora-Public-Domain
- nixpkgs unstable: mariadb-server 11.8.8
- opensuse-leap 16.0: libmariadb-devel 3.4.9-160000.1.1 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: libmariadb-devel 3.4.9-160000.1.1 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: libmariadb-devel 3.4.9-160000.1.1 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: libmariadb-devel 3.4.9-160000.1.1 Β· LGPL-2.1-or-later
- ubuntu questing: libmariadb-dev 1:11.8.3-1build1
- ubuntu resolute: libmariadb-dev 1:11.8.6-5 Β· GPL-2.0-only
- ubuntu resolute: libmariadb-dev 1:11.8.6-5ubuntu0.1 Β· GPL-2.0-only
- ubuntu stonking: libmariadb-dev 1:11.8.9+ds-4ubuntu2 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms