List:Commits« Previous MessageNext Message »
From:<gshchepa Date:November 2 2007 2:51pm
Subject:bk commit into 5.0 tree (gshchepa:1.2552) BUG#28837
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of uchum. When uchum does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2007-11-02 18:51:11+04:00, gshchepa@stripped +3 -0
  Fixed bug #28837.
  The MyISAM storage engine reports error 134 doing DELETE with a self-join.
  
  Error 134 (HA_ERR_RECORD_DELETED) is an internal engine code to report
  deleted records during table scans. 
  The join_read_next_same function has been modified to skip
  deleted rows silently.

  mysql-test/r/myisam.result@stripped, 2007-11-02 18:51:02+04:00, gshchepa@stripped +22 -0
    Added test case for bug #28837.

  mysql-test/t/myisam.test@stripped, 2007-11-02 18:51:01+04:00, gshchepa@stripped +17 -0
    Added test case for bug #28837.

  sql/sql_select.cc@stripped, 2007-11-02 18:50:58+04:00, gshchepa@stripped +7 -3
    Fixed bug #28837.
    The join_read_next_same function has been modified to skip
    deleted rows silently.

diff -Nrup a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result
--- a/mysql-test/r/myisam.result	2007-05-22 17:58:29 +05:00
+++ b/mysql-test/r/myisam.result	2007-11-02 18:51:02 +04:00
@@ -1806,4 +1806,26 @@ SELECT a FROM t1 FORCE INDEX (inx) WHERE
 a
 1
 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
diff -Nrup a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test
--- a/mysql-test/t/myisam.test	2007-08-29 17:44:21 +05:00
+++ b/mysql-test/t/myisam.test	2007-11-02 18:51:01 +04:00
@@ -1161,4 +1161,21 @@ ALTER TABLE t1 ENABLE KEYS;
 SELECT a FROM t1 FORCE INDEX (inx) WHERE a=1;
 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 -Nrup a/sql/sql_select.cc b/sql/sql_select.cc
--- a/sql/sql_select.cc	2007-10-23 18:48:56 +05:00
+++ b/sql/sql_select.cc	2007-11-02 18:50:58 +04:00
@@ -11160,9 +11160,13 @@ join_read_next_same(READ_RECORD *info)
   TABLE *table= info->table;
   JOIN_TAB *tab=table->reginfo.join_tab;
 
-  if ((error=table->file->index_next_same(table->record[0],
-					  tab->ref.key_buff,
-					  tab->ref.key_length)))
+  while ((error=table->file->index_next_same(table->record[0],
+                                             tab->ref.key_buff,
+                                             tab->ref.key_length)) ==
+          HA_ERR_RECORD_DELETED)
+    continue;
+
+  if (error)
   {
     if (error != HA_ERR_END_OF_FILE)
       return report_error(table, error);
Thread
bk commit into 5.0 tree (gshchepa:1.2552) BUG#28837gshchepa2 Nov