List:Commits« Previous MessageNext Message »
From:Sergey Petrunia Date:January 3 2009 8:04am
Subject:bzr commit into mysql-6.0-opt branch (sergefp:2759)
View as plain text  
#At file:///home/spetrunia/dev/mysql-6.0-subq-r20/ based on revid:sergefp@stripped

 2759 Sergey Petrunia	2009-01-03 [merge]
      merge mysql-6.0 -> mysql-6.0-opt
modified:
  .bzr-mysql/default.conf
  mysql-test/r/func_math.result
  mysql-test/r/innodb_mrr.result
  mysql-test/r/type_varchar.result
  mysql-test/t/func_math.test
  mysql-test/t/innodb_mrr.test
  sql/item_func.cc
  sql/sql_base.cc
  sql/sql_select.cc

=== modified file '.bzr-mysql/default.conf'
--- a/.bzr-mysql/default.conf	2008-12-22 20:00:22 +0000
+++ b/.bzr-mysql/default.conf	2008-12-29 17:07:04 +0000
@@ -1,5 +1,5 @@
 [MYSQL]
-tree_location = bzr+ssh://bk-internal.mysql.com/bzrroot/server/mysql-6.0-opt-subqueries/
+tree_location = bzr+ssh://bk-internal.mysql.com/bzrroot/server/mysql-6.0-opt/
 post_commit_to = "commits@stripped"
 post_push_to = "commits@stripped"
-tree_name = "mysql-6.0-opt-subqueries"
+tree_name = "mysql-6.0-opt"

=== modified file 'mysql-test/r/func_math.result'
--- a/mysql-test/r/func_math.result	2008-11-24 09:53:39 +0000
+++ b/mysql-test/r/func_math.result	2008-12-22 12:44:57 +0000
@@ -383,8 +383,10 @@ SELECT b DIV 900 y FROM t1 GROUP BY y;
 y
 0
 Warnings:
-Warning	1292	Truncated incorrect INTEGER value: 'str1'
-Warning	1292	Truncated incorrect INTEGER value: 'str2'
+Warning	1366	Incorrect decimal value: '' for column '' at row -1
+Warning	1292	Truncated incorrect DECIMAL value: 'str1'
+Warning	1366	Incorrect decimal value: '' for column '' at row -1
+Warning	1292	Truncated incorrect DECIMAL value: 'str2'
 SELECT c DIV 900 y FROM t1 GROUP BY y;
 y
 0
@@ -460,3 +462,8 @@ SELECT POW(10, 309);
 POW(10, 309)
 NULL
 End of 5.1 tests
+select 123456789012345678901234567890.123456789012345678901234567890 div 1 as x;
+ERROR 22003: Out of range value for column 'x' at row 1
+select "123456789012345678901234567890.123456789012345678901234567890" div 1 as x;
+ERROR 22003: Out of range value for column 'x' at row 1
+End of 6.0 tests

=== modified file 'mysql-test/r/innodb_mrr.result'
--- a/mysql-test/r/innodb_mrr.result	2008-09-05 14:36:37 +0000
+++ b/mysql-test/r/innodb_mrr.result	2008-12-29 03:42:30 +0000
@@ -351,3 +351,32 @@ pk
 1
 5
 drop table t1;
+#
+# BUG#39447: Error with NOT NULL condition and LIMIT 1
+#
+CREATE TABLE t1 (                 
+id int(11) NOT NULL,                
+parent_id int(11) DEFAULT NULL,     
+name varchar(10) DEFAULT NULL,      
+PRIMARY KEY (id),                   
+KEY ind_parent_id (parent_id)     
+) ENGINE=InnoDB;
+insert into t1 (id, parent_id, name) values
+(10,NULL,'A'),
+(20,10,'B'),
+(30,10,'C'),
+(40,NULL,'D'),
+(50,40,'E'),
+(60,40,'F'),
+(70,NULL,'J');
+SELECT id FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1;
+id
+60
+This must show type=index, extra=Using where
+explain SELECT * FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	ind_parent_id	PRIMARY	4	NULL	2	Using where
+SELECT * FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1;
+id	parent_id	name
+60	40	F
+drop table t1;

=== modified file 'mysql-test/r/type_varchar.result'
--- a/mysql-test/r/type_varchar.result	2008-11-24 09:53:39 +0000
+++ b/mysql-test/r/type_varchar.result	2008-12-22 10:11:13 +0000
@@ -475,8 +475,9 @@ a	(a DIV 2)
 60	30
 t	0
 Warnings:
-Warning	1292	Truncated incorrect INTEGER value: '1a'
-Warning	1292	Truncated incorrect INTEGER value: 't '
+Warning	1292	Truncated incorrect DECIMAL value: '1a'
+Warning	1366	Incorrect decimal value: '' for column '' at row -1
+Warning	1292	Truncated incorrect DECIMAL value: 't '
 SELECT a,CAST(a AS SIGNED) FROM t1 ORDER BY a;
 a	CAST(a AS SIGNED)
 10	10

=== modified file 'mysql-test/t/func_math.test'
--- a/mysql-test/t/func_math.test	2008-04-07 15:57:54 +0000
+++ b/mysql-test/t/func_math.test	2008-12-11 15:27:05 +0000
@@ -283,3 +283,14 @@ SELECT EXP(750);
 SELECT POW(10, 309);
 
 --echo End of 5.1 tests
+
+#
+# Bug #8457: Precision math: DIV returns incorrect result with large decimal value
+#
+
+--error ER_WARN_DATA_OUT_OF_RANGE
+select 123456789012345678901234567890.123456789012345678901234567890 div 1 as x;
+--error ER_WARN_DATA_OUT_OF_RANGE
+select "123456789012345678901234567890.123456789012345678901234567890" div 1 as x; 
+
+--echo End of 6.0 tests

=== modified file 'mysql-test/t/innodb_mrr.test'
--- a/mysql-test/t/innodb_mrr.test	2008-09-05 14:36:37 +0000
+++ b/mysql-test/t/innodb_mrr.test	2008-12-29 03:42:30 +0000
@@ -99,3 +99,28 @@ select pk from t1 WHERE `varchar_key` > 
 select pk from t1 WHERE `int_nokey` IS NULL OR  `varchar_key` > 'kr' group by pk;
 drop table t1;
 
+--echo #
+--echo # BUG#39447: Error with NOT NULL condition and LIMIT 1
+--echo #
+CREATE TABLE t1 (                 
+   id int(11) NOT NULL,                
+   parent_id int(11) DEFAULT NULL,     
+   name varchar(10) DEFAULT NULL,      
+   PRIMARY KEY (id),                   
+   KEY ind_parent_id (parent_id)     
+) ENGINE=InnoDB;
+
+insert into t1 (id, parent_id, name) values
+(10,NULL,'A'),
+(20,10,'B'),
+(30,10,'C'),
+(40,NULL,'D'),
+(50,40,'E'),
+(60,40,'F'),
+(70,NULL,'J');
+
+SELECT id FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1;
+--echo This must show type=index, extra=Using where
+explain SELECT * FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1;
+SELECT * FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1;
+drop table t1;

=== modified file 'sql/item_func.cc'
--- a/sql/item_func.cc	2008-12-14 11:36:15 +0000
+++ b/sql/item_func.cc	2008-12-24 10:22:24 +0000
@@ -1368,6 +1368,38 @@ void Item_func_div::fix_length_and_dec()
 longlong Item_func_int_div::val_int()
 {
   DBUG_ASSERT(fixed == 1);
+
+  /*
+    Perform division using DECIMAL math if either of the operands has a
+    non-integer type
+  */
+  if (args[0]->result_type() != INT_RESULT ||
+      args[1]->result_type() != INT_RESULT)
+  {
+    my_decimal value0, value1, tmp;
+    my_decimal *val0, *val1;
+    longlong res;
+    int err;
+
+    val0= args[0]->val_decimal(&value0);
+    val1= args[1]->val_decimal(&value1);
+    if ((null_value= (args[0]->null_value || args[1]->null_value)))
+      return 0;
+
+    if ((err= my_decimal_div(E_DEC_FATAL_ERROR & ~E_DEC_DIV_ZERO, &tmp,
+                             val0, val1, 0)) > 3)
+    {
+      if (err == E_DEC_DIV_ZERO)
+        signal_divide_by_null();
+      return 0;
+    }
+
+    if (my_decimal2int(E_DEC_FATAL_ERROR, &tmp, unsigned_flag, &res) &
+        E_DEC_OVERFLOW)
+      my_error(ER_WARN_DATA_OUT_OF_RANGE, MYF(0), name, 1);
+    return res;
+  }
+  
   longlong value=args[0]->val_int();
   longlong val2=args[1]->val_int();
   if ((null_value= (args[0]->null_value || args[1]->null_value)))

=== modified file 'sql/sql_base.cc'
--- a/sql/sql_base.cc	2008-12-27 01:32:33 +0000
+++ b/sql/sql_base.cc	2008-12-29 16:40:21 +0000
@@ -6523,7 +6523,14 @@ int setup_wild(THD *thd, TABLE_LIST *tab
     /* make * substituting permanent */
     SELECT_LEX *select_lex= thd->lex->current_select;
     select_lex->with_wild= 0;
-    select_lex->item_list= fields;
+
+    /*
+      The assignment below is translated to memcpy() call (at least on some
+      platforms). memcpy() expects that source and destination areas do not
+      overlap. That problem was detected by valgrind.
+    */
+    if (&select_lex->item_list != &fields)
+      select_lex->item_list= fields;
 
     thd->restore_active_arena(arena, &backup);
   }

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2008-12-27 19:26:43 +0000
+++ b/sql/sql_select.cc	2008-12-29 17:06:12 +0000
@@ -18734,9 +18734,9 @@ test_if_skip_sort_order(JOIN_TAB *tab,OR
           }
           if (tab->pre_idx_push_select_cond)
           {
+            tab->select_cond= tab->pre_idx_push_select_cond;
             if (tab->select)
               tab->select->cond= tab->select_cond;
-            tab->select_cond= tab->pre_idx_push_select_cond;
           }
           table->file->ha_index_or_rnd_end();
           if (join->select_options & SELECT_DESCRIBE)

Thread
bzr commit into mysql-6.0-opt branch (sergefp:2759)Sergey Petrunia3 Jan