From a7de20574749ececbe8492f340f6ddc7be1544fa Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Fri, 4 Sep 2009 12:29:18 +0500 Subject: BUG#46961 - archive engine loses rows during self joining select! SELECT with join (not only self-join) from archive table may return incomplete result set, when result set size exceeds join buffer size. The problem was that archive row counter was initialzed too early, when ha_archive::info() method was called. Later, when optimizer exceeds join buffer, it attempts to reuse handler without calling ha_archive::info() again (which is correct). Fixed by moving row counter initialization from ha_archive::info() to ha_archive::rnd_init(). mysql-test/r/archive.result: A test case for BUG#46961. mysql-test/t/archive.test: A test case for BUG#46961. storage/archive/ha_archive.cc: Since a cursor may get reused without a call to ::info(), move assignment of scan_rows to a proper place, that is ::rnd_init(). --- storage/archive/ha_archive.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'storage') diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc index 1146b2eb73a..f1b9c26dfd6 100644 --- a/storage/archive/ha_archive.cc +++ b/storage/archive/ha_archive.cc @@ -993,6 +993,7 @@ int ha_archive::rnd_init(bool scan) /* We rewind the file so that we can read from the beginning if scan */ if (scan) { + scan_rows= stats.records; DBUG_PRINT("info", ("archive will retrieve %llu rows", (unsigned long long) scan_rows)); @@ -1461,7 +1462,6 @@ int ha_archive::info(uint flag) stats.records= share->rows_recorded; pthread_mutex_unlock(&share->mutex); - scan_rows= stats.records; stats.deleted= 0; DBUG_PRINT("ha_archive", ("Stats rows is %d\n", (int)stats.records)); -- cgit v1.2.1