@@ -181,10 +181,11 @@ static VALUE mysql2_set_field_string_encoding(VALUE val, MYSQL_FIELD field, rb_e
181
181
#endif
182
182
183
183
184
- static VALUE rb_mysql_result_fetch_row (VALUE self , ID db_timezone , ID app_timezone , int symbolizeKeys , int asArray , int castBool , int cast , MYSQL_FIELD * fields ) {
184
+ static VALUE rb_mysql_result_fetch_row (VALUE self , ID db_timezone , ID app_timezone , int symbolizeKeys , int asArray , int castBool , int cast ) {
185
185
VALUE rowVal ;
186
186
mysql2_result_wrapper * wrapper ;
187
187
MYSQL_ROW row ;
188
+ MYSQL_FIELD * fields ;
188
189
unsigned int i = 0 ;
189
190
unsigned long * fieldLengths ;
190
191
void * ptr ;
@@ -216,6 +217,9 @@ static VALUE rb_mysql_result_fetch_row(VALUE self, ID db_timezone, ID app_timezo
216
217
wrapper -> fields = rb_ary_new2 (wrapper -> numberOfFields );
217
218
}
218
219
220
+ /* get the MySQL field types to convert to Ruby field types */
221
+ fields = mysql_fetch_fields (wrapper -> result );
222
+
219
223
for (i = 0 ; i < wrapper -> numberOfFields ; i ++ ) {
220
224
VALUE field = rb_mysql_result_fetch_field (self , i , symbolizeKeys );
221
225
if (row [i ]) {
@@ -500,10 +504,8 @@ static VALUE rb_mysql_result_each(int argc, VALUE * argv, VALUE self) {
500
504
if (!wrapper -> streamingComplete ) {
501
505
VALUE row ;
502
506
503
- fields = mysql_fetch_fields (wrapper -> result );
504
-
505
507
do {
506
- row = rb_mysql_result_fetch_row (self , db_timezone , app_timezone , symbolizeKeys , asArray , castBool , cast , fields );
508
+ row = rb_mysql_result_fetch_row (self , db_timezone , app_timezone , symbolizeKeys , asArray , castBool , cast );
507
509
508
510
if (block != Qnil && row != Qnil ) {
509
511
rb_yield (row );
@@ -528,14 +530,13 @@ static VALUE rb_mysql_result_each(int argc, VALUE * argv, VALUE self) {
528
530
} else {
529
531
unsigned long rowsProcessed = 0 ;
530
532
rowsProcessed = RARRAY_LEN (wrapper -> rows );
531
- fields = mysql_fetch_fields (wrapper -> result );
532
533
533
534
for (i = 0 ; i < wrapper -> numberOfRows ; i ++ ) {
534
535
VALUE row ;
535
536
if (cacheRows && i < rowsProcessed ) {
536
537
row = rb_ary_entry (wrapper -> rows , i );
537
538
} else {
538
- row = rb_mysql_result_fetch_row (self , db_timezone , app_timezone , symbolizeKeys , asArray , castBool , cast , fields );
539
+ row = rb_mysql_result_fetch_row (self , db_timezone , app_timezone , symbolizeKeys , asArray , castBool , cast );
539
540
if (cacheRows ) {
540
541
rb_ary_store (wrapper -> rows , i , row );
541
542
}
0 commit comments