mysql_stmt_attr_get(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_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 by mysql_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 is my_bool *. Indicates if mysql_stmt_store_result(3) will update the max_length value of MYSQL_FIELD structures. πŸ“
  • STMT_ATTR_CURSOR_TYPE β€” type is unsigned long *. Possible values are CURSOR_TYPE_READ_ONLY or default value CURSOR_TYPE_NO_CURSOR. 🎯
  • STMT_ATTR_PREFETCH_ROWS β€” type is unsigned long *. Number of rows which will be prefetched. The default value is 1. πŸ“
  • STMT_ATTR_PREBIND_PARAMS β€” type is unsigned int *. Number of parameters used for mariadb_stmt_execute_direct(3). 🧚
  • STMT_ATTR_STATE β€” type is enum mysql_stmt_state *. Status of prepared statement. Possible values are defined in enum 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 🌈


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