@@ -191,10 +191,11 @@ static unsigned int msec_char_to_uint(char *msec_char, size_t len)
191
191
return (unsigned int )strtoul (msec_char , NULL , 10 );
192
192
}
193
193
194
- 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 ) {
194
+ static VALUE rb_mysql_result_fetch_row (VALUE self , ID db_timezone , ID app_timezone , int symbolizeKeys , int asArray , int castBool , int cast ) {
195
195
VALUE rowVal ;
196
196
mysql2_result_wrapper * wrapper ;
197
197
MYSQL_ROW row ;
198
+ MYSQL_FIELD * fields ;
198
199
unsigned int i = 0 ;
199
200
unsigned long * fieldLengths ;
200
201
void * ptr ;
@@ -226,6 +227,9 @@ static VALUE rb_mysql_result_fetch_row(VALUE self, ID db_timezone, ID app_timezo
226
227
wrapper -> fields = rb_ary_new2 (wrapper -> numberOfFields );
227
228
}
228
229
230
+ /* get the MySQL field types to convert to Ruby field types */
231
+ fields = mysql_fetch_fields (wrapper -> result );
232
+
229
233
for (i = 0 ; i < wrapper -> numberOfFields ; i ++ ) {
230
234
VALUE field = rb_mysql_result_fetch_field (self , i , symbolizeKeys );
231
235
if (row [i ]) {
@@ -447,7 +451,6 @@ static VALUE rb_mysql_result_each(int argc, VALUE * argv, VALUE self) {
447
451
unsigned long i ;
448
452
const char * errstr ;
449
453
int symbolizeKeys , asArray , castBool , cacheRows , cast ;
450
- MYSQL_FIELD * fields = NULL ;
451
454
452
455
GetMysql2Result (self , wrapper );
453
456
@@ -499,10 +502,8 @@ static VALUE rb_mysql_result_each(int argc, VALUE * argv, VALUE self) {
499
502
if (!wrapper -> streamingComplete ) {
500
503
VALUE row ;
501
504
502
- fields = mysql_fetch_fields (wrapper -> result );
503
-
504
505
do {
505
- row = rb_mysql_result_fetch_row (self , db_timezone , app_timezone , symbolizeKeys , asArray , castBool , cast , fields );
506
+ row = rb_mysql_result_fetch_row (self , db_timezone , app_timezone , symbolizeKeys , asArray , castBool , cast );
506
507
if (row != Qnil ) {
507
508
wrapper -> numberOfRows ++ ;
508
509
if (block != Qnil ) {
@@ -542,14 +543,13 @@ static VALUE rb_mysql_result_each(int argc, VALUE * argv, VALUE self) {
542
543
} else {
543
544
unsigned long rowsProcessed = 0 ;
544
545
rowsProcessed = RARRAY_LEN (wrapper -> rows );
545
- fields = mysql_fetch_fields (wrapper -> result );
546
546
547
547
for (i = 0 ; i < wrapper -> numberOfRows ; i ++ ) {
548
548
VALUE row ;
549
549
if (cacheRows && i < rowsProcessed ) {
550
550
row = rb_ary_entry (wrapper -> rows , i );
551
551
} else {
552
- row = rb_mysql_result_fetch_row (self , db_timezone , app_timezone , symbolizeKeys , asArray , castBool , cast , fields );
552
+ row = rb_mysql_result_fetch_row (self , db_timezone , app_timezone , symbolizeKeys , asArray , castBool , cast );
553
553
if (cacheRows ) {
554
554
rb_ary_store (wrapper -> rows , i , row );
555
555
}
0 commit comments