List:Commits« Previous MessageNext Message »
From:Ole John Aske Date:September 21 2010 11:42am
Subject:bzr push into mysql-5.1-telco-7.0-spj-scan-vs-scan branch
(ole.john.aske:3285 to 3286)
View as plain text  
 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
 3285 Ole John Aske	2010-09-21
      spj-svs: Refactored SPJ API, SE-handler interface, and handling of resultsets created by SPJ.
      
      Rational for this rewrite is that the 'global cursor' on the NdbQuery has proved insufficient for handling
      a pushed join consisting of scan - scan - See added MTR testcase.
      
      In this commit we introduce 'local cursors' on each NdbQueryOperation. These may be itterated to 
      'first' or 'next' position. All navigation on these local cursors are with respect to any parent
      dependencies, such that we will get an 'EndOfScan' status when there are no more 'next' results
      on an operations which depends on the current parent(s).
      
      In order to clean up the code, the global cursor has been reimplemented on top of the local cursors.
      Furthermore, logic for elimination of NULL rows in inner joins and imcomplete batches, has been moved
      from the resultset iteration into ::handleBatchComplete() which now filters away NULL rows before
      any itteration is done on the resultset.
      This enabled us to remove the enum states 'IterState' and 'ScanRowResults'.
      
      SE-handler interface has been extended with ::index_next_pushed() which provides the interface 
      to 'next' itterating on the local cursor
      
      NDB handler implementation has been changed to use the local cursors instead of the global cursor.

    modified:
      mysql-test/suite/ndb/r/ndb_join_pushdown.result
      mysql-test/suite/ndb/t/ndb_join_pushdown.test
      sql/ha_ndbcluster.cc
      sql/ha_ndbcluster.h
      sql/handler.h
      sql/sql_select.cc
      storage/ndb/include/ndbapi/NdbQueryOperation.hpp
      storage/ndb/src/ndbapi/NdbQueryOperation.cpp
      storage/ndb/src/ndbapi/NdbQueryOperationImpl.hpp
=== 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 push into mysql-5.1-telco-7.0-spj-scan-vs-scan branch(ole.john.aske:3285 to 3286) Ole John Aske21 Sep