List:Commits« Previous MessageNext Message »
From:Jan Wedvik Date:May 26 2011 2:46pm
Subject:bzr push into mysql-5.1-telco-7.0 branch (jan.wedvik:4423 to 4424)
View as plain text  
 4424 Jan Wedvik	2011-05-26
      This commit concerns pushed queries (those using NdbQuery etc.).
      This is a fix for an error that would occur when pushing an index scan that is sorted on a string field.
      The problem was an assumption that compare_ndbrecord() would always return 0,-1 or 1, when it can in fact return any
      number. This could cause results to be sorted in the wrong order, or mysqld to loop for ever.

    modified:
      storage/ndb/src/ndbapi/NdbQueryOperation.cpp
 4423 Jonas Oreland	2011-05-26
      ndb - fix bug in DbtcProxy...worker instances are named 1..N

    modified:
      storage/ndb/src/kernel/blocks/dbtc/DbtcProxy.cpp
=== modified file 'storage/ndb/src/ndbapi/NdbQueryOperation.cpp'
--- a/storage/ndb/src/ndbapi/NdbQueryOperation.cpp	2011-05-11 13:31:44 +0000
+++ b/storage/ndb/src/ndbapi/NdbQueryOperation.cpp	2011-05-26 14:44:59 +0000
@@ -3186,18 +3186,19 @@ NdbQueryImpl::OrderedFragSet::reorganize
     while(first<last)
     {
       assert(middle<m_activeFragCount);
-      switch(compare(*m_activeFrags[m_activeFragCount-1], 
-                     *m_activeFrags[middle]))
+      const int cmpRes = compare(*m_activeFrags[m_activeFragCount-1], 
+                                 *m_activeFrags[middle]);
+      if (cmpRes < 0)
       {
-      case -1:
         first = middle + 1;
-        break;
-      case 0:
+      }
+      else if (cmpRes == 0)
+      {
         last = first = middle;
-        break;
-      case 1:
+      }
+      else
+      {
         last = middle;
-        break;
       }
       middle = (first+last)/2;
     }
@@ -3246,7 +3247,7 @@ NdbQueryImpl::OrderedFragSet::add(NdbRoo
       int current = 0;
       // Insert the new frag such that the array remains sorted.
       while(current<m_activeFragCount && 
-            compare(frag, *m_activeFrags[current])==-1)
+            compare(frag, *m_activeFrags[current]) < 0)
       {
         current++;
       }
@@ -3290,7 +3291,7 @@ NdbQueryImpl::OrderedFragSet::verifySort
 {
   for(int i = 0; i<m_activeFragCount-2; i++)
   {
-    if(compare(*m_activeFrags[i], *m_activeFrags[i+1])==-1)
+    if(compare(*m_activeFrags[i], *m_activeFrags[i+1]) < 0)
     {
       assert(false);
       return false;
@@ -3303,7 +3304,7 @@ NdbQueryImpl::OrderedFragSet::verifySort
 /**
  * Compare frags such that f1<f2 if f1 is empty but f2 is not.
  * - Othewise compare record contents.
- * @return -1 if frag1<frag2, 0 if frag1 == frag2, otherwise 1.
+ * @return negative if frag1<frag2, 0 if frag1 == frag2, otherwise positive.
 */
 int
 NdbQueryImpl::OrderedFragSet::compare(const NdbRootFragment& frag1,

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-5.1-telco-7.0 branch (jan.wedvik:4423 to 4424) Jan Wedvik26 May