#At file:///home/satya/WORK/mysql-6.0-bug-40677/
2934 Satya B 2008-11-24
Fix for BUG#40677 - Archive tables joined on primary return no result
Select queries on archive tables when joined on their primary keys
returns no results(empty set)
Archive storage doesn't inform the handler about the fetched record
status when it is found. Fixed the archive storage engine to update
the record status when it fetches successfully
modified:
mysql-test/r/archive.result
mysql-test/t/archive.test
storage/archive/ha_archive.cc
per-file messages:
mysql-test/r/archive.result
Result file for the modified archive.test
mysql-test/t/archive.test
added testcase to test join operation on primary key on archive tables
storage/archive/ha_archive.cc
Fixed index_read_idx(..) to set table->status to zero when record is found
=== modified file 'mysql-test/r/archive.result'
--- a/mysql-test/r/archive.result 2007-12-13 12:59:16 +0000
+++ b/mysql-test/r/archive.result 2008-11-24 15:53:30 +0000
@@ -12698,3 +12698,13 @@ SELECT * FROM t1 ORDER BY a;
a b
1 NULL
2 NULL
+DROP TABLE t1;
+CREATE TABLE t1(id INT NOT NULL AUTO_INCREMENT, name VARCHAR(128) NOT NULL, PRIMARY KEY(id)) ENGINE=archive;
+INSERT INTO t1 VALUES(NULL,'a'),(NULL,'a');
+CREATE TABLE t2(id INT NOT NULL AUTO_INCREMENT, name VARCHAR(128) NOT NULL, PRIMARY KEY(id)) ENGINE=archive;
+INSERT INTO t2 VALUES(NULL,'b'),(NULL,'b');
+SELECT t1.id, t2.id, t1.name, t2.name FROM t1,t2 WHERE t1.id = t2.id;
+id id name name
+1 1 a b
+2 2 a b
+DROP TABLE t1,t2;
=== modified file 'mysql-test/t/archive.test'
--- a/mysql-test/t/archive.test 2007-11-29 12:05:51 +0000
+++ b/mysql-test/t/archive.test 2008-11-24 15:53:30 +0000
@@ -1600,3 +1600,14 @@ CREATE TABLE t1(a INT NOT NULL AUTO_INCR
INSERT INTO t1 VALUES (NULL, NULL),(NULL, NULL);
FLUSH TABLE t1;
SELECT * FROM t1 ORDER BY a;
+DROP TABLE t1;
+
+#
+# BUG#40677 - Archive tables joined on primary return no result
+#
+CREATE TABLE t1(id INT NOT NULL AUTO_INCREMENT, name VARCHAR(128) NOT NULL, PRIMARY KEY(id)) ENGINE=archive;
+INSERT INTO t1 VALUES(NULL,'a'),(NULL,'a');
+CREATE TABLE t2(id INT NOT NULL AUTO_INCREMENT, name VARCHAR(128) NOT NULL, PRIMARY KEY(id)) ENGINE=archive;
+INSERT INTO t2 VALUES(NULL,'b'),(NULL,'b');
+SELECT t1.id, t2.id, t1.name, t2.name FROM t1,t2 WHERE t1.id = t2.id;
+DROP TABLE t1,t2;
=== modified file 'storage/archive/ha_archive.cc'
--- a/storage/archive/ha_archive.cc 2008-11-06 06:18:15 +0000
+++ b/storage/archive/ha_archive.cc 2008-11-24 15:53:30 +0000
@@ -950,7 +950,11 @@ int ha_archive::index_read_idx(uchar *bu
}
if (found)
+ {
+ /* notify handler that a record has been found */
+ table->status= 0;
DBUG_RETURN(0);
+ }
error:
DBUG_RETURN(rc ? rc : HA_ERR_END_OF_FILE);