diff --git a/ext/mysql.c b/ext/mysql.c index 739d352..383c7ae 100644 --- a/ext/mysql.c +++ b/ext/mysql.c @@ -1129,7 +1129,7 @@ static VALUE process_all_hashes(VALUE obj, VALUE with_table, int build_array, in VALUE ary; if(build_array) ary = rb_ary_new(); - MYSQL_ROW row = mysql_fetch_row(res); // need one early to determine the columns + MYSQL_ROW row = mysql_fetch_row(res); // grab one off the top, to determine the rows if (row == NULL){ if(build_array){ return ary; @@ -1137,7 +1137,6 @@ static VALUE process_all_hashes(VALUE obj, VALUE with_table, int build_array, in return Qnil; } } - unsigned long* lengths = mysql_fetch_lengths(res); MYSQL_FIELD* fields = mysql_fetch_fields(res); unsigned int i; VALUE hash; @@ -1171,9 +1170,11 @@ static VALUE process_all_hashes(VALUE obj, VALUE with_table, int build_array, in } } + unsigned long* lengths = NULL; while(row != NULL) { hash = rb_hash_new(); + lengths = mysql_fetch_lengths(res); for (i=0; i