MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Georgi Kodinov Date:August 28 2008 11:03am
Subject:bzr push into mysql-5.0 branch (kgeorge:2680)
View as plain text  
 2680 Georgi Kodinov	2008-08-28 [merge]
      merge 5.0-main -> 5.0-bugteam

=== modified file 'mysql-test/r/group_min_max.result'
--- a/mysql-test/r/group_min_max.result	2008-08-19 10:36:24 +0000
+++ b/mysql-test/r/group_min_max.result	2008-08-27 13:03:17 +0000
@@ -2353,3 +2353,79 @@ a	MIN(b)	MAX(b)	AVG(b)
 2	1	3	2.0000
 1	1	3	2.0000
 DROP TABLE t1;
+create table t1 (a int, b int, primary key (a,b), key `index` (a,b)) engine=MyISAM;
+insert into  t1 (a,b) values 
+(0,0),(0,1),(0,2),(0,3),(0,4),(0,5),(0,6),
+(0,7),(0,8),(0,9),(0,10),(0,11),(0,12),(0,13),
+(1,0),(1,1),(1,2),(1,3),(1,4),(1,5),(1,6),
+(1,7),(1,8),(1,9),(1,10),(1,11),(1,12),(1,13),
+(2,0),(2,1),(2,2),(2,3),(2,4),(2,5),(2,6),
+(2,7),(2,8),(2,9),(2,10),(2,11),(2,12),(2,13),
+(3,0),(3,1),(3,2),(3,3),(3,4),(3,5),(3,6),
+(3,7),(3,8),(3,9),(3,10),(3,11),(3,12),(3,13);
+insert into t1 (a,b) select a, max(b)+1 from t1 where a = 0 group by a;
+select * from t1;
+a	b
+0	0
+0	1
+0	2
+0	3
+0	4
+0	5
+0	6
+0	7
+0	8
+0	9
+0	10
+0	11
+0	12
+0	13
+0	14
+1	0
+1	1
+1	2
+1	3
+1	4
+1	5
+1	6
+1	7
+1	8
+1	9
+1	10
+1	11
+1	12
+1	13
+2	0
+2	1
+2	2
+2	3
+2	4
+2	5
+2	6
+2	7
+2	8
+2	9
+2	10
+2	11
+2	12
+2	13
+3	0
+3	1
+3	2
+3	3
+3	4
+3	5
+3	6
+3	7
+3	8
+3	9
+3	10
+3	11
+3	12
+3	13
+explain extended select sql_buffer_result a, max(b)+1 from t1 where a = 0 group by a;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	PRIMARY,index	PRIMARY	4	NULL	3	Using where; Using index for group-by; Using temporary
+Warnings:
+Note	1003	select sql_buffer_result `test`.`t1`.`a` AS `a`,(max(`test`.`t1`.`b`) + 1) AS `max(b)+1` from `test`.`t1` where (`test`.`t1`.`a` = 0) group by `test`.`t1`.`a`
+drop table t1;

=== modified file 'mysql-test/r/type_bit.result'
--- a/mysql-test/r/type_bit.result	2007-12-02 00:48:43 +0000
+++ b/mysql-test/r/type_bit.result	2008-08-27 21:10:37 +0000
@@ -684,4 +684,28 @@ SELECT 1 FROM t1 GROUP BY a;
 1
 1
 DROP TABLE t1;
+CREATE TABLE t1 (b BIT NOT NULL, i2 INTEGER NOT NULL, s VARCHAR(255) NOT NULL);
+INSERT INTO t1 VALUES(0x01,100,''), (0x00,300,''), (0x01,200,''), (0x00,100,'');
+SELECT HEX(b), i2 FROM t1 WHERE (i2>=100 AND i2<201) AND b=TRUE;
+HEX(b)	i2
+1	100
+1	200
+CREATE TABLE t2 (b1 BIT NOT NULL, b2 BIT NOT NULL, i2 INTEGER NOT NULL,
+s VARCHAR(255) NOT NULL);
+INSERT INTO t2 VALUES (0x01,0x00,100,''), (0x00,0x01,300,''),
+(0x01,0x00,200,''), (0x00,0x01,100,'');
+SELECT HEX(b1), i2 FROM t2 WHERE (i2>=100 AND i2<201) AND b1=TRUE;
+HEX(b1)	i2
+1	100
+1	200
+SELECT HEX(b2), i2 FROM t2 WHERE (i2>=100 AND i2<201) AND b2=FALSE;
+HEX(b2)	i2
+0	100
+0	200
+SELECT HEX(b1), HEX(b2), i2 FROM t2
+WHERE (i2>=100 AND i2<201) AND b1=TRUE AND b2=FALSE;
+HEX(b1)	HEX(b2)	i2
+1	0	100
+1	0	200
+DROP TABLE t1, t2;
 End of 5.0 tests

=== modified file 'mysql-test/t/group_min_max.test'
--- a/mysql-test/t/group_min_max.test	2008-08-19 10:36:24 +0000
+++ b/mysql-test/t/group_min_max.test	2008-08-27 13:03:17 +0000
@@ -916,3 +916,22 @@ SELECT a, MIN(b), MAX(b), AVG(b) FROM t1
 SELECT a, MIN(b), MAX(b), AVG(b) FROM t1 GROUP BY a ORDER BY a DESC;
 
 DROP TABLE t1;
+
+#
+# Bug#38195: Incorrect handling of aggregate functions when loose index scan is
+#            used causes server crash.
+#
+create table t1 (a int, b int, primary key (a,b), key `index` (a,b)) engine=MyISAM;
+insert into  t1 (a,b) values 
+(0,0),(0,1),(0,2),(0,3),(0,4),(0,5),(0,6),
+  (0,7),(0,8),(0,9),(0,10),(0,11),(0,12),(0,13),
+(1,0),(1,1),(1,2),(1,3),(1,4),(1,5),(1,6),
+  (1,7),(1,8),(1,9),(1,10),(1,11),(1,12),(1,13),
+(2,0),(2,1),(2,2),(2,3),(2,4),(2,5),(2,6),
+  (2,7),(2,8),(2,9),(2,10),(2,11),(2,12),(2,13),
+(3,0),(3,1),(3,2),(3,3),(3,4),(3,5),(3,6),
+  (3,7),(3,8),(3,9),(3,10),(3,11),(3,12),(3,13);
+insert into t1 (a,b) select a, max(b)+1 from t1 where a = 0 group by a;
+select * from t1;
+explain extended select sql_buffer_result a, max(b)+1 from t1 where a = 0 group by a;
+drop table t1;

=== modified file 'mysql-test/t/type_bit.test'
--- a/mysql-test/t/type_bit.test	2007-11-21 18:56:42 +0000
+++ b/mysql-test/t/type_bit.test	2008-08-27 21:10:37 +0000
@@ -333,4 +333,23 @@ SELECT 1 FROM t1 GROUP BY a;
 
 DROP TABLE t1;
 
+#
+# Bug#37799 SELECT with a BIT column in WHERE clause returns unexpected result
+#
+
+CREATE TABLE t1 (b BIT NOT NULL, i2 INTEGER NOT NULL, s VARCHAR(255) NOT NULL);
+INSERT INTO t1 VALUES(0x01,100,''), (0x00,300,''), (0x01,200,''), (0x00,100,'');
+SELECT HEX(b), i2 FROM t1 WHERE (i2>=100 AND i2<201) AND b=TRUE;
+
+CREATE TABLE t2 (b1 BIT NOT NULL, b2 BIT NOT NULL, i2 INTEGER NOT NULL,
+                 s VARCHAR(255) NOT NULL);
+INSERT INTO t2 VALUES (0x01,0x00,100,''), (0x00,0x01,300,''),
+                      (0x01,0x00,200,''), (0x00,0x01,100,'');
+SELECT HEX(b1), i2 FROM t2 WHERE (i2>=100 AND i2<201) AND b1=TRUE;
+SELECT HEX(b2), i2 FROM t2 WHERE (i2>=100 AND i2<201) AND b2=FALSE;
+SELECT HEX(b1), HEX(b2), i2 FROM t2
+       WHERE (i2>=100 AND i2<201) AND b1=TRUE AND b2=FALSE;
+
+DROP TABLE t1, t2;
+
 --echo End of 5.0 tests

=== modified file 'sql/field.h'
--- a/sql/field.h	2008-08-11 16:10:00 +0000
+++ b/sql/field.h	2008-08-27 21:10:37 +0000
@@ -138,7 +138,7 @@ public:
   virtual bool eq(Field *field)
   {
     return (ptr == field->ptr && null_ptr == field->null_ptr &&
-            null_bit == field->null_bit);
+            null_bit == field->null_bit && field->type() == type());
   }
   virtual bool eq_def(Field *field);
   
@@ -1489,7 +1489,6 @@ public:
   bool eq(Field *field)
   {
     return (Field::eq(field) &&
-            field->type() == type() &&
             bit_ptr == ((Field_bit *)field)->bit_ptr &&
             bit_ofs == ((Field_bit *)field)->bit_ofs);
   }

=== modified file 'sql/opt_range.cc'
--- a/sql/opt_range.cc	2008-07-23 11:25:00 +0000
+++ b/sql/opt_range.cc	2008-08-25 17:02:54 +0000
@@ -7103,6 +7103,13 @@ QUICK_SELECT_DESC::QUICK_SELECT_DESC(QUI
   used_key_parts (used_key_parts_arg)
 {
   QUICK_RANGE *r;
+  /* 
+    Use default MRR implementation for reverse scans. No table engine
+    currently can do an MRR scan with output in reverse index order.
+  */
+  multi_range_length= 0;
+  multi_range= NULL;
+  multi_range_buff= NULL;
 
   QUICK_RANGE **pr= (QUICK_RANGE**)ranges.buffer;
   QUICK_RANGE **end_range= pr + ranges.elements;

=== modified file 'sql/opt_range.h'
--- a/sql/opt_range.h	2008-07-23 11:25:00 +0000
+++ b/sql/opt_range.h	2008-08-25 17:02:54 +0000
@@ -329,14 +329,7 @@ public:
   void dbug_dump(int indent, bool verbose);
 #endif
 private:
-  /* Used only by QUICK_SELECT_DESC */
-  QUICK_RANGE_SELECT(const QUICK_RANGE_SELECT& org) : QUICK_SELECT_I()
-  {
-    bcopy(&org, this, sizeof(*this));
-    multi_range_length= 0;
-    multi_range= NULL;
-    multi_range_buff= NULL;
-  }
+  /* Default copy ctor used by QUICK_SELECT_DESC */
 };
 
 

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2008-08-19 10:36:24 +0000
+++ b/sql/sql_select.cc	2008-08-27 13:03:17 +0000
@@ -1724,7 +1724,8 @@ JOIN::exec()
     if (!items1)
     {
       items1= items0 + all_fields.elements;
-      if (sort_and_group || curr_tmp_table->group)
+      if (sort_and_group || curr_tmp_table->group ||
+          tmp_table_param.precomputed_group_by)
       {
 	if (change_to_use_tmp_fields(thd, items1,
 				     tmp_fields_list1, tmp_all_fields1,
@@ -9259,6 +9260,8 @@ create_tmp_table(THD *thd,TMP_TABLE_PARA
   MI_COLUMNDEF *recinfo;
   uint total_uneven_bit_length= 0;
   bool force_copy_fields= param->force_copy_fields;
+  /* Treat sum functions as normal ones when loose index scan is used. */
+  save_sum_fields|= param->precomputed_group_by;
   DBUG_ENTER("create_tmp_table");
   DBUG_PRINT("enter",("distinct: %d  save_sum_fields: %d  rows_limit: %lu  group: %d",
 		      (int) distinct, (int) save_sum_fields,

Thread
bzr push into mysql-5.0 branch (kgeorge:2680) Georgi Kodinov28 Aug