MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:<gshchepa Date:June 23 2007 7:23pm
Subject:bk commit into 5.0 tree (gshchepa:1.2501) BUG#29095
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-06-24 00:23:07+05:00, gshchepa@stripped +3 -0
  Fixed bug #29095.
  INSERT into table from SELECT from the same table
  with ORDER BY and LIMIT was inserting other data
  than sole SELECT ... ORDER BY ... LIMIT returns.
  
  One part of the patch for bug #9676 improperly pushed
  LIMIT to temporary table in the presence of the ORDER BY
  clause.
  That part has been removed.

  mysql-test/r/insert_select.result@stripped, 2007-06-24 00:20:20+05:00, gshchepa@stripped +31 -0
    Expanded the test case for bug #9676.
    Created a test case for bug #29095.

  mysql-test/t/insert_select.test@stripped, 2007-06-24 00:20:19+05:00, gshchepa@stripped +25 -0
    Expanded the test case for bug #9676.
    Created a test case for bug #29095.

  sql/sql_select.cc@stripped, 2007-06-24 00:20:18+05:00, gshchepa@stripped +1 -2
    Fixed bug #29095.
    One part of the patch for bug #9676 improperly pushed
    LIMIT to temporary table in the presence of the ORDER BY
    clause.
    That part has been removed.

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	gshchepa
# Host:	gleb.loc
# Root:	/home/uchum/work/bk/5.0-opt-29095

--- 1.533/sql/sql_select.cc	2007-06-20 13:06:21 +05:00
+++ 1.534/sql/sql_select.cc	2007-06-24 00:20:18 +05:00
@@ -1347,8 +1347,7 @@ JOIN::optimize()
       there are aggregate functions, because in all these cases we need
       all result rows.
     */
-    ha_rows tmp_rows_limit= ((order == 0 || skip_sort_order ||
-                              test(select_options & OPTION_BUFFER_RESULT)) &&
+    ha_rows tmp_rows_limit= ((order == 0 || skip_sort_order || test(select_options & OPTION_BUFFER_RESULT)) &&
                              !tmp_group &&
                              !thd->lex->current_select->with_sum_func) ?
                             select_limit : HA_POS_ERROR;

--- 1.47/mysql-test/r/insert_select.result	2007-05-30 17:04:02 +05:00
+++ 1.48/mysql-test/r/insert_select.result	2007-06-24 00:20:20 +05:00
@@ -688,7 +688,16 @@ ERROR 42S22: Unknown column 't2.x' in 'f
 drop table t1,t2;
 CREATE TABLE t1 (a int PRIMARY KEY);
 INSERT INTO t1 values (1), (2);
+flush status;
 INSERT INTO t1 SELECT a + 2 FROM t1 LIMIT 1;
+show status like 'Handler_read%';
+Variable_name	Value
+Handler_read_first	1
+Handler_read_key	0
+Handler_read_next	0
+Handler_read_prev	0
+Handler_read_rnd	0
+Handler_read_rnd_next	1
 DROP TABLE t1;
 CREATE TABLE t1 (x int, y int);
 CREATE TABLE t2 (z int, y int);
@@ -772,4 +781,26 @@ d
 7
 20
 20
+DROP TABLE t1,t2;
+CREATE TABLE t1 (
+id INT AUTO_INCREMENT PRIMARY KEY,
+prev_id INT,
+join_id INT DEFAULT 0);
+INSERT INTO t1 (prev_id) VALUES (NULL), (1), (2);
+SELECT * FROM t1;
+id	prev_id	join_id
+1	NULL	0
+2	1	0
+3	2	0
+CREATE TABLE t2 (join_id INT);
+INSERT INTO t2 (join_id) VALUES (0);
+INSERT INTO t1 (prev_id) SELECT id
+FROM t2 LEFT JOIN t1 ON t1.join_id = t2.join_id
+ORDER BY id DESC LIMIT 1;
+SELECT * FROM t1;
+id	prev_id	join_id
+1	NULL	0
+2	1	0
+3	2	0
+4	3	0
 DROP TABLE t1,t2;

--- 1.38/mysql-test/t/insert_select.test	2007-03-22 20:44:15 +04:00
+++ 1.39/mysql-test/t/insert_select.test	2007-06-24 00:20:19 +05:00
@@ -233,7 +233,9 @@ drop table t1,t2; 
 CREATE TABLE t1 (a int PRIMARY KEY);
 INSERT INTO t1 values (1), (2);
 
+flush status;
 INSERT INTO t1 SELECT a + 2 FROM t1 LIMIT 1;
+show status like 'Handler_read%';
 
 DROP TABLE t1;
 
@@ -331,4 +333,27 @@ INSERT INTO t2 (d)
   FROM t1;
 
 SELECT * FROM t2;
+DROP TABLE t1,t2;
+
+#
+# Bug #29095: incorrect pushing of LIMIT into the temporary
+# table ignoring ORDER BY clause
+#
+
+CREATE TABLE t1 (
+  id INT AUTO_INCREMENT PRIMARY KEY,
+  prev_id INT,
+  join_id INT DEFAULT 0);
+
+INSERT INTO t1 (prev_id) VALUES (NULL), (1), (2);
+SELECT * FROM t1;
+
+CREATE TABLE t2 (join_id INT);
+INSERT INTO t2 (join_id) VALUES (0);
+
+INSERT INTO t1 (prev_id) SELECT id
+  FROM t2 LEFT JOIN t1 ON t1.join_id = t2.join_id
+  ORDER BY id DESC LIMIT 1;
+SELECT * FROM t1;
+
 DROP TABLE t1,t2;
Thread
bk commit into 5.0 tree (gshchepa:1.2501) BUG#29095gshchepa23 Jun