List:Commits« Previous MessageNext Message »
From:Jonas Oreland Date:September 24 2010 8:07am
Subject:bzr commit into mysql-5.1-telco-7.0-spj-scan-vs-scan branch (jonas:3294)
View as plain text  
#At file:///home/jonas/src/70-spj-svs/ based on revid:jan.wedvik@stripped

 3294 Jonas Oreland	2010-09-24
      ndb - fix Dbspj handling of PRUNE_PATTERN

    modified:
      mysql-test/suite/ndb/r/ndb_join_pushdown.result
      mysql-test/suite/ndb/t/ndb_join_pushdown.test
      storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp
      storage/ndb/src/kernel/blocks/dbspj/Dbspj.hpp
      storage/ndb/src/kernel/blocks/dbspj/DbspjMain.cpp
      storage/ndb/src/kernel/vm/KeyDescriptor.hpp
=== modified file 'mysql-test/suite/ndb/r/ndb_join_pushdown.result'
--- a/mysql-test/suite/ndb/r/ndb_join_pushdown.result	2010-09-24 07:29:43 +0000
+++ b/mysql-test/suite/ndb/r/ndb_join_pushdown.result	2010-09-24 08:07:43 +0000
@@ -2967,6 +2967,13 @@ join t1 as t2 on t2.a = t1.c and t2.b = 
 join t1 as t3 on t3.a = t2.c;
 count(*)
 8988
+alter table t1 partition by key(a);
+select count(*)
+from t1
+join t1 as t2 on t2.a = t1.c
+join t1 as t3 on t3.a = t2.c and t3.b = t2.d;
+count(*)
+8990
 drop table t1;
 CREATE LOGFILE GROUP lg1
 ADD UNDOFILE 'undofile.dat'
@@ -3928,32 +3935,32 @@ and spj_counts_at_end.counter_name <> 'L
        and spj_counts_at_end.counter_name <> 'SCAN_BATCHES_RETURNED';
 counter_name	spj_counts_at_end.val - spj_counts_at_startup.val
 CONST_PRUNED_RANGE_SCANS_RECEIVED	6
-LOCAL_TABLE_SCANS_SENT	190
-PRUNED_RANGE_SCANS_RECEIVED	12
+LOCAL_TABLE_SCANS_SENT	192
+PRUNED_RANGE_SCANS_RECEIVED	14
 RANGE_SCANS_RECEIVED	195
-READS_NOT_FOUND	398
+READS_NOT_FOUND	402
 READS_RECEIVED	48
-SCAN_ROWS_RETURNED	42579
-TABLE_SCANS_RECEIVED	190
+SCAN_ROWS_RETURNED	63563
+TABLE_SCANS_RECEIVED	192
 select sum(spj_counts_at_end.val - spj_counts_at_startup.val) as 'LOCAL+REMOTE READS_SENT'
        from spj_counts_at_end, spj_counts_at_startup 
 where spj_counts_at_end.counter_name = spj_counts_at_startup.counter_name
 and (spj_counts_at_end.counter_name = 'LOCAL_READS_SENT'
        or spj_counts_at_end.counter_name = 'REMOTE_READS_SENT');
 LOCAL+REMOTE READS_SENT
-20088
+29082
 drop table spj_counts_at_startup;
 drop table spj_counts_at_end;
 scan_count
-1955
+1961
 pruned_scan_count
 7
 sorted_scan_count
 44
 pushed_queries_defined
-327
+328
 pushed_queries_dropped
 11
 pushed_queries_executed
-244
+245
 set ndb_join_pushdown = @save_ndb_join_pushdown;

=== modified file 'mysql-test/suite/ndb/t/ndb_join_pushdown.test'
--- a/mysql-test/suite/ndb/t/ndb_join_pushdown.test	2010-09-24 07:29:43 +0000
+++ b/mysql-test/suite/ndb/t/ndb_join_pushdown.test	2010-09-24 08:07:43 +0000
@@ -1933,6 +1933,12 @@ from t1
 join t1 as t2 on t2.a = t1.c and t2.b = t1.d
 join t1 as t3 on t3.a = t2.c;
 
+alter table t1 partition by key(a);
+select count(*)
+from t1
+join t1 as t2 on t2.a = t1.c
+join t1 as t3 on t3.a = t2.c and t3.b = t2.d;
+
 drop table t1;
 
 # Pushed join accessing disk data.

=== modified file 'storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp'
--- a/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp	2010-08-20 11:33:06 +0000
+++ b/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp	2010-09-24 08:07:43 +0000
@@ -6129,6 +6129,17 @@ Dbdict::createTab_local(Signal* signal,
     KeyDescriptor* desc= g_key_descriptor_pool.getPtr(tabPtr.i);
     new (desc) KeyDescriptor();
 
+    if (tabPtr.p->primaryTableId == RNIL)
+    {
+      jam();
+      desc->primaryTableId = createTabPtr.p->m_request.tableId;
+    }
+    else
+    {
+      jam();
+      desc->primaryTableId = tabPtr.p->primaryTableId;
+    }
+
     Uint32 key = 0;
     Ptr<AttributeRecord> attrPtr;
     LocalDLFifoList<AttributeRecord> list(c_attributeRecordPool,

=== modified file 'storage/ndb/src/kernel/blocks/dbspj/Dbspj.hpp'
--- a/storage/ndb/src/kernel/blocks/dbspj/Dbspj.hpp	2010-09-07 19:40:50 +0000
+++ b/storage/ndb/src/kernel/blocks/dbspj/Dbspj.hpp	2010-09-24 08:07:43 +0000
@@ -468,6 +468,7 @@ public:
       m_ref = 0; 
       m_fragId = fid; 
       m_state = SFH_NOT_STARTED;
+      m_rangePtrI = RNIL;
       reset_ranges();
     }
 
@@ -478,7 +479,7 @@ public:
     Uint32 m_ref;
 
     void reset_ranges() {
-      m_rangePtrI = RNIL;
+      // m_rangePtrI is explicitly managed...in code
       m_range_builder.m_range_cnt = m_range_builder.m_range_size = 0;
     }
     struct RangeBuilder 
@@ -531,7 +532,8 @@ public:
     TreeNode()
     : m_magic(MAGIC), m_state(TN_END),
       m_parentPtrI(RNIL), m_requestPtrI(0)
-    {}
+    {
+    }
 
     TreeNode(Uint32 request)
     : m_magic(MAGIC),
@@ -543,7 +545,7 @@ public:
       m_send.m_correlation = 0;
       m_send.m_keyInfoPtrI = RNIL;
       m_send.m_attrInfoPtrI = RNIL;
-    };
+    }
 
     const Uint32 m_magic;
     const struct OpInfo* m_info;
@@ -1075,6 +1077,7 @@ private:
                              const struct KeyDescriptor* desc);
 
   Uint32 computeHash(Signal*, BuildKeyReq&, Uint32 table, Uint32 keyInfoPtrI);
+  Uint32 computePartitionHash(Signal*, BuildKeyReq&, Uint32 table, Uint32 keyInfoPtrI);
   Uint32 getNodes(Signal*, BuildKeyReq&, Uint32 tableId);
 
   /**

=== modified file 'storage/ndb/src/kernel/blocks/dbspj/DbspjMain.cpp'
--- a/storage/ndb/src/kernel/blocks/dbspj/DbspjMain.cpp	2010-09-10 07:48:02 +0000
+++ b/storage/ndb/src/kernel/blocks/dbspj/DbspjMain.cpp	2010-09-24 08:07:43 +0000
@@ -27,6 +27,7 @@
 #include <signaldata/AttrInfo.hpp>
 #include <Interpreter.hpp>
 #include <AttributeHeader.hpp>
+#include <AttributeDescriptor.hpp>
 #include <KeyDescriptor.hpp>
 #include <md5_hash.hpp>
 #include <signaldata/TcKeyConf.hpp>
@@ -3456,6 +3457,57 @@ Dbspj::computeHash(Signal* signal,
   }
 }
 
+/**
+ * This function differs from computeHash in that *ptrI*
+ * only contains partition key (packed) and not full primary key
+ */
+Uint32
+Dbspj::computePartitionHash(Signal* signal,
+                            BuildKeyReq& dst, Uint32 tableId, Uint32 ptrI)
+{
+  SegmentedSectionPtr ptr;
+  getSection(ptr, ptrI);
+
+  /* NOTE:  md5_hash below require 64-bit alignment
+   */
+  const Uint32 MAX_KEY_SIZE_IN_LONG_WORDS=
+    (MAX_KEY_SIZE_IN_WORDS + 1) / 2;
+  Uint64 _space[MAX_KEY_SIZE_IN_LONG_WORDS];
+  Uint64 *tmp64 = _space;
+  Uint32 *tmp32 = (Uint32*)tmp64;
+  copy(tmp32, ptr);
+
+  const KeyDescriptor* desc = g_key_descriptor_pool.getPtr(tableId);
+  ndbrequire(desc != NULL);
+
+  bool need_xfrm = desc->hasCharAttr || desc->noOfVarKeys;
+  if (need_xfrm)
+  {
+    jam();
+    /**
+     * xfrm distribution key
+     */
+    Uint32 srcPos = 0;
+    Uint32 dstPos = 0;
+    Uint32 * src = tmp32;
+    Uint32 * dst = signal->theData+24;
+    for (Uint32 i = 0; i < desc->noOfKeyAttr; i++)
+    {
+      const KeyDescriptor::KeyAttr& keyAttr = desc->keyAttr[i];
+      if (AttributeDescriptor::getDKey(keyAttr.attributeDescriptor))
+      {
+        xfrm_attr(keyAttr.attributeDescriptor, keyAttr.charsetInfo,
+                  src, srcPos, dst, dstPos,
+                  NDB_ARRAY_SIZE(signal->theData) - 24);
+      }
+    }
+    tmp64 = (Uint64*)dst;
+  }
+
+  md5_hash(dst.hashInfo, tmp64, ptr.sz);
+  return 0;
+}
+
 Uint32
 Dbspj::getNodes(Signal* signal, BuildKeyReq& dst, Uint32 tableId)
 {
@@ -4373,8 +4425,9 @@ Dbspj::execDIH_SCAN_TAB_CONF(Signal* sig
     // but only parts in distribution key
 
     BuildKeyReq tmp;
-    Uint32 tableId = dst->tableId;
-    Uint32 err = computeHash(signal, tmp, tableId, data.m_constPrunePtrI);
+    Uint32 indexId = dst->tableId;
+    Uint32 tableId = g_key_descriptor_pool.getPtr(indexId)->primaryTableId;
+    Uint32 err = computePartitionHash(signal, tmp, tableId, data.m_constPrunePtrI);
     if (unlikely(err != 0))
       goto error;
 
@@ -4574,8 +4627,9 @@ Dbspj::scanIndex_parent_row(Signal* sign
 
       BuildKeyReq tmp;
       ScanFragReq * dst = (ScanFragReq*)data.m_scanFragReq;
-      Uint32 tableId = dst->tableId;
-      err = computeHash(signal, tmp, tableId, pruneKeyPtrI);
+      Uint32 indexId = dst->tableId;
+      Uint32 tableId = g_key_descriptor_pool.getPtr(indexId)->primaryTableId;
+      err = computePartitionHash(signal, tmp, tableId, pruneKeyPtrI);
       releaseSection(pruneKeyPtrI); // see ^ TODO
       if (unlikely(err != 0))
       {
@@ -4601,7 +4655,6 @@ Dbspj::scanIndex_parent_row(Signal* sign
       {
         jam();
         fragPtr.p->m_ref = tmp.receiverRef;
-        data.m_frags_not_complete++;
       }
       else
       {
@@ -4621,10 +4674,15 @@ Dbspj::scanIndex_parent_row(Signal* sign
        * and send to 1 or all resp.
        */
       list.first(fragPtr);
-      data.m_frags_not_complete++;
     }
     
     Uint32 ptrI = fragPtr.p->m_rangePtrI;
+    if (ptrI == RNIL)
+    {
+      jam();
+      data.m_frags_not_complete++;
+    }
+
     bool hasNull;
     if (treeNodePtr.p->m_bits & TreeNode::T_KEYINFO_CONSTRUCTED)
     {
@@ -4784,6 +4842,7 @@ Dbspj::scanIndex_send(Signal* signal,
     list.first(fragPtr);
     keyInfoPtrI = fragPtr.p->m_rangePtrI;
     ndbrequire(keyInfoPtrI != RNIL);
+    fragPtr.p->m_rangePtrI = RNIL;
   }
 
   Uint32 batchRange = 0;
@@ -4813,6 +4872,7 @@ Dbspj::scanIndex_send(Signal* signal,
         fragPtr.p->m_state = ScanFragHandle::SFH_COMPLETE;
         continue;
       }
+      fragPtr.p->m_rangePtrI = RNIL;
 
       /**
        * If we'll use sendSignal() and we need to send the attrInfo several

=== modified file 'storage/ndb/src/kernel/vm/KeyDescriptor.hpp'
--- a/storage/ndb/src/kernel/vm/KeyDescriptor.hpp	2009-05-26 18:53:34 +0000
+++ b/storage/ndb/src/kernel/vm/KeyDescriptor.hpp	2010-09-24 08:07:43 +0000
@@ -26,9 +26,11 @@
 struct KeyDescriptor
 {
   KeyDescriptor () { 
+    primaryTableId = RNIL;
     noOfKeyAttr = hasCharAttr = noOfDistrKeys = noOfVarKeys = 0; 
   }
   
+  Uint32 primaryTableId;
   Uint8 noOfKeyAttr;
   Uint8 hasCharAttr;
   Uint8 noOfDistrKeys;


Attachment: [text/bzr-bundle] bzr/jonas@mysql.com-20100924080743-wnay992t8u6fy211.bundle
Thread
bzr commit into mysql-5.1-telco-7.0-spj-scan-vs-scan branch (jonas:3294) Jonas Oreland24 Sep