Without this attribute set, max_length field is not filled for prepared statements.
This is from http://dev.mysql.com/doc/refman/5.0/en/c-api-datatypes.html : If you are using prepared statements, max_length is not set by default because for the binary protocol the lengths of the values depend on the types of the values in the result set. (See Section 20.9.5, “C API Prepared Statement Data types”.) If you want the max_length values anyway, enable the STMT_ATTR_UPDATE_MAX_LENGTH option with mysql_stmt_attr_set() and the lengths will be set when you call mysql_stmt_store_result(). (See Section 20.9.7.3, “mysql_stmt_attr_set()”, and Section 20.9.7.27, “mysql_stmt_store_result()”.) diff --git a/dbd/apr_dbd_mysql.c b/dbd/apr_dbd_mysql.c index 01afed2..0d206ac 100644 --- a/dbd/apr_dbd_mysql.c +++ b/dbd/apr_dbd_mysql.c @@ -581,8 +581,14 @@ static int dbd_mysql_prepare(apr_pool_t *pool, apr_dbd_t *sql, (*statement)->stmt = mysql_stmt_init(sql->conn); if ((*statement)->stmt) { + my_bool update_max_length = 1; + apr_pool_cleanup_register(pool, (*statement)->stmt, stmt_close, apr_pool_cleanup_null); + + mysql_stmt_attr_set((*statement)->stmt, STMT_ATTR_UPDATE_MAX_LENGTH, + &update_max_length); + ret = mysql_stmt_prepare((*statement)->stmt, query, strlen(query)); if (ret != 0) { -- Marko Kevac Sent from Moscow, Mow, Russia
