List:Commits« Previous MessageNext Message »
From:Ole John Aske Date:October 11 2010 9:48am
Subject:bzr commit into mysql-5.1-telco-7.0-spj-scan-vs-scan branch
(ole.john.aske:3307)
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:jan.wedvik@stripped

 3307 Ole John Aske	2010-10-11
      spj-svs: Recommited after 'bzr pull' to clear merge conflicts
      
      Fixed incorrect usage of info in NdbRecord to find the NdbQueryOperand* which 
      defined the value for a specific column in the partition key.
      
      Bug caused 'out of bound' read in m_bound.low[] and an assert when compiled with DEBUG.
      Includes testcase for the above.

    modified:
      mysql-test/suite/ndb/r/ndb_join_pushdown.result
      mysql-test/suite/ndb/t/ndb_join_pushdown.test
      storage/ndb/src/ndbapi/NdbQueryBuilder.cpp
=== modified file 'mysql-test/suite/ndb/r/ndb_join_pushdown.result'
--- a/mysql-test/suite/ndb/r/ndb_join_pushdown.result	2010-09-30 14:20:12 +0000
+++ b/mysql-test/suite/ndb/r/ndb_join_pushdown.result	2010-10-11 09:48:36 +0000
@@ -3875,6 +3875,14 @@ d	e	f	a	b	c	d	e	f	a	b	c
 1	2	3	6	7	8	1	2	3	1	2	4
 1	2	3	7	8	9	1	2	3	1	2	3
 1	2	3	7	8	9	1	2	3	1	2	4
+alter table t1 drop primary key, add primary key using hash (d,b,a,c);
+alter table t1 partition by key (b);
+create index ix1 on t1(b,d,a);
+explain
+select straight_join * from t1 x, t1 y where y.a=x.d and y.b=x.e;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	x	ALL	PRIMARY	NULL	NULL	NULL	8	Parent of 2 pushed join@1
+1	SIMPLE	y	ref	ix1	ix1	4	test.x.e	1	Child of pushed join@1; Using where
 pruned
 12
 const_pruned
@@ -4014,13 +4022,13 @@ LOCAL+REMOTE READS_SENT
 drop table spj_counts_at_startup;
 drop table spj_counts_at_end;
 scan_count
-1975
+1985
 pruned_scan_count
 7
 sorted_scan_count
 44
 pushed_queries_defined
-333
+334
 pushed_queries_dropped
 11
 pushed_queries_executed

=== modified file 'mysql-test/suite/ndb/t/ndb_join_pushdown.test'
--- a/mysql-test/suite/ndb/t/ndb_join_pushdown.test	2010-09-30 14:20:12 +0000
+++ b/mysql-test/suite/ndb/t/ndb_join_pushdown.test	2010-10-11 09:48:36 +0000
@@ -2771,6 +2771,18 @@ select straight_join * from t1 x, t1 y w
 --sorted_result
 select straight_join * from t1 x, t1 y where y.a=x.d and y.b=2;
 
+##########
+# Test pruned scan using an index:
+# Declaring PK as 'using hash' will prevent that PK is used as index
+# Declare PK / ix1 with mismatching column order will test correct
+# usage of NdbRecord::distkey_indexes[]
+##########
+alter table t1 drop primary key, add primary key using hash (d,b,a,c);
+alter table t1 partition by key (b);
+create index ix1 on t1(b,d,a);
+
+explain
+select straight_join * from t1 x, t1 y where y.a=x.d and y.b=x.e;
 
 # Verify pruned execution by comparing the NDB$INFO counters
 --disable_query_log

=== modified file 'storage/ndb/src/ndbapi/NdbQueryBuilder.cpp'
--- a/storage/ndb/src/ndbapi/NdbQueryBuilder.cpp	2010-09-24 07:29:43 +0000
+++ b/storage/ndb/src/ndbapi/NdbQueryBuilder.cpp	2010-10-11 09:48:36 +0000
@@ -2102,10 +2102,12 @@ NdbQueryIndexScanOperationDefImpl::appen
 
       for (unsigned i = 0; i < indexRecord->distkey_index_length; i++)
       {
-        unsigned keyNo = indexRecord->distkey_indexes[i];
-        assert(keyNo<distKeys);
-        assert(indexRecord->columns[keyNo].flags & NdbRecord::IsDistributionKey);
-        const NdbQueryOperandImpl* key = m_bound.low[keyNo];
+        const unsigned keyNo = indexRecord->distkey_indexes[i];
+        assert(keyNo<indexRecord->noOfColumns);
+        const NdbRecord::Attr& indexAttr = indexRecord->columns[keyNo];
+        assert(indexAttr.flags & NdbRecord::IsDistributionKey);
+        assert(indexAttr.index_attrId<m_bound.lowKeys);
+        const NdbQueryOperandImpl* key = m_bound.low[indexAttr.index_attrId];
 
         switch(key->getKind())
         {


Attachment: [text/bzr-bundle] bzr/ole.john.aske@oracle.com-20101011094836-yayn6gufqziknfcx.bundle
Thread
bzr commit into mysql-5.1-telco-7.0-spj-scan-vs-scan branch(ole.john.aske:3307) Ole John Aske11 Oct