List:Commits« Previous MessageNext Message »
From:Ole John Aske Date:October 11 2010 9:55am
Subject:bzr push into mysql-5.1-telco-7.0-spj-scan-vs-scan branch
(ole.john.aske:3306 to 3308)
View as plain text  
 3308 Ole John Aske	2010-10-11
      spj-svs: Fixed an undefined memory read
      
      Fixed a situation where an empty 'm_spjProjection' will cause 
      NdbQueryOperationDefImpl::appendChildProjection() to set the QueryTree flag 'NI_LINKED_ATTR' without
      appending a projection list to the serialized query tree.
      
      This fix will ensure that a serialized m_spjProjection list with size==0 will be included in these cases.
      
      No testcase as I can't think of any deterministic ways to make a testcase for an undefined memory read....

    modified:
      storage/ndb/src/ndbapi/NdbQueryBuilder.cpp
 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
 3306 Jan Wedvik	2010-10-07
      This commit adds methods for setting the parallelism for the root operation
      of a pushed scan query (to be less than the number of fragments).
      
      If you wish to test this, apply the patch below and run suitable SQL queries.
      
      -----------8<----------------
      === modified file 'sql/ha_ndbcluster.cc'
      --- sql/ha_ndbcluster.cc	2010-10-07 11:21:35 +0000
      +++ sql/ha_ndbcluster.cc	2010-10-07 10:56:58 +0000
      @@ -5205,6 +5205,11 @@ int ha_ndbcluster::ordered_index_scan(co
             ERR_RETURN(query->getNdbError());
           }
       
      +    if (!sorted)
      +    {
      +      query->getQueryOperation(0U)->setParallelism(1);
      +    }
      +
           if (pbound  && query->setBound(key_rec, pbound)!=0)
             ERR_RETURN(query->getNdbError());
       
      @@ -5393,6 +5398,7 @@ int ha_ndbcluster::full_table_scan(const
       
           m_thd_ndb->m_scan_count++;
           DBUG_ASSERT(!uses_blob_value(table->read_set));  // Can't have BLOB in pushed joins (yet)
      +    m_active_query->getQueryOperation(0U)->setParallelism(1);
         }
         else // if (check_if_pushable(NdbQueryOperationDef::TableScan))
         {
      
      -----------8<----------------

    modified:
      storage/ndb/include/kernel/signaldata/ScanTab.hpp
      storage/ndb/include/ndbapi/NdbQueryOperation.hpp
      storage/ndb/src/kernel/blocks/dbtc/Dbtc.hpp
      storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp
      storage/ndb/src/ndbapi/NdbQueryBuilderImpl.hpp
      storage/ndb/src/ndbapi/NdbQueryOperation.cpp
      storage/ndb/src/ndbapi/NdbQueryOperationImpl.hpp
      storage/ndb/src/ndbapi/ndberror.c
=== 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:55:24 +0000
@@ -1810,11 +1810,9 @@ public:
     m_pos(0),
     m_finished(false)
  {
-    if (size > 0) {
-      m_seq = buffer.alloc(1 + size/2);
-      assert (size <= 0xFFFF);
-      m_seq[0] = size;
-    }
+    m_seq = buffer.alloc(1 + size/2);
+    assert (size <= 0xFFFF);
+    m_seq[0] = size;
   }
 
   ~Uint16Sequence()
@@ -2102,10 +2100,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-20101011095524-c6k1ptd3zvc3ipl8.bundle
Thread
bzr push into mysql-5.1-telco-7.0-spj-scan-vs-scan branch(ole.john.aske:3306 to 3308) Ole John Aske11 Oct