@@ -294,7 +294,7 @@ static void rb_mysql_result_alloc_result_buffers(VALUE self, MYSQL_FIELD *fields
294294 }
295295}
296296
297- static VALUE rb_mysql_result_stmt_fetch_row (VALUE self , ID db_timezone , ID app_timezone , int symbolizeKeys , int asArray , int castBool , int cast , MYSQL_FIELD * fields ) {
297+ static VALUE rb_mysql_result_stmt_fetch_row (VALUE self , ID db_timezone , ID app_timezone , int symbolizeKeys , int asArray , int castBool , MYSQL_FIELD * fields ) {
298298 VALUE rowVal ;
299299 mysql2_result_wrapper * wrapper ;
300300 unsigned int i = 0 ;
@@ -780,12 +780,13 @@ static VALUE rb_mysql_result_each_nonstmt(VALUE self, const result_each_args* ar
780780 wrapper -> numberOfRows ++ ;
781781 if (args -> block_given != Qnil ) {
782782 rb_yield (row );
783+ wrapper -> lastRowProcessed ++ ;
783784 }
784785 }
785786 } while (row != Qnil );
786787
787788 rb_mysql_result_free_result (wrapper );
788- // wrapper->numberOfRows = wrapper->lastRowProcessed;
789+ wrapper -> numberOfRows = wrapper -> lastRowProcessed ;
789790 wrapper -> streamingComplete = 1 ;
790791
791792 // Check for errors, the connection might have gone out from under us
@@ -864,17 +865,18 @@ static VALUE rb_mysql_result_each_stmt(VALUE self, const result_each_args* args)
864865 fields = mysql_fetch_fields (wrapper -> result );
865866
866867 do {
867- row = rb_mysql_result_stmt_fetch_row (self , args -> db_timezone , args -> app_timezone , args -> symbolizeKeys , args -> asArray , args -> castBool , args -> cast , fields );
868+ row = rb_mysql_result_stmt_fetch_row (self , args -> db_timezone , args -> app_timezone , args -> symbolizeKeys , args -> asArray , args -> castBool , fields );
868869 if (row != Qnil ) {
869870 wrapper -> numberOfRows ++ ;
870871 if (args -> block_given != Qnil ) {
871872 rb_yield (row );
873+ wrapper -> lastRowProcessed ++ ;
872874 }
873875 }
874876 } while (row != Qnil );
875877
876878 rb_mysql_result_free_result (wrapper );
877- // wrapper->numberOfRows = wrapper->lastRowProcessed;
879+ wrapper -> numberOfRows = wrapper -> lastRowProcessed ;
878880 wrapper -> streamingComplete = 1 ;
879881
880882 // Check for errors, the connection might have gone out from under us
@@ -903,7 +905,7 @@ static VALUE rb_mysql_result_each_stmt(VALUE self, const result_each_args* args)
903905 if (args -> cacheRows && i < rowsProcessed ) {
904906 row = rb_ary_entry (wrapper -> rows , i );
905907 } else {
906- row = rb_mysql_result_stmt_fetch_row (self , args -> db_timezone , args -> app_timezone , args -> symbolizeKeys , args -> asArray , args -> castBool , args -> cast , fields );
908+ row = rb_mysql_result_stmt_fetch_row (self , args -> db_timezone , args -> app_timezone , args -> symbolizeKeys , args -> asArray , args -> castBool , fields );
907909 if (args -> cacheRows ) {
908910 rb_ary_store (wrapper -> rows , i , row );
909911 }
@@ -962,10 +964,14 @@ static VALUE rb_mysql_result_each(int argc, VALUE * argv, VALUE self) {
962964 rb_warn ("cacheRows is ignored if streaming is true" );
963965 }
964966
965- if (wrapper -> stmt && !args .cacheRows && !args .streaming ) {
967+ if (wrapper -> stmt && !args .cacheRows && !args .streaming ) {
966968 rb_warn ("cacheRows is forced for prepared statements (if not streaming)" );
967969 }
968970
971+ if (wrapper -> stmt && !args .cast ) {
972+ rb_warn ("cast is forced for prepared statements" );
973+ }
974+
969975 dbTz = rb_hash_aref (opts , sym_database_timezone );
970976 if (dbTz == sym_local ) {
971977 db_timezone = intern_local ;
0 commit comments