return 0;
}
- if (!stmt->executed) {
+ if (!S->result) {
/* figure out the result set format, if any */
S->result = mysql_stmt_result_metadata(S->stmt);
if (S->result) {
S->fields = mysql_fetch_fields(S->result);
stmt->column_count = (int)mysql_num_fields(S->result);
- if (H->buffered) {
- mysql_stmt_store_result(S->stmt);
- }
-
S->bound_result = ecalloc(stmt->column_count, sizeof(MYSQL_BIND));
S->out_null = ecalloc(stmt->column_count, sizeof(my_bool));
S->out_length = ecalloc(stmt->column_count, sizeof(unsigned long));
}
}
}
+
+ /* 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;