List:Commits« Previous MessageNext Message »
From:igor Date:July 15 2006 7:28am
Subject:bk commit into 5.0 tree (igor:1.2200) BUG#20869
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of igor. When igor 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, 2006-07-15 00:28:21-07:00, igor@stripped +3 -0
  Fixed bug #20869.
  The bug caused a crash of the server if a subquery with
  ORDER BY DESC used the range access method.
  The bug happened because the method QUICK_SELECT_DESC::reset
  was not reworked after MRR interface had been introduced.

  mysql-test/r/subselect.result@stripped, 2006-07-15 00:28:13-07:00, igor@stripped +36 -0
    Added a test case for bug #20869.

  mysql-test/t/subselect.test@stripped, 2006-07-15 00:28:13-07:00, igor@stripped +38 -0
    Added a test case for bug #20869.

  sql/opt_range.h@stripped, 2006-07-15 00:28:13-07:00, igor@stripped +1 -1
    Fixed bug #20869.
    The bug caused a crash of the server if a subquery with
    ORDER BY DESC used the range access method.
    The bug happened because the method QUICK_SELECT_DESC::reset
    was not reworked after MRR interface had been introduced.
    

# 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:	igor
# Host:	rurik.mysql.com
# Root:	/home/igor/mysql-5.0-opt

--- 1.58/sql/opt_range.h	2006-07-15 00:28:30 -07:00
+++ 1.59/sql/opt_range.h	2006-07-15 00:28:30 -07:00
@@ -668,7 +668,7 @@
 #ifdef NOT_USED
   bool test_if_null_range(QUICK_RANGE *range, uint used_key_parts);
 #endif
-  int reset(void) { next=0; rev_it.rewind(); return 0; }
+  int reset(void) { rev_it.rewind(); return QUICK_RANGE_SELECT::reset(); }
   List<QUICK_RANGE> rev_ranges;
   List_iterator<QUICK_RANGE> rev_it;
 };

--- 1.147/mysql-test/r/subselect.result	2006-07-15 00:28:30 -07:00
+++ 1.148/mysql-test/r/subselect.result	2006-07-15 00:28:30 -07:00
@@ -3238,3 +3238,39 @@
 10000000000000000000
 DROP TABLE t1;
 DROP TABLE t2;
+CREATE TABLE t1 (
+i1 int(11) NOT NULL default '0',
+i2 int(11) NOT NULL default '0',
+t datetime NOT NULL default '0000-00-00 00:00:00',
+PRIMARY KEY  (i1,i2,t)
+);
+INSERT INTO t1 VALUES 
+(24,1,'2005-03-03 16:31:31'),(24,1,'2005-05-27 12:40:07'),
+(24,1,'2005-05-27 12:40:08'),(24,1,'2005-05-27 12:40:10'),
+(24,1,'2005-05-27 12:40:25'),(24,1,'2005-05-27 12:40:30'),
+(24,2,'2005-03-03 13:43:05'),(24,2,'2005-03-03 16:23:31'),
+(24,2,'2005-03-03 16:31:30'),(24,2,'2005-05-27 12:37:02'),
+(24,2,'2005-05-27 12:40:06');
+CREATE TABLE t2 (
+i1 int(11) NOT NULL default '0',
+i2 int(11) NOT NULL default '0',
+t datetime default NULL,
+PRIMARY KEY  (i1)
+);
+INSERT INTO t2 VALUES (24,1,'2006-06-20 12:29:40');
+EXPLAIN
+SELECT * FROM t1,t2
+WHERE t1.t = (SELECT t1.t FROM t1 
+WHERE t1.t < t2.t  AND t1.i2=1 AND t2.i1=t1.i1
+ORDER BY t1.t DESC LIMIT 1);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	t2	system	NULL	NULL	NULL	NULL	1	
+1	PRIMARY	t1	index	NULL	PRIMARY	16	NULL	11	Using where; Using index
+2	DEPENDENT SUBQUERY	t1	range	PRIMARY	PRIMARY	16	NULL	5	Using where; Using index
+SELECT * FROM t1,t2
+WHERE t1.t = (SELECT t1.t FROM t1 
+WHERE t1.t < t2.t  AND t1.i2=1 AND t2.i1=t1.i1
+ORDER BY t1.t DESC LIMIT 1);
+i1	i2	t	i1	i2	t
+24	1	2005-05-27 12:40:30	24	1	2006-06-20 12:29:40
+DROP TABLE t1, t2;

--- 1.120/mysql-test/t/subselect.test	2006-07-15 00:28:30 -07:00
+++ 1.121/mysql-test/t/subselect.test	2006-07-15 00:28:30 -07:00
@@ -2161,3 +2161,41 @@
 
 DROP TABLE t1;
 DROP TABLE t2;
+
+# 
+# Bug#20869: subselect with range access by DESC
+#
+
+CREATE TABLE t1 (
+  i1 int(11) NOT NULL default '0',
+  i2 int(11) NOT NULL default '0',
+  t datetime NOT NULL default '0000-00-00 00:00:00',
+  PRIMARY KEY  (i1,i2,t)
+);
+INSERT INTO t1 VALUES 
+(24,1,'2005-03-03 16:31:31'),(24,1,'2005-05-27 12:40:07'),
+(24,1,'2005-05-27 12:40:08'),(24,1,'2005-05-27 12:40:10'),
+(24,1,'2005-05-27 12:40:25'),(24,1,'2005-05-27 12:40:30'),
+(24,2,'2005-03-03 13:43:05'),(24,2,'2005-03-03 16:23:31'),
+(24,2,'2005-03-03 16:31:30'),(24,2,'2005-05-27 12:37:02'),
+(24,2,'2005-05-27 12:40:06');
+
+CREATE TABLE t2 (
+  i1 int(11) NOT NULL default '0',
+  i2 int(11) NOT NULL default '0',
+  t datetime default NULL,
+  PRIMARY KEY  (i1)
+);
+INSERT INTO t2 VALUES (24,1,'2006-06-20 12:29:40');
+
+EXPLAIN
+SELECT * FROM t1,t2
+  WHERE t1.t = (SELECT t1.t FROM t1 
+                  WHERE t1.t < t2.t  AND t1.i2=1 AND t2.i1=t1.i1
+                    ORDER BY t1.t DESC LIMIT 1);
+SELECT * FROM t1,t2
+  WHERE t1.t = (SELECT t1.t FROM t1 
+                  WHERE t1.t < t2.t  AND t1.i2=1 AND t2.i1=t1.i1
+                    ORDER BY t1.t DESC LIMIT 1);
+
+DROP TABLE t1, t2;
Thread
bk commit into 5.0 tree (igor:1.2200) BUG#20869igor15 Jul