summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <kaa@polly.(none)>2007-11-26 20:15:30 +0300
committerunknown <kaa@polly.(none)>2007-11-26 20:15:30 +0300
commit8ae8b2e5ef0554a506414b6eddc4c028c438b4e6 (patch)
tree598aba7472d441171bbd41565a24f2d863a0dcb7
parent185b9efe8c243f28d24d30a79165c83df6eb6d12 (diff)
parented48025916e6a5bff564aa6402750a4b291186bf (diff)
downloadmariadb-git-8ae8b2e5ef0554a506414b6eddc4c028c438b4e6.tar.gz
Merge polly.(none):/home/kaa/src/opt/bug28837/my51-bug29131
into polly.(none):/home/kaa/src/opt/mysql-5.1-opt storage/myisam/ha_myisam.cc: Auto merged mysql-test/r/merge.result: Manual merge. mysql-test/r/myisam.result: Manual merge. mysql-test/t/merge.test: Manual merge. mysql-test/t/myisam.test: Manual merge.
-rw-r--r--mysql-test/r/merge.result37
-rw-r--r--mysql-test/r/myisam.result22
-rw-r--r--mysql-test/t/merge.test22
-rw-r--r--mysql-test/t/myisam.test17
-rw-r--r--storage/myisam/ha_myisam.cc6
-rw-r--r--storage/myisammrg/ha_myisammrg.cc6
6 files changed, 108 insertions, 2 deletions
diff --git a/mysql-test/r/merge.result b/mysql-test/r/merge.result
index d6e19107ec4..6e9195f7425 100644
--- a/mysql-test/r/merge.result
+++ b/mysql-test/r/merge.result
@@ -884,4 +884,41 @@ CREATE TABLE t2 (c1 INT) ENGINE=MERGE UNION=(t1) INSERT_METHOD=FIRST;
CREATE TABLE IF NOT EXISTS t1 SELECT * FROM t2;
ERROR HY000: You can't specify target table 't1' for update in FROM clause
DROP TABLE t1, t2;
+CREATE TABLE t1 (id INT NOT NULL, ref INT NOT NULL, INDEX (id)) ENGINE=MyISAM;
+CREATE TABLE t2 LIKE t1;
+INSERT INTO t2 (id, ref) VALUES (1,3), (2,1), (3,2), (4,5), (4,4);
+INSERT INTO t1 SELECT * FROM t2;
+INSERT INTO t1 SELECT * FROM t2;
+CREATE TABLE t3 (id INT NOT NULL, ref INT NOT NULL, INDEX (id)) ENGINE=MERGE
+UNION(t1);
+SELECT * FROM t3 AS a INNER JOIN t3 AS b USING (id) WHERE a.ref < b.ref;
+id ref ref
+4 4 5
+4 4 5
+4 4 5
+4 4 5
+SELECT * FROM t3;
+id ref
+1 3
+2 1
+3 2
+4 5
+4 4
+1 3
+2 1
+3 2
+4 5
+4 4
+DELETE FROM a USING t3 AS a INNER JOIN t3 AS b USING (id) WHERE a.ref < b.ref;
+SELECT * FROM t3;
+id ref
+1 3
+2 1
+3 2
+4 5
+1 3
+2 1
+3 2
+4 5
+DROP TABLE t1, t2, t3;
End of 5.0 tests
diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result
index 3125660643c..205edf2d617 100644
--- a/mysql-test/r/myisam.result
+++ b/mysql-test/r/myisam.result
@@ -1819,6 +1819,28 @@ SHOW TABLE STATUS LIKE 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 MyISAM 10 Fixed 1 # # # 3072 # # # # # # #
DROP TABLE t1;
+CREATE TABLE t1 (id int NOT NULL, ref int NOT NULL, INDEX (id)) ENGINE=MyISAM;
+CREATE TABLE t2 LIKE t1;
+INSERT INTO t2 (id, ref) VALUES (1,3), (2,1), (3,2), (4,5), (4,4);
+INSERT INTO t1 SELECT * FROM t2;
+SELECT * FROM t1 AS a INNER JOIN t1 AS b USING (id) WHERE a.ref < b.ref;
+id ref ref
+4 4 5
+SELECT * FROM t1;
+id ref
+1 3
+2 1
+3 2
+4 5
+4 4
+DELETE FROM a USING t1 AS a INNER JOIN t1 AS b USING (id) WHERE a.ref < b.ref;
+SELECT * FROM t1;
+id ref
+1 3
+2 1
+3 2
+4 5
+DROP TABLE t1, t2;
End of 5.0 tests
create table t1 (a int not null, key `a` (a) key_block_size=1024);
show create table t1;
diff --git a/mysql-test/t/merge.test b/mysql-test/t/merge.test
index a50588b1e78..f8fd82707ce 100644
--- a/mysql-test/t/merge.test
+++ b/mysql-test/t/merge.test
@@ -525,4 +525,26 @@ CREATE TABLE t2 (c1 INT) ENGINE=MERGE UNION=(t1) INSERT_METHOD=FIRST;
CREATE TABLE IF NOT EXISTS t1 SELECT * FROM t2;
DROP TABLE t1, t2;
+#
+# Bug #28837: MyISAM storage engine error (134) doing delete with self-join
+#
+
+CREATE TABLE t1 (id INT NOT NULL, ref INT NOT NULL, INDEX (id)) ENGINE=MyISAM;
+CREATE TABLE t2 LIKE t1;
+
+INSERT INTO t2 (id, ref) VALUES (1,3), (2,1), (3,2), (4,5), (4,4);
+INSERT INTO t1 SELECT * FROM t2;
+INSERT INTO t1 SELECT * FROM t2;
+
+CREATE TABLE t3 (id INT NOT NULL, ref INT NOT NULL, INDEX (id)) ENGINE=MERGE
+ UNION(t1);
+
+SELECT * FROM t3 AS a INNER JOIN t3 AS b USING (id) WHERE a.ref < b.ref;
+SELECT * FROM t3;
+DELETE FROM a USING t3 AS a INNER JOIN t3 AS b USING (id) WHERE a.ref < b.ref;
+SELECT * FROM t3;
+
+DROP TABLE t1, t2, t3;
+
+
--echo End of 5.0 tests
diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test
index 6f24d84f4c0..34db38d4a38 100644
--- a/mysql-test/t/myisam.test
+++ b/mysql-test/t/myisam.test
@@ -1172,6 +1172,23 @@ SHOW TABLE STATUS LIKE 't1';
#--exec myisamchk -iev var/master-data/test/t1.MYI
DROP TABLE t1;
+#
+# Bug#28837: MyISAM storage engine error (134) doing delete with self-join
+#
+
+CREATE TABLE t1 (id int NOT NULL, ref int NOT NULL, INDEX (id)) ENGINE=MyISAM;
+CREATE TABLE t2 LIKE t1;
+
+INSERT INTO t2 (id, ref) VALUES (1,3), (2,1), (3,2), (4,5), (4,4);
+INSERT INTO t1 SELECT * FROM t2;
+
+SELECT * FROM t1 AS a INNER JOIN t1 AS b USING (id) WHERE a.ref < b.ref;
+SELECT * FROM t1;
+DELETE FROM a USING t1 AS a INNER JOIN t1 AS b USING (id) WHERE a.ref < b.ref;
+SELECT * FROM t1;
+
+DROP TABLE t1, t2;
+
--echo End of 5.0 tests
diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc
index ca4c40547ee..be966e90de4 100644
--- a/storage/myisam/ha_myisam.cc
+++ b/storage/myisam/ha_myisam.cc
@@ -1649,9 +1649,13 @@ int ha_myisam::index_next_same(uchar *buf,
const uchar *key __attribute__((unused)),
uint length __attribute__((unused)))
{
+ int error;
DBUG_ASSERT(inited==INDEX);
ha_statistic_increment(&SSV::ha_read_next_count);
- int error=mi_rnext_same(file,buf);
+ do
+ {
+ error= mi_rnext_same(file,buf);
+ } while (error == HA_ERR_RECORD_DELETED);
table->status=error ? STATUS_NOT_FOUND: 0;
return error;
}
diff --git a/storage/myisammrg/ha_myisammrg.cc b/storage/myisammrg/ha_myisammrg.cc
index 8a914e8a2de..54ad029c4f4 100644
--- a/storage/myisammrg/ha_myisammrg.cc
+++ b/storage/myisammrg/ha_myisammrg.cc
@@ -271,8 +271,12 @@ int ha_myisammrg::index_next_same(uchar * buf,
const uchar *key __attribute__((unused)),
uint length __attribute__((unused)))
{
+ int error;
ha_statistic_increment(&SSV::ha_read_next_count);
- int error=myrg_rnext_same(file,buf);
+ do
+ {
+ error= myrg_rnext_same(file,buf);
+ } while (error == HA_ERR_RECORD_DELETED);
table->status=error ? STATUS_NOT_FOUND: 0;
return error;
}