List:Commits« Previous MessageNext Message »
From:Ole John Aske Date:June 30 2011 8:28am
Subject:bzr push into mysql-5.1-telco-7.0 branch (ole.john.aske:4487 to 4488)
View as plain text  
 4488 Ole John Aske	2011-06-30
      Extended SPJ api with NdbQueryDef::getQueryType() (Lookup, SingleScan, MultiScan).
      Also refactored internals of api to use this method where we had to 
      differentiate between single and multiscan query.

    modified:
      storage/ndb/src/ndbapi/NdbQueryBuilder.cpp
      storage/ndb/src/ndbapi/NdbQueryBuilder.hpp
      storage/ndb/src/ndbapi/NdbQueryBuilderImpl.hpp
      storage/ndb/src/ndbapi/NdbQueryOperation.cpp
 4487 Frazer Clement	2011-06-30
      WL5353 Primary Cluster Conflict Detection
        Implement Ndb_slave_max_replicated_epoch status variable
      
      New status variable, initialised on Slave start from ndb_apply_status
      table contents and maintained as 'reflected' ndb_apply_status WRITE_ROW 
      events are applied.  ndb_apply_status events logged by the Slave server,
      or any server in the IGNORE_SERVER_IDs list are used.
      
      The status variable is reset when RESET SLAVE is executed.
      
      Additionally :
       - Ndb handler code accessing the MasterInfo structure is factored out into
         new files (ndb_mi.h, ndb_mi.cc)
       - The master_epoch member of MasterInfo is no longer used/maintained.
      
      Two new testcases added to verify status variable initialisation and
      maintenance.
      
      This variable is used in a future patch series to detect distributed update 
      serialisation violations (conflicts).

    added:
      mysql-test/suite/ndb_rpl/r/ndb_rpl_circular_2ch_rep_status.result
      mysql-test/suite/ndb_rpl/r/ndb_rpl_init_rep_status.result
      mysql-test/suite/ndb_rpl/t/ndb_rpl_circular_2ch_rep_status.cnf
      mysql-test/suite/ndb_rpl/t/ndb_rpl_circular_2ch_rep_status.test
      mysql-test/suite/ndb_rpl/t/ndb_rpl_init_rep_status.test
      sql/ndb_mi.cc
      sql/ndb_mi.h
    modified:
      mysql-test/suite/ndb/r/ndb_basic.result
      sql/Makefile.am
      sql/ha_ndbcluster.cc
      sql/ha_ndbcluster.h
      sql/ha_ndbcluster_binlog.cc
      storage/ndb/CMakeLists.txt
=== modified file 'storage/ndb/src/ndbapi/NdbQueryBuilder.cpp'
--- a/storage/ndb/src/ndbapi/NdbQueryBuilder.cpp	2011-06-16 09:32:43 +0000
+++ b/storage/ndb/src/ndbapi/NdbQueryBuilder.cpp	2011-06-30 08:27:52 +0000
@@ -318,6 +318,11 @@ NdbQueryDef::isScanQuery() const
 { return m_impl.isScanQuery();
 }
 
+NdbQueryDef::QueryType
+NdbQueryDef::getQueryType() const
+{ return m_impl.getQueryType();
+}
+
 NdbQueryDefImpl& 
 NdbQueryDef::getImpl() const{
   return m_impl;
@@ -1095,24 +1100,10 @@ NdbQueryBuilderImpl::contains(const NdbQ
 const NdbQueryDefImpl*
 NdbQueryBuilderImpl::prepare()
 {
-  /* Check if query is sorted and has multiple scan operations. This 
-   * combination is not implemented.
-   */
-  if (m_operations.size() > 0 && 
-      m_operations[0]->isScanOperation() &&
-      m_operations[0]->getOrdering() 
-        != NdbQueryOptions::ScanOrdering_unordered &&
-      m_operations[0]->getOrdering() != NdbQueryOptions::ScanOrdering_void)
-  {
-    for (Uint32 i = 1; i<m_operations.size(); i++)
-    {
-      if (m_operations[i]->isScanOperation())
-      {
-        setErrorCode(QRY_MULTIPLE_SCAN_SORTED);
-        return NULL;
-      } 
-    }
-  }
+  const bool sorted =
+    m_operations.size() > 0 &&
+    m_operations[0]->getOrdering() != NdbQueryOptions::ScanOrdering_unordered &&
+    m_operations[0]->getOrdering() != NdbQueryOptions::ScanOrdering_void;
 
   int error;
   NdbQueryDefImpl* def = new NdbQueryDefImpl(m_operations, m_operands, error);
@@ -1127,6 +1118,16 @@ NdbQueryBuilderImpl::prepare()
     return NULL;
   }
 
+  /* Check if query is sorted and has multiple scan operations. This 
+   * combination is not implemented.
+   */
+  if (sorted && def->getQueryType() == NdbQueryDef::MultiScanQuery)
+  {
+    delete def;
+    setErrorCode(QRY_MULTIPLE_SCAN_SORTED);
+    return NULL;
+  }
+
   if (doPrintQueryTree)
   {
     ndbout << "Query tree:" << endl;
@@ -1256,6 +1257,20 @@ NdbQueryDefImpl::getQueryOperation(const
   return NULL;
 }
 
+NdbQueryDef::QueryType
+NdbQueryDefImpl::getQueryType() const
+{
+  if (!m_operations[0]->isScanOperation())
+    return NdbQueryDef::LookupQuery;
+
+  for (Uint32 i=1; i<m_operations.size(); ++i)
+  {
+    if (m_operations[i]->isScanOperation())
+      return NdbQueryDef::MultiScanQuery;
+  }
+  return NdbQueryDef::SingleScanQuery;
+}
+
 ////////////////////////////////////////////////////////////////
 // The (hidden) Impl of NdbQueryOperand (w/ various subclasses)
 ////////////////////////////////////////////////////////////////

=== modified file 'storage/ndb/src/ndbapi/NdbQueryBuilder.hpp'
--- a/storage/ndb/src/ndbapi/NdbQueryBuilder.hpp	2011-06-20 13:25:48 +0000
+++ b/storage/ndb/src/ndbapi/NdbQueryBuilder.hpp	2011-06-30 08:27:52 +0000
@@ -493,6 +493,15 @@ class NdbQueryDef
 
 public:
 
+  /**
+   * The different types of query types supported
+   */
+  enum QueryType {
+    LookupQuery,     ///< All operations are PrimaryKey- or UniqueIndexAccess
+    SingleScanQuery, ///< Root is Table- or OrderedIndexScan, childs are 'lookup'
+    MultiScanQuery   ///< Root, and some childs are scans
+  };
+
   Uint32 getNoOfOperations() const;
 
   // Get a specific NdbQueryOperationDef by ident specified
@@ -504,6 +513,9 @@ public:
   // the client has completed access to it.
   bool isScanQuery() const;
 
+  // Return the 'enum QueryType' as defined above.
+  QueryType getQueryType() const;
+
   // Remove this NdbQueryDef including operation and operands it contains
   void destroy() const;
 

=== modified file 'storage/ndb/src/ndbapi/NdbQueryBuilderImpl.hpp'
--- a/storage/ndb/src/ndbapi/NdbQueryBuilderImpl.hpp	2011-06-16 09:32:43 +0000
+++ b/storage/ndb/src/ndbapi/NdbQueryBuilderImpl.hpp	2011-06-30 08:27:52 +0000
@@ -595,6 +595,8 @@ public:
   bool isScanQuery() const
   { return m_operations[0]->isScanOperation(); }
 
+  NdbQueryDef::QueryType getQueryType() const;
+
   Uint32 getNoOfOperations() const
   { return m_operations.size(); }
 

=== modified file 'storage/ndb/src/ndbapi/NdbQueryOperation.cpp'
--- a/storage/ndb/src/ndbapi/NdbQueryOperation.cpp	2011-06-20 13:25:48 +0000
+++ b/storage/ndb/src/ndbapi/NdbQueryOperation.cpp	2011-06-30 08:27:52 +0000
@@ -4771,17 +4771,11 @@ NdbQueryOperationImpl::setOrdering(NdbQu
   /* Check if query is sorted and has multiple scan operations. This 
    * combination is not implemented.
    */
-  if (ordering != NdbQueryOptions::ScanOrdering_unordered)
+  if (ordering != NdbQueryOptions::ScanOrdering_unordered &&
+      getQueryDef().getQueryType() == NdbQueryDef::MultiScanQuery)
   {
-    for (Uint32 i = 1; i < getQuery().getNoOfOperations(); i++)
-    {
-      if (getQuery().getQueryOperation(i).getQueryOperationDef()
-          .isScanOperation())
-      {
-        getQuery().setErrorCode(QRY_MULTIPLE_SCAN_SORTED);
-        return -1;
-      }
-    }
+    getQuery().setErrorCode(QRY_MULTIPLE_SCAN_SORTED);
+    return -1;
   }
   
   m_ordering = ordering;

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-5.1-telco-7.0 branch (ole.john.aske:4487 to 4488) Ole John Aske4 Jul