List:Commits« Previous MessageNext Message »
From:Ole John Aske Date:September 21 2010 11:41am
Subject:bzr commit into mysql-5.1-telco-7.0-spj-scan-vs-scan branch
(ole.john.aske:3286)
View as plain text  
#At file:///net/fimafeng09/export/home/tmp/oleja/mysql/mysql-5.1-telco-7.0-spj-scan-scan/ based on revid:ole.john.aske@stripped

 3286 Ole John Aske	2010-09-21
      sps-svs: Pushing a join with 'index_merge' as the root operation will 
      identify the root as a AT_MULTI_PRIMARY_KEY from the AQP module.
      
      This will be represented as a lookup operation in the query tree. However, we failed
      to identify is as such in is_lookup_operation(), which might cause a 'lookup-scan'
      query to be pushed.
      
      As 'lookup-scan' is currently not supported, this resulted in an 'error 20002'

    modified:
      mysql-test/suite/ndb/r/ndb_join_pushdown.result
      mysql-test/suite/ndb/t/ndb_join_pushdown.test
      sql/ha_ndbcluster.cc
=== modified file 'mysql-test/suite/ndb/r/ndb_join_pushdown.result'
--- a/mysql-test/suite/ndb/r/ndb_join_pushdown.result	2010-09-21 06:33:27 +0000
+++ b/mysql-test/suite/ndb/r/ndb_join_pushdown.result	2010-09-21 11:41:05 +0000
@@ -3461,6 +3461,17 @@ left join t1 as x5 on x4.a=x5.b;
 count(*)
 1885
 set ndb_join_pushdown=on;
+explain select count(*) from t1 as x1
+join t1 as x2 on x1.a=x2.b
+where x1.pk = 1 or x1.u=1;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	x1	index_merge	PRIMARY,ix2	ix2,PRIMARY	4,4	NULL	2	Using sort_union(ix2,PRIMARY); Using where with pushed condition
+1	SIMPLE	x2	ref	ix1	ix1	5	test.x1.a	1	Using where
+select count(*) from t1 as x1
+join t1 as x2 on x1.a=x2.b
+where x1.pk = 1 or x1.u=1;
+count(*)
+13
 set ndb_join_pushdown=on;
 explain
 select straight_join * from t1 as table1

=== modified file 'mysql-test/suite/ndb/t/ndb_join_pushdown.test'
--- a/mysql-test/suite/ndb/t/ndb_join_pushdown.test	2010-09-21 06:33:27 +0000
+++ b/mysql-test/suite/ndb/t/ndb_join_pushdown.test	2010-09-21 11:41:05 +0000
@@ -2461,6 +2461,21 @@ left join t1 as x4 on x3.u=x4.pk
 left join t1 as x5 on x4.a=x5.b;
 set ndb_join_pushdown=on;
 
+
+############################
+# Testcase for 'Got error 20002 'Unknown error code' from NDBCLUSTER'
+# Caused by failure to identify AT_MULTI_PRIMARY_KEY as a lookup operation.
+# This in turn caused a pushed 'lookup-scan' query to be produced - which we don't support
+
+# Should not be pushed (lookup-scan query)
+explain select count(*) from t1 as x1
+ join t1 as x2 on x1.a=x2.b
+ where x1.pk = 1 or x1.u=1;
+
+select count(*) from t1 as x1
+ join t1 as x2 on x1.a=x2.b
+ where x1.pk = 1 or x1.u=1;
+
 ############################
 # Testcase which forced us to ditch using the 'global cursor'
 # on the NdbQuery result set from mysqld.

=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc	2010-09-21 06:33:27 +0000
+++ b/sql/ha_ndbcluster.cc	2010-09-21 11:41:05 +0000
@@ -663,6 +663,7 @@ static const char* get_referred_table_ac
 static bool is_lookup_operation(AQP::enum_access_type accessType)
 {
   return (accessType == AQP::AT_PRIMARY_KEY ||
+          accessType == AQP::AT_MULTI_PRIMARY_KEY ||
           accessType == AQP::AT_UNIQUE_KEY);
 }
 
@@ -1287,9 +1288,7 @@ ha_ndbcluster::make_pushed_join(AQP::Joi
      */
     if (push_cnt == 0)
     {
-      if (access_type == AQP::AT_PRIMARY_KEY ||
-          access_type == AQP::AT_MULTI_PRIMARY_KEY ||
-          access_type == AQP::AT_UNIQUE_KEY)
+      if (is_lookup_operation(access_type))
       {
         const KEY *key= &table->key_info[join_root->get_index_no()];
         const NdbQueryOperand* root_key[ndb_pushed_join::MAX_KEY_PART+1]= {NULL};


Attachment: [text/bzr-bundle] bzr/ole.john.aske@sun.com-20100921114105-n3rpv6kn7b741bag.bundle
Thread
bzr commit into mysql-5.1-telco-7.0-spj-scan-vs-scan branch(ole.john.aske:3286) Ole John Aske21 Sep