From: Ole John Aske Date: December 7 2010 5:20pm Subject: bzr commit into mysql-5.1-telco-7.1 branch (ole.john.aske:4015) Bug#58791 List-Archive: http://lists.mysql.com/commits/126246 X-Bug: 58791 Message-Id: <20101207172040.3B82D223@fimafeng09.norway.sun.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============7832266978274830670==" --===============7832266978274830670== MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline #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-07 Fix for bug#58791, for review. 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-07 17:20:34 +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 +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-11-29 15:43:51 +0000 +++ b/mysql-test/suite/ndb/t/ndb_condition_pushdown.test 2010-12-07 17:20:34 +0000 @@ -2320,6 +2320,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, ) 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-01 12:06:43 +0000 +++ b/sql/ha_ndbcluster.cc 2010-12-07 17:20:34 +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) --===============7832266978274830670== MIME-Version: 1.0 Content-Type: text/bzr-bundle; charset="us-ascii"; name="bzr/ole.john.aske@stripped" Content-Transfer-Encoding: 7bit Content-Disposition: inline # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: ole.john.aske@stripped\ # sgdbngb15z41e93m # target_branch: file:///net/fimafeng09/export/home/tmp/oleja/mysql\ # /mysql-5.1-telco-7.1/ # testament_sha1: ec2c66b0ddfe0796806b1966386f8978b9c8aba9 # timestamp: 2010-12-07 18:20:40 +0100 # base_revision_id: pekka@stripped # # Begin bundle IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWREtvo0AA75fgGAwWff//3+3 tmC////7YAgvnnboBoFDu3EJ2ADQB1hpAhNPUeqPZSb1MKeo0aeiAMhoyAAMjygSUTQKntpoU81T 0NEyg2o9QGnqaD1GgBoADjJk0MRiaMAjATCAMBNNGmRoBhiUyBT9UyHqaM0T1HqAAA00GIBoAaDj Jk0MRiaMAjATCAMBNNGmRoBhJIE0BGmQCaYCTBGkyTMnqIekNGnqaeoSAGgbIBnNcYGmMo6pZdux V1Benr8Vr9xFQxiLKTtohPR/O90rDdGJRQ+NasDlphXpqSIMlRyUn6oTfChn3FEf3fPe6DUXASLn AEUDNexyyUw0/TYVFAoww/2frZL0WyfI6ZSSSQEMgEzp4mFDJWthwuIPZcRkjensycbLwUJ9Ghzo rLOyWNIM1SI87cgpWWVIRhnzPOZlh8STapq92VpB75DlIBUS6VgNnr1/a7oU3dZSnBZZy3Yu333V VByv2MXFxUPR9TC1iskOK1IeD31ihXZR9ZbnhUzEtHRjyX57fIsVVV0Ypiw49ql+EhA45EWZ4K2E yPjnSD1rfYQEVfq5HcNxa305+U9xLIPH5TQJze76Pf+/kfgFXxdpsF56fHt18gcK8YYyG8ykCjke YcQDyHZrcsyvyPLJkXiOYoIhyeXiOMavD7UwfL78/nckRWAr0kZVYmBhhiJ2fjin5aFoXyCnI4Lp gFfvA5j6O5hT0a3oRMcyS/5iMdxutk+gRAgKkcx8IKkGkwhoEmFBax1esjGw8PvHZUnC/Bgk7QPD AYpMIJcqAD1YNxl+LwdlX9HRuiF7CMwYkFAqjRKDrJUhqI4aETHqj3W5yYjBSyBUIjSPcYXHHPM4 EFWqS6wqE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