This is a read-only copy of the MariaDB Knowledgebase generated on 2024-11-22. For the latest, interactive version please visit https://mariadb.com/kb/.

mysql_stmt_attr_get

Syntax

my_bool mysql_stmt_attr_get(MYSQL_STMT * stmt,
                            enum enum_stmt_attr_type,
                            void * attr);
  • stmt - a statement handle, which was previously allocated by mysql_stmt_init().
  • enum_stmt_attr_type - attribute. See below.
  • 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 are CURSOR_TYPE_READ_ONLY or default value CURSOR_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, &param_count);
    

Setting the number of prefetched rows will work only for read only cursors.

See Also

Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.