my_ulonglong row_count;
#if HAVE_MYSQL_STMT_PREPARE
int i;
- my_bool on = 1;
if (S->stmt) {
/* (re)bind the parameters */
return 0;
}
- mysql_stmt_attr_set(S->stmt, STMT_ATTR_UPDATE_MAX_LENGTH, &on);
+ /* if buffered, pre-fetch all the data */
+ if (H->buffered) {
+ my_bool on = 1;
+ mysql_stmt_attr_set(S->stmt, STMT_ATTR_UPDATE_MAX_LENGTH, &on);
+ mysql_stmt_store_result(S->stmt);
+ }
if (!S->result) {
/* figure out the result set format, if any */
/* summon memory to hold the row */
for (i = 0; i < stmt->column_count; i++) {
- S->bound_result[i].buffer_length = S->fields[i].length;
+ S->bound_result[i].buffer_length =
+ S->fields[i].max_length? S->fields[i].max_length:
+ S->fields[i].length;
S->bound_result[i].buffer = emalloc(S->bound_result[i].buffer_length);
S->bound_result[i].is_null = &S->out_null[i];
S->bound_result[i].length = &S->out_length[i];
}
}
- /* if buffered, pre-fetch all the data */
- if (H->buffered) {
- mysql_stmt_store_result(S->stmt);
- }
stmt->row_count = mysql_stmt_affected_rows(S->stmt);
return 1;