List:Commits« Previous MessageNext Message »
From:Ole John Aske Date:December 8 2010 8:03am
Subject:bzr commit into mysql-5.1-telco-7.1 branch (ole.john.aske:4015) Bug#58791
View as plain text  
#At file:///net/fimafeng09/export/home/tmp/oleja/mysql/mysql-5.1-telco-7.1/ based on revid:pekka@stripped

 4015 Ole John Aske	2010-12-08
      Updated fix for bug#58791 - Added missing '--sorted_result' to test
      
      ha_ndbcluster::cond_push() should reject to push any condition which refer fields
      outside the scope of 'this' table.

    modified:
      mysql-test/suite/ndb/r/ndb_condition_pushdown.result
      mysql-test/suite/ndb/t/ndb_condition_pushdown.test
      sql/ha_ndbcluster.cc
=== modified file 'mysql-test/suite/ndb/r/ndb_condition_pushdown.result'
--- a/mysql-test/suite/ndb/r/ndb_condition_pushdown.result	2010-11-29 15:43:51 +0000
+++ b/mysql-test/suite/ndb/r/ndb_condition_pushdown.result	2010-12-08 08:03:44 +0000
@@ -2247,5 +2247,18 @@ id	select_type	table	type	possible_keys	
 Warnings:
 Note	1003	select `test`.`t2`.`c` AS `c`,count(distinct `test`.`t2`.`a`) AS `count(distinct t2.a)` from `test`.`tx` join `test`.`tx` `t2` where ((`test`.`tx`.`b` = `test`.`t2`.`d`) and (`test`.`tx`.`a` = `test`.`t2`.`c`) and (`test`.`t2`.`a` = 4)) group by `test`.`t2`.`c`
 drop table tx;
+create table t (pk1 int, pk2 int, primary key(pk1,pk2)) engine = ndb;
+insert into t values (1,0), (2,0), (3,0), (4,0);
+set engine_condition_pushdown=1;
+select table1.pk1, table2.pk1, table1.pk2, table2.pk2
+from t as table1, t as table2
+where table2.pk1 in (0,3) and
+(table1.pk1 = 7 or table2.pk1 = 3);
+pk1	pk1	pk2	pk2
+1	3	0	0
+2	3	0	0
+3	3	0	0
+4	3	0	0
+drop table t;
 set engine_condition_pushdown = @old_ecpd;
 DROP TABLE t1,t2,t3,t4,t5;

=== modified file 'mysql-test/suite/ndb/t/ndb_condition_pushdown.test'
--- a/mysql-test/suite/ndb/t/ndb_condition_pushdown.test	2010-11-29 15:43:51 +0000
+++ b/mysql-test/suite/ndb/t/ndb_condition_pushdown.test	2010-12-08 08:03:44 +0000
@@ -2320,6 +2320,28 @@ group by t2.c;
 
 drop table tx;
 
+
+# Bug#58791 Incorrect result as Cluster may fail to reject an unpushable condition
+
+create table t (pk1 int, pk2 int, primary key(pk1,pk2)) engine = ndb;
+insert into t values (1,0), (2,0), (3,0), (4,0);
+
+set engine_condition_pushdown=1;
+
+# Multiple instances of same table (t as table<n>, ) confused 
+# ha_ndbcluster::cond_push() which accepted
+# '(table1.pk1 = 7 or table2.pk1 = 3)' as a pushable cond.
+# for 'table2'
+#
+
+--sorted_result
+select table1.pk1, table2.pk1, table1.pk2, table2.pk2
+ from t as table1, t as table2
+ where table2.pk1 in (0,3) and
+   (table1.pk1 = 7 or table2.pk1 = 3);
+
+drop table t;
+
 set engine_condition_pushdown = @old_ecpd;
 DROP TABLE t1,t2,t3,t4,t5;
 

=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc	2010-12-01 12:06:43 +0000
+++ b/sql/ha_ndbcluster.cc	2010-12-08 08:03:44 +0000
@@ -12700,6 +12700,18 @@ COND* 
 ha_ndbcluster::cond_push(const COND *cond) 
 { 
   DBUG_ENTER("cond_push");
+
+  if (cond->used_tables() & ~table->map)
+  {
+    /**
+     * 'cond' refers fields from other tables, or other instances 
+     * of this table, -> reject it.
+     * (Optimizer need to have a better understanding of what is 
+     *  pushable by each handler.)
+     */
+    DBUG_EXECUTE("where",print_where((COND *)cond, "Rejected cond_push", QT_ORDINARY););
+    DBUG_RETURN(NULL);
+  }
   if (!m_cond) 
     m_cond= new ha_ndbcluster_cond;
   if (!m_cond)


Attachment: [text/bzr-bundle] bzr/ole.john.aske@oracle.com-20101208080344-2g5tgkyrr1ri39jb.bundle
Thread
bzr commit into mysql-5.1-telco-7.1 branch (ole.john.aske:4015) Bug#58791Ole John Aske8 Dec