List:Commits« Previous MessageNext Message »
From:Ole John Aske Date:December 7 2010 5:27pm
Subject:bzr push into mysql-5.1-telco-7.0-spj-scan-vs-scan branch
(ole.john.aske:3391 to 3392) Bug#58791
View as plain text  
 3392 Ole John Aske	2010-12-07
      SPJ-scan-scan: Cherry picked fix for bug#58791: Incorrect result as Cluster may fail to reject an unpushable condition.

    modified:
      mysql-test/suite/ndb/r/ndb_condition_pushdown.result
      mysql-test/suite/ndb/t/ndb_condition_pushdown.test
      sql/ha_ndbcluster.cc
 3391 Ole John Aske	2010-12-07
      SPJ-scan-scan: Updated cherry picked fix for bug 58490 to latest fix being reviewed

    modified:
      sql/sql_select.cc
=== modified file 'mysql-test/suite/ndb/r/ndb_condition_pushdown.result'
--- a/mysql-test/suite/ndb/r/ndb_condition_pushdown.result	2010-12-02 08:51:17 +0000
+++ b/mysql-test/suite/ndb/r/ndb_condition_pushdown.result	2010-12-07 17:27:02 +0000
@@ -2285,5 +2285,18 @@ Note	1644	Table 't2' is not pushable: GR
 Note	1644	Table 'tx' is not pushable: GROUP BY cannot be done using index on grouped columns.
 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
+4	3	0	0
+3	3	0	0
+2	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-12-01 22:00:42 +0000
+++ b/mysql-test/suite/ndb/t/ndb_condition_pushdown.test	2010-12-07 17:27:02 +0000
@@ -2345,6 +2345,26 @@ 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'
+#
+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-06 11:38:21 +0000
+++ b/sql/ha_ndbcluster.cc	2010-12-07 17:27:02 +0000
@@ -15141,6 +15141,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)

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-5.1-telco-7.0-spj-scan-vs-scan branch(ole.john.aske:3391 to 3392) Bug#58791Ole John Aske7 Dec