Loading mysql-test/r/merge.result +37 −0 Original line number Diff line number Diff line Loading @@ -881,4 +881,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 mysql-test/r/myisam.result +22 −0 Original line number Diff line number Diff line Loading @@ -1831,4 +1831,26 @@ 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 mysql-test/t/merge.test +22 −0 Original line number Diff line number Diff line Loading @@ -521,4 +521,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 mysql-test/t/myisam.test +17 −0 Original line number Diff line number Diff line Loading @@ -1187,4 +1187,21 @@ 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 sql/ha_myisam.cc +6 −2 Original line number Diff line number Diff line Loading @@ -1602,10 +1602,14 @@ int ha_myisam::index_next_same(byte * buf, const byte *key __attribute__((unused)), uint length __attribute__((unused))) { int error; DBUG_ASSERT(inited==INDEX); statistic_increment(table->in_use->status_var.ha_read_next_count, &LOCK_status); 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; } Loading Loading
mysql-test/r/merge.result +37 −0 Original line number Diff line number Diff line Loading @@ -881,4 +881,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
mysql-test/r/myisam.result +22 −0 Original line number Diff line number Diff line Loading @@ -1831,4 +1831,26 @@ 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
mysql-test/t/merge.test +22 −0 Original line number Diff line number Diff line Loading @@ -521,4 +521,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
mysql-test/t/myisam.test +17 −0 Original line number Diff line number Diff line Loading @@ -1187,4 +1187,21 @@ 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
sql/ha_myisam.cc +6 −2 Original line number Diff line number Diff line Loading @@ -1602,10 +1602,14 @@ int ha_myisam::index_next_same(byte * buf, const byte *key __attribute__((unused)), uint length __attribute__((unused))) { int error; DBUG_ASSERT(inited==INDEX); statistic_increment(table->in_use->status_var.ha_read_next_count, &LOCK_status); 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; } Loading