mysql_stmt_attr_get
mysql_stmt_attr_get retrieves the current value of a prepared statement attribute, such as cursor type, prefetch row count, or max-length update behavior.
Syntax
my_bool mysql_stmt_attr_get(MYSQL_STMT * stmt,
enum enum_stmt_attr_type,
void * attr);Parameters
stmt
A statement handle, which was previously allocated by mysql_stmt_init().
enum_stmt_attr_type
Attribute. See Attribute Types.
attr
Pointer to a variable, which will contain the attribute value.
Description
Gets the current value of a statement attribute. Returns zero on success, non zero on failure.
Attribute Types
The enum_stmt_attr_type parameter has the following possible values:
STMT_ATTR_UPDATE_MAX_LENGTH: Indicates if mysql_stmt_store_result() will update the max_length value of MYSQL_FIELD structures.my_bool is_update; rc= mysql_stmt_attr_get(stmt, STMT_ATTR_UPDATE_MAX_LENGTH, &is_update);STMT_ATTR_CURSOR_TYPE: Cursor type. Possible values areCURSOR_TYPE_READ_ONLYor default valueCURSOR_TYPE_NO_CURSOR.unsigned long cursor_type; rc= mysql_stmt_attr_get(stmt, STMT_ATTR_CURSOR_TYPE, &cursor_type);STMT_ATTR_PREFETCH_ROWS: Number of rows which will be prefetched. The default value is 1.unsigned long prefetch_rows; rc= mysql_stmt_attr_get(stmt, STMT_ATTR_PREFETCH_ROWS, &prefetch_rows);STMT_ATTR_PREBIND_PARAMS: Number of parameters used for mariadb_stmt_execute_direct()unsigned int param_count; rc= mysql_stmt_attr_get(stmt, STMT_ATTR_PREBIND_PARAMS, ¶m_count);STMT_ATTR_STATE: Status of the prepared statement. The returned value is of typeenum mysql_stmt_state. Possible values are defined inenum mysql_stmt_state. Introduced in MariaDB Connector/C 3.1.0enum mysql_stmt_state stmt_state; rc= mysql_stmt_attr_get(stmt, STMT_ATTR_STATE, &stmt_state);STMT_ATTR_SQL_STATEMENT: The SQL statement from the last executed mysql_stmt_prepare() call. The returned value is of typeMARIADB_CONST_STRING. Added in MariaDB Connector/C 3.4.4MARIADB_CONST_STRING sql_statement; rc= mysql_stmt_attr_get(stmt, STMT_ATTR_SQL_STATEMENT, &sql_statement);
See Also
This page is: Copyright © 2026 MariaDB. All rights reserved.
Last updated
Was this helpful?

