Skip to content

Commit 3adb531

Browse files
authored
rb_mysql_result_free_result is now executed if the result is 0 rows. (#1399)
When there are 0 rows in the result, the condition to load the cache from the beginning (lastRowProcessed == numberOfRows) is met, and the else route is not entered. To resolve this, the else route is always entered first.
1 parent 794ca50 commit 3adb531

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

ext/mysql2/result.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ static VALUE rb_mysql_result_each_(VALUE self,
10151015
rb_raise(cMysql2Error, "You have already fetched all the rows for this query and streaming is true. (to reiterate you must requery).");
10161016
}
10171017
} else {
1018-
if (args->cacheRows && wrapper->lastRowProcessed == wrapper->numberOfRows) {
1018+
if (args->cacheRows && wrapper->resultFreed) {
10191019
/* we've already read the entire dataset from the C result into our */
10201020
/* internal array. Lets hand that over to the user since it's ready to go */
10211021
for (i = 0; i < wrapper->numberOfRows; i++) {

0 commit comments

Comments
 (0)