List:Commits« Previous MessageNext Message »
From:jonas Date:October 20 2006 2:18pm
Subject:bk commit into 5.1 tree (jonas:1.2302) BUG#17929
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of jonas. When jonas does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2006-10-20 14:18:28+02:00, jonas@stripped +7 -0
  ndb - bug#17929
      guess which scan type to use in handler

  sql/ha_ndbcluster.cc@stripped, 2006-10-20 14:18:26+02:00, jonas@stripped +26 -4
    ndb - bug#17929
        guess which scan type to use in handler

  storage/ndb/include/ndbapi/NdbDictionary.hpp@stripped, 2006-10-20 14:18:26+02:00,
jonas@stripped +10 -0
    ndb - bug#17929
        guess which scan type to use in handler

  storage/ndb/include/ndbapi/NdbScanOperation.hpp@stripped, 2006-10-20 14:18:27+02:00,
jonas@stripped +2 -1
    ndb - bug#17929
        guess which scan type to use in handler

  storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp@stripped, 2006-10-20 14:18:27+02:00,
jonas@stripped +53 -0
    ndb - bug#17929
        guess which scan type to use in handler

  storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp@stripped, 2006-10-20 14:18:27+02:00,
jonas@stripped +1 -1
    ndb - bug#17929
        guess which scan type to use in handler

  storage/ndb/src/ndbapi/NdbScanOperation.cpp@stripped, 2006-10-20 14:18:27+02:00,
jonas@stripped +6 -1
    ndb - bug#17929
        guess which scan type to use in handler

  storage/ndb/tools/delete_all.cpp@stripped, 2006-10-20 14:18:27+02:00,
jonas@stripped +12 -1
    ndb - bug#17929
        guess which scan type to use in handler

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	jonas
# Host:	perch.ndb.mysql.com
# Root:	/home/jonas/src/51-work

--- 1.84/storage/ndb/include/ndbapi/NdbDictionary.hpp	2006-10-20 14:18:33 +02:00
+++ 1.85/storage/ndb/include/ndbapi/NdbDictionary.hpp	2006-10-20 14:18:33 +02:00
@@ -920,6 +920,16 @@
 
     bool getTemporary();
     void setTemporary(bool); 
+
+    /**
+     * Check if any of column in bitmaps are disk columns
+     *   returns bitmap of different columns
+     *     bit 0 = atleast 1 pk column is set
+     *     bit 1 = atleast 1 disk column set
+     *     bit 2 = atleast 1 non disk column set
+     *   passing NULL pointer will equal to bitmap with all columns set
+     */
+    int checkColumns(const Uint32* bitmap, unsigned len_in_bytes) const;
 #endif
 
     // these 2 are not de-doxygenated

--- 1.42/storage/ndb/include/ndbapi/NdbScanOperation.hpp	2006-10-20 14:18:33 +02:00
+++ 1.43/storage/ndb/include/ndbapi/NdbScanOperation.hpp	2006-10-20 14:18:33 +02:00
@@ -42,7 +42,8 @@
    * readTuples.
    */
   enum ScanFlag {
-    SF_TupScan = (1 << 16),     // scan TUP
+    SF_TupScan = (1 << 16),     // scan TUP order
+    SF_DiskScan = (2 << 16),    // scan in DISK order
     SF_OrderBy = (1 << 24),     // index scan in order
     SF_Descending = (2 << 24),  // index scan in descending order
     SF_ReadRangeNo = (4 << 24), // enable @ref get_range_no

--- 1.151/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp	2006-10-20 14:18:33 +02:00
+++ 1.152/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp	2006-10-20 14:18:33 +02:00
@@ -773,6 +773,7 @@
   m_keyLenInWords = 0;
   m_noOfDistributionKeys = 0;
   m_noOfBlobs = 0;
+  m_noOfDiskColumns = 0;
   Uint32 i, n;
   for (i = 0; i < m_columns.size(); i++) {
     NdbColumnImpl* col = m_columns[i];
@@ -785,6 +786,10 @@
     
     if (col->getBlobType())
       m_noOfBlobs++;
+
+    if (col->getStorageType() == NdbDictionary::Column::StorageTypeDisk)
+      m_noOfDiskColumns++;
+    
     col->m_keyInfoPos = ~0;
   }
   if (m_noOfDistributionKeys == m_noOfKeys) {
@@ -1068,6 +1073,54 @@
   }
   return 0;
 }
+
+int
+NdbDictionary::Table::checkColumns(const Uint32* map, Uint32 len) const
+{
+  int ret = 0;
+  Uint32 colCnt = m_impl.m_columns.size();
+  if (map == 0)
+  {
+    ret |= 1;
+    ret |= (m_impl.m_noOfDiskColumns) ? 2 : 0;
+    ret |= (colCnt > m_impl.m_noOfDiskColumns) ? 4 : 0;
+    return ret;
+  }
+
+  NdbColumnImpl** cols = m_impl.m_columns.getBase();
+  const char * ptr = reinterpret_cast<const char*>(map);
+  const char * end = ptr + len;
+  Uint32 no = 0;
+  while (ptr < end)
+  {
+    Uint32 val = (Uint32)* ptr;
+    Uint32 idx = 1;
+    for (Uint32 i = 0; i<8; i++)
+    {
+      if (val & idx)
+      {
+	if (cols[no]->getPrimaryKey())
+	  ret |= 1;
+	else
+	{
+	  if (cols[no]->getStorageType() == NdbDictionary::Column::StorageTypeDisk)
+	    ret |= 2;
+	  else
+	    ret |= 4;
+	}
+      }
+      no ++;
+      idx *= 2; 
+      if (no == colCnt)
+	return ret;
+    }
+    
+    ptr++;
+  }
+  return ret;
+}
+
+
   
 /**
  * NdbIndexImpl

--- 1.68/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp	2006-10-20 14:18:33 +02:00
+++ 1.69/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp	2006-10-20 14:18:33 +02:00
@@ -225,7 +225,7 @@
   // if all pk = dk then this is zero!
   Uint8 m_noOfDistributionKeys;
   Uint8 m_noOfBlobs;
-  
+  Uint8 m_noOfDiskColumns;
   Uint8 m_replicaCount;
 
   /**

--- 1.97/storage/ndb/src/ndbapi/NdbScanOperation.cpp	2006-10-20 14:18:33 +02:00
+++ 1.98/storage/ndb/src/ndbapi/NdbScanOperation.cpp	2006-10-20 14:18:33 +02:00
@@ -174,7 +174,12 @@
     }
   }
 #endif
-
+  if (scan_flags & SF_DiskScan)
+  {
+    tupScan = true;
+    m_no_disk_flag = false;
+  }
+  
   bool rangeScan = false;
   if (m_accessTable->m_indexType == NdbDictionary::Index::OrderedIndex)
   {

--- 1.20/storage/ndb/tools/delete_all.cpp	2006-10-20 14:18:33 +02:00
+++ 1.21/storage/ndb/tools/delete_all.cpp	2006-10-20 14:18:33 +02:00
@@ -29,6 +29,8 @@
 
 static const char* _dbname = "TEST_DB";
 static my_bool _transactional = false;
+static my_bool _tupscan = 0;
+static my_bool _diskscan = 0;
 static struct my_option my_long_options[] =
 {
   NDB_STD_OPTS("ndb_desc"),
@@ -38,6 +40,12 @@
   { "transactional", 't', "Single transaction (may run out of operations)",
     (gptr*) &_transactional, (gptr*) &_transactional, 0,
     GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
+  { "tupscan", 999, "Run tupscan",
+    (gptr*) &_tupscan, (gptr*) &_tupscan, 0,
+    GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
+  { "diskscan", 999, "Run diskcan",
+    (gptr*) &_diskscan, (gptr*) &_diskscan, 0,
+    GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
   { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
 };
 static void usage()
@@ -139,8 +147,11 @@
       goto failed;
     }
     
+    int flags = 0;
+    flags |= _tupscan ? NdbScanOperation::SF_TupScan : 0;
+    flags |= _diskscan ? NdbScanOperation::SF_DiskScan : 0;
     if( pOp->readTuples(NdbOperation::LM_Exclusive, 
-			NdbScanOperation::SF_TupScan, par) ) {
+			flags, par) ) {
       goto failed;
     }
     

--- 1.357/sql/ha_ndbcluster.cc	2006-10-20 14:18:33 +02:00
+++ 1.358/sql/ha_ndbcluster.cc	2006-10-20 14:18:33 +02:00
@@ -2393,6 +2393,30 @@
   DBUG_RETURN(next_result(buf));
 }
 
+static
+int
+guess_scan_flags(NdbOperation::LockMode lm, 
+		 const NDBTAB* tab, const MY_BITMAP* readset)
+{
+  int flags= 0;
+  flags|= (lm == NdbOperation::LM_Read) ? NdbScanOperation::SF_KeyInfo : 0;
+  if (tab->checkColumns(0, 0) & 2)
+  {
+    int ret = tab->checkColumns(readset->bitmap, no_bytes_in_map(readset));
+    
+    if (ret & 2)
+    { // If disk columns...use disk scan
+      flags |= NdbScanOperation::SF_DiskScan;
+    }
+    else if ((ret & 4) == 0 && (lm == NdbOperation::LM_Exclusive))
+    {
+      // If no mem column is set and exclusive...guess disk scan
+      flags |= NdbScanOperation::SF_DiskScan;
+    }
+  }
+  return flags;
+}
+
 /*
   Start full table scan in NDB
  */
@@ -2410,11 +2434,9 @@
 
   NdbOperation::LockMode lm=
     (NdbOperation::LockMode)get_ndb_lock_type(m_lock.type);
-  bool need_pk = (lm == NdbOperation::LM_Read);
+  int flags= guess_scan_flags(lm, m_table, table->read_set);
   if (!(op=trans->getNdbScanOperation(m_table)) ||
-      op->readTuples(lm, 
-		     (need_pk)?NdbScanOperation::SF_KeyInfo:0, 
-		     parallelism))
+      op->readTuples(lm, flags, parallelism))
     ERR_RETURN(trans->getNdbError());
   m_active_cursor= op;
 
Thread
bk commit into 5.1 tree (jonas:1.2302) BUG#17929jonas20 Oct