#At file:///home/svoj/devel/bzr-mysql/mysql-5.1-bugteam-bug46961/ based on revid:v.narayanan@stripped
3109 Sergey Vojtovich 2009-09-04
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().
modified:
mysql-test/r/archive.result
mysql-test/t/archive.test
storage/archive/ha_archive.cc
=== modified file 'mysql-test/r/archive.result'
--- a/mysql-test/r/archive.result 2009-03-26 14:27:34 +0000
+++ b/mysql-test/r/archive.result 2009-09-04 07:29:18 +0000
@@ -12695,3 +12695,14 @@ a b
1 NULL
2 NULL
DROP TABLE t1;
+SET @save_join_buffer_size= @@join_buffer_size;
+SET @@join_buffer_size= 8228;
+CREATE TABLE t1(a CHAR(255)) ENGINE=archive;
+INSERT INTO t1 VALUES('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),
+('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),
+('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
+SELECT COUNT(t1.a) FROM t1, t1 a, t1 b, t1 c, t1 d, t1 e;
+COUNT(t1.a)
+729
+DROP TABLE t1;
+SET @@join_buffer_size= @save_join_buffer_size;
=== modified file 'mysql-test/t/archive.test'
--- a/mysql-test/t/archive.test 2009-03-26 14:27:34 +0000
+++ b/mysql-test/t/archive.test 2009-09-04 07:29:18 +0000
@@ -1599,3 +1599,16 @@ INSERT INTO t1 VALUES (NULL, NULL),(NULL
FLUSH TABLE t1;
SELECT * FROM t1 ORDER BY a;
DROP TABLE t1;
+
+#
+# BUG#46961 - archive engine loses rows during self joining select!
+#
+SET @save_join_buffer_size= @@join_buffer_size;
+SET @@join_buffer_size= 8228;
+CREATE TABLE t1(a CHAR(255)) ENGINE=archive;
+INSERT INTO t1 VALUES('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),
+ ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),
+ ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
+SELECT COUNT(t1.a) FROM t1, t1 a, t1 b, t1 c, t1 d, t1 e;
+DROP TABLE t1;
+SET @@join_buffer_size= @save_join_buffer_size;
=== modified file 'storage/archive/ha_archive.cc'
--- a/storage/archive/ha_archive.cc 2009-05-15 13:03:22 +0000
+++ b/storage/archive/ha_archive.cc 2009-09-04 07:29:18 +0000
@@ -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));
Attachment: [text/bzr-bundle] bzr/svoj@sun.com-20090904072918-wyqdi83fuemy867t.bundle
Thread |
---|
• bzr commit into mysql-5.1-bugteam branch (svoj:3109) Bug#46961 | Sergey Vojtovich | 4 Sep |