MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Tor Didriksen Date:May 18 2010 9:27am
Subject:bzr commit into mysql-next-mr-bugfixing branch (tor.didriksen:3180) Bug#53236
View as plain text  
#At file:///export/home/didrik/mysqldev-next-mr/next-mr-opt-backporting-br1/ based on revid:guilhem@stripped

 3180 Tor Didriksen	2010-05-18
      Bug#53236 Segfault in DTCollation::set(DTCollation&)
      
      Backport of tor.didriksen@stripped
      Backported even though the test does not fail in this tree.
      
      Don't call member functions for a NIL pointer.
     @ mysql-test/r/subselect4.result
        Add test case.
     @ mysql-test/t/subselect4.test
        Add test case.
     @ sql/sql_select.cc
        If the (virtual) member function clone_item() returns NULL,
        there is no substitution to be made, and we don't need to set the collation.
        The test was invoking Item_cache::clone_item()

    modified:
      mysql-test/r/subselect4.result
      mysql-test/t/subselect4.test
      sql/sql_select.cc
=== modified file 'mysql-test/r/subselect4.result'
--- a/mysql-test/r/subselect4.result	2010-05-14 11:22:27 +0000
+++ b/mysql-test/r/subselect4.result	2010-05-18 09:27:25 +0000
@@ -474,3 +474,28 @@ id
 80
 90
 drop table t1,t2,t3,t4;
+#
+# Bug#53236 Segfault in DTCollation::set(DTCollation&)
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_varchar VARCHAR(1),
+PRIMARY KEY (pk)
+)
+;
+INSERT INTO t1 (col_varchar) 
+VALUES
+('w'),
+('m')
+;
+SELECT  table1.pk
+FROM ( t1 AS table1 JOIN t1 AS table2 ON (table1.col_varchar =
+table2.col_varchar) ) 
+WHERE ( 1, 2 ) IN ( SELECT SUBQUERY1_t1.pk AS SUBQUERY1_field1,
+SUBQUERY1_t1.pk AS SUBQUERY1_field2
+FROM ( t1 AS SUBQUERY1_t1 JOIN t1 AS SUBQUERY1_t2
+ON (SUBQUERY1_t2.col_varchar =
+SUBQUERY1_t1.col_varchar) ) ) 
+;
+pk
+drop table t1;

=== modified file 'mysql-test/t/subselect4.test'
--- a/mysql-test/t/subselect4.test	2010-05-14 08:14:09 +0000
+++ b/mysql-test/t/subselect4.test	2010-05-18 09:27:25 +0000
@@ -436,3 +436,32 @@ WHERE 1 IN(SELECT 1
                                  FROM t1)));
 
 drop table t1,t2,t3,t4;
+
+--echo #
+--echo # Bug#53236 Segfault in DTCollation::set(DTCollation&)
+--echo #
+
+CREATE TABLE t1 (
+  pk INTEGER AUTO_INCREMENT,
+  col_varchar VARCHAR(1),
+  PRIMARY KEY (pk)
+)
+;
+
+INSERT INTO t1 (col_varchar) 
+VALUES
+('w'),
+('m')
+;
+
+SELECT  table1.pk
+FROM ( t1 AS table1 JOIN t1 AS table2 ON (table1.col_varchar =
+                                          table2.col_varchar) ) 
+WHERE ( 1, 2 ) IN ( SELECT SUBQUERY1_t1.pk AS SUBQUERY1_field1,
+                           SUBQUERY1_t1.pk AS SUBQUERY1_field2
+                    FROM ( t1 AS SUBQUERY1_t1 JOIN t1 AS SUBQUERY1_t2
+                           ON (SUBQUERY1_t2.col_varchar =
+                               SUBQUERY1_t1.col_varchar) ) ) 
+;
+
+drop table t1;

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2010-05-14 13:10:30 +0000
+++ b/sql/sql_select.cc	2010-05-18 09:27:25 +0000
@@ -12443,10 +12443,9 @@ change_cond_ref_to_const(THD *thd, I_Lis
        left_item->collation.collation == value->collation.collation))
   {
     Item *tmp=value->clone_item();
-    tmp->collation.set(right_item->collation);
-    
     if (tmp)
     {
+      tmp->collation.set(right_item->collation);
       thd->change_item_tree(args + 1, tmp);
       func->update_used_tables();
       if ((functype == Item_func::EQ_FUNC || functype == Item_func::EQUAL_FUNC)
@@ -12467,10 +12466,9 @@ change_cond_ref_to_const(THD *thd, I_Lis
             right_item->collation.collation == value->collation.collation))
   {
     Item *tmp= value->clone_item();
-    tmp->collation.set(left_item->collation);
-    
     if (tmp)
     {
+      tmp->collation.set(left_item->collation);
       thd->change_item_tree(args, tmp);
       value= tmp;
       func->update_used_tables();


Attachment: [text/bzr-bundle] bzr/tor.didriksen@sun.com-20100518092725-8wckfcxv9hjmj4zb.bundle
Thread
bzr commit into mysql-next-mr-bugfixing branch (tor.didriksen:3180) Bug#53236Tor Didriksen18 May