List:Commits« Previous MessageNext Message »
From:Tor Didriksen Date:June 30 2011 12:57pm
Subject:bzr push into mysql-trunk branch (tor.didriksen:3248 to 3249) Bug#12620084
View as plain text  
 3249 Tor Didriksen	2011-06-30
      Bug#12620084 ASSERTION WHEN CHECKING FIELD_TYPES[FIELD_POS] AND IT'S MYSQL_TYPE_NULL
     @ mysql-test/r/func_if.result
        New test case.
     @ mysql-test/t/func_if.test
        New test case.
     @ sql/item_cmpfunc.cc
        In Item_func_if::fix_length_and_dec():
        Apply same logic as in agg_result_type(), i.e.
        "NULL items don't affect the result"

    modified:
      mysql-test/r/func_if.result
      mysql-test/t/func_if.test
      sql/item_cmpfunc.cc
 3248 Marko Mäkelä	2011-06-30 [merge]
      Merge mysql-5.5 to mysql-trunk.

    modified:
      mysql-test/suite/innodb/r/innodb-index.result
      mysql-test/suite/innodb/t/innodb-index.test
      storage/innobase/row/row0row.c
=== modified file 'mysql-test/r/func_if.result'
--- a/mysql-test/r/func_if.result	2010-09-13 09:58:11 +0000
+++ b/mysql-test/r/func_if.result	2011-06-30 12:57:20 +0000
@@ -196,3 +196,19 @@ c
 NULL
 0
 DROP TABLE t1;
+#
+# Bug#12620084
+# ASSERTION WHEN CHECKING FIELD_TYPES[FIELD_POS] AND IT'S MYSQL_TYPE_NULL
+#
+SELECT if(0, (SELECT min('hello')), NULL);
+if(0, (SELECT min('hello')), NULL)
+NULL
+SELECT if(1, (SELECT min('hello')), NULL);
+if(1, (SELECT min('hello')), NULL)
+hello
+SELECT if(0, NULL, (SELECT min('hello')));
+if(0, NULL, (SELECT min('hello')))
+hello
+SELECT if(1, NULL, (SELECT min('hello')));
+if(1, NULL, (SELECT min('hello')))
+NULL

=== modified file 'mysql-test/t/func_if.test'
--- a/mysql-test/t/func_if.test	2010-09-13 09:58:11 +0000
+++ b/mysql-test/t/func_if.test	2011-06-30 12:57:20 +0000
@@ -177,3 +177,13 @@ INSERT INTO t1 VALUES (NULL, 0), (NULL, 
 SELECT IF(b, (SELECT a FROM t1 LIMIT 1), b) c FROM t1 GROUP BY c;
 
 DROP TABLE t1;
+
+--echo #
+--echo # Bug#12620084
+--echo # ASSERTION WHEN CHECKING FIELD_TYPES[FIELD_POS] AND IT'S MYSQL_TYPE_NULL
+--echo #
+
+SELECT if(0, (SELECT min('hello')), NULL);
+SELECT if(1, (SELECT min('hello')), NULL);
+SELECT if(0, NULL, (SELECT min('hello')));
+SELECT if(1, NULL, (SELECT min('hello')));

=== modified file 'sql/item_cmpfunc.cc'
--- a/sql/item_cmpfunc.cc	2011-06-24 09:29:07 +0000
+++ b/sql/item_cmpfunc.cc	2011-06-30 12:57:20 +0000
@@ -2732,7 +2732,7 @@ Item_func_if::fix_length_and_dec()
   bool null1=args[1]->const_item() && args[1]->null_value;
   bool null2=args[2]->const_item() && args[2]->null_value;
 
-  if (null1)
+  if (null1 && args[2]->type() != NULL_ITEM)
   {
     cached_result_type= arg2_type;
     collation.set(args[2]->collation);
@@ -2741,7 +2741,7 @@ Item_func_if::fix_length_and_dec()
     return;
   }
 
-  if (null2)
+  if (null2 && args[1]->type() != NULL_ITEM)
   {
     cached_result_type= arg1_type;
     collation.set(args[1]->collation);

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk branch (tor.didriksen:3248 to 3249) Bug#12620084Tor Didriksen4 Jul