List:Commits« Previous MessageNext Message »
From:Ole John Aske Date:June 16 2011 9:32am
Subject:bzr commit into mysql-5.1-telco-7.0 branch (ole.john.aske:4458)
View as plain text  
#At file:///net/fimafeng09/export/home/tmp/oleja/mysql/mysql-5.1-telco-7.0/ based on revid:jan.wedvik@stripped

 4458 Ole John Aske	2011-06-16
      SPJ API update:
      
      The ndbapi for SPJ was not completely in synch with the primary 
      SPJ source (mysql-5.1-telco-7.0-spj-scan-scan). Likely due to some
      late arriving patches when the SPJ api was merged into telco-7.0.
      
      This patch fix this unintentional diff between these branches.

    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
      storage/ndb/test/include/HugoQueryBuilder.hpp
      storage/ndb/test/src/HugoQueryBuilder.cpp
=== modified file 'storage/ndb/src/ndbapi/NdbQueryBuilder.cpp'
--- a/storage/ndb/src/ndbapi/NdbQueryBuilder.cpp	2011-05-17 12:47:21 +0000
+++ b/storage/ndb/src/ndbapi/NdbQueryBuilder.cpp	2011-06-16 09:32:43 +0000
@@ -23,7 +23,6 @@
 #include <Vector.hpp>
 #include "signaldata/QueryTree.hpp"
 
-#include <Ndb.hpp>
 #include "NdbDictionaryImpl.hpp"
 #include <NdbRecord.hpp>
 #include "AttributeHeader.hpp"
@@ -575,16 +574,15 @@ NdbQueryIndexScanOperationDef::~NdbQuery
 
 NdbQueryOperationDefImpl::~NdbQueryOperationDefImpl()
 {
+  // Unlink any parent and child refering this object
   if (m_parent != NULL)
   {
     m_parent->removeChild(this);
   }
-  // Delete children recursively also.
   for (Uint32 i = 0; i<m_children.size(); i++)
   {
     assert(m_children[i]->m_parent == this);
     m_children[i]->m_parent = NULL;
-    delete m_children[i];
   }
 }
 
@@ -686,9 +684,9 @@ NdbQueryOperationDef::getIndex() const
  * Implementation of NdbQueryBuilder factory
  ******************************************/
 // Static method.
-NdbQueryBuilder* NdbQueryBuilder::create(Ndb& ndb)
+NdbQueryBuilder* NdbQueryBuilder::create()
 {
-  NdbQueryBuilderImpl* const impl = new NdbQueryBuilderImpl(ndb);
+  NdbQueryBuilderImpl* const impl = new NdbQueryBuilderImpl();
   if (likely (impl != NULL))
   {
     if (likely(impl->getNdbError().code == 0))
@@ -1045,9 +1043,9 @@ NdbQueryBuilder::prepare()
 // The (hidden) Impl of NdbQueryBuilder
 ////////////////////////////////////////
 
-NdbQueryBuilderImpl::NdbQueryBuilderImpl(Ndb& ndb)
+NdbQueryBuilderImpl::NdbQueryBuilderImpl()
 : m_interface(*this),
-  m_ndb(ndb), m_error(),
+  m_error(),
   m_operations(),
   m_operands(),
   m_paramCnt(0),
@@ -1063,12 +1061,13 @@ NdbQueryBuilderImpl::NdbQueryBuilderImpl
 NdbQueryBuilderImpl::~NdbQueryBuilderImpl()
 {
   // Delete all operand and operator in Vector's
-  if (m_operations.size() > 0)
+  for (Uint32 i=0; i<m_operations.size(); ++i)
   {
-    delete m_operations[0];
+    delete m_operations[i];
   }
   for (Uint32 i=0; i<m_operands.size(); ++i)
-  { delete m_operands[i];
+  {
+    delete m_operands[i];
   }
 }
 
@@ -1231,12 +1230,13 @@ NdbQueryDefImpl(const Vector<NdbQueryOpe
 NdbQueryDefImpl::~NdbQueryDefImpl()
 {
   // Release all NdbQueryOperations
-  if (m_operations.size() > 0)
+  for (Uint32 i=0; i<m_operations.size(); ++i)
   {
-    delete m_operations[0];
+    delete m_operations[i];
   }
   for (Uint32 i=0; i<m_operands.size(); ++i)
-  { delete m_operands[i];
+  {
+    delete m_operands[i];
   }
 }
 
@@ -2799,15 +2799,14 @@ main(int argc, const char** argv)
   assert (sizeof(NdbParamOperand) == sizeof(NdbQueryOperandImpl*));
   assert (sizeof(NdbLinkedOperand) == sizeof(NdbQueryOperandImpl*));
 
-  Ndb *myNdb = 0;
-  NdbQueryBuilder myBuilder(*myNdb);
+  NdbQueryBuilder* const myBuilder= NdbQueryBuilder::create();
 
   const NdbDictionary::Table *manager = (NdbDictionary::Table*)0xDEADBEAF;
 //  const NdbDictionary::Index *ix = (NdbDictionary::Index*)0x11223344;
 
-  NdbQueryDef* q1 = 0;
+  const NdbQueryDef* q1 = 0;
   {
-    NdbQueryBuilder* qb = &myBuilder; //myDict->getQueryBuilder();
+    NdbQueryBuilder* qb = myBuilder;
 
     const NdbQueryOperand* managerKey[] =  // Manager is indexed om {"dept_no", "emp_no"}
     {  qb->constValue("d005"),             // dept_no = "d005"

=== modified file 'storage/ndb/src/ndbapi/NdbQueryBuilder.hpp'
--- a/storage/ndb/src/ndbapi/NdbQueryBuilder.hpp	2011-04-06 14:16:13 +0000
+++ b/storage/ndb/src/ndbapi/NdbQueryBuilder.hpp	2011-06-16 09:32:43 +0000
@@ -24,7 +24,6 @@
 // skip includes...and require them to be included first
 // BUH!
 
-class Ndb;
 class NdbQueryDef;
 class NdbQueryDefImpl;
 class NdbQueryBuilderImpl;
@@ -358,9 +357,8 @@ private:
  *   build phase.
  *
  * - The NdbQueryDef produced by the ::prepare() method has a lifetime 
- *   determined by the Ndb object, or until it is explicit released by
- *   NdbQueryDef::release()
- *  
+ *   until it is explicit released by NdbQueryDef::release()
+ *
  */
 class NdbQueryBuilder 
 {
@@ -380,7 +378,7 @@ public:
    * Allocate an instance.
    * @return New instance, or NULL if allocation failed.
    */
-  static NdbQueryBuilder* create(Ndb& ndb);
+  static NdbQueryBuilder* create();
 
   /**
    * Release this object and any resources held by it.
@@ -478,8 +476,7 @@ private:
  * NdbQueryDef represents a ::prepare()'d object from NdbQueryBuilder.
  *
  * The NdbQueryDef is reusable in the sense that it may be executed multiple
- * times. Its lifetime is defined by the Ndb object which it was created with,
- * or it may be explicitely released() when no longer required.
+ * times. It is valid until it is explicitely released().
  *
  * The NdbQueryDef *must* be keept alive until the last thread
  * which executing a query based on this NdbQueryDef has completed execution 

=== modified file 'storage/ndb/src/ndbapi/NdbQueryBuilderImpl.hpp'
--- a/storage/ndb/src/ndbapi/NdbQueryBuilderImpl.hpp	2011-05-05 11:06:08 +0000
+++ b/storage/ndb/src/ndbapi/NdbQueryBuilderImpl.hpp	2011-06-16 09:32:43 +0000
@@ -631,7 +631,7 @@ class NdbQueryBuilderImpl
 
 public:
   ~NdbQueryBuilderImpl();
-  explicit NdbQueryBuilderImpl(Ndb& ndb);
+  explicit NdbQueryBuilderImpl();
 
   const NdbQueryDefImpl* prepare();
 
@@ -665,7 +665,6 @@ private:
   bool contains(const NdbQueryOperationDefImpl*);
 
   NdbQueryBuilder m_interface;
-  Ndb& m_ndb;
   NdbError m_error;
 
   Vector<NdbQueryOperationDefImpl*> m_operations;

=== modified file 'storage/ndb/src/ndbapi/NdbQueryOperation.cpp'
--- a/storage/ndb/src/ndbapi/NdbQueryOperation.cpp	2011-05-26 14:44:59 +0000
+++ b/storage/ndb/src/ndbapi/NdbQueryOperation.cpp	2011-06-16 09:32:43 +0000
@@ -2895,7 +2895,6 @@ NdbQueryImpl::closeTcCursor(bool forceSe
   assert (m_queryDef.isScanQuery());
 
   NdbImpl* const ndb = m_transaction.getNdb()->theImpl;
-  NdbImpl* const impl = ndb;
   const Uint32 timeout  = ndb->get_waitfor_timeout();
   const Uint32 nodeId   = m_transaction.getConnectedNodeId();
   const Uint32 seq      = m_transaction.theNodeSequence;
@@ -2905,7 +2904,7 @@ NdbQueryImpl::closeTcCursor(bool forceSe
    */
   PollGuard poll_guard(*ndb);
 
-  if (unlikely(impl->getNodeSequence(nodeId) != seq))
+  if (unlikely(ndb->getNodeSequence(nodeId) != seq))
   {
     setErrorCode(Err_NodeFailCausedAbort);
     return -1;  // Transporter disconnected and reconnected, no need to close
@@ -2917,7 +2916,7 @@ NdbQueryImpl::closeTcCursor(bool forceSe
     const FetchResult result = static_cast<FetchResult>
         (poll_guard.wait_scan(3*timeout, nodeId, forceSend));
 
-    if (unlikely(impl->getNodeSequence(nodeId) != seq))
+    if (unlikely(ndb->getNodeSequence(nodeId) != seq))
       setFetchTerminated(Err_NodeFailCausedAbort,false);
     else if (unlikely(result != FetchResult_ok))
     {
@@ -2952,7 +2951,7 @@ NdbQueryImpl::closeTcCursor(bool forceSe
       const FetchResult result = static_cast<FetchResult>
           (poll_guard.wait_scan(3*timeout, nodeId, forceSend));
 
-      if (unlikely(impl->getNodeSequence(nodeId) != seq))
+      if (unlikely(ndb->getNodeSequence(nodeId) != seq))
         setFetchTerminated(Err_NodeFailCausedAbort,false);
       else if (unlikely(result != FetchResult_ok))
       {

=== modified file 'storage/ndb/test/include/HugoQueryBuilder.hpp'
--- a/storage/ndb/test/include/HugoQueryBuilder.hpp	2011-04-06 14:16:13 +0000
+++ b/storage/ndb/test/include/HugoQueryBuilder.hpp	2011-06-16 09:32:43 +0000
@@ -1,6 +1,5 @@
 /*
-   Copyright (C) 2003 MySQL AB
-    All rights reserved. Use is subject to license terms.
+   Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -105,7 +104,7 @@ public:
   OptionMask getOptionMask() const { return m_options;}
   void setOptionMask(OptionMask om) { m_options = om;}
 
-  const NdbQueryDef * createQuery(Ndb*, bool takeOwnership = false);
+  const NdbQueryDef * createQuery(bool takeOwnership = false);
 
 private:
   struct TableDef

=== modified file 'storage/ndb/test/src/HugoQueryBuilder.cpp'
--- a/storage/ndb/test/src/HugoQueryBuilder.cpp	2011-04-06 14:16:13 +0000
+++ b/storage/ndb/test/src/HugoQueryBuilder.cpp	2011-06-16 09:32:43 +0000
@@ -1,6 +1,5 @@
 /*
-   Copyright (C) 2003 MySQL AB
-    All rights reserved. Use is subject to license terms.
+   Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -563,9 +562,9 @@ loop:
 }
 
 const NdbQueryDef *
-HugoQueryBuilder::createQuery(Ndb* pNdb, bool takeOwnership)
+HugoQueryBuilder::createQuery(bool takeOwnership)
 {
-  NdbQueryBuilder* const builder = NdbQueryBuilder::create(*pNdb);
+  NdbQueryBuilder* const builder = NdbQueryBuilder::create();
   if (builder == NULL)
   {
     ndbout << "Failed to create NdbQueryBuilder." << endl;


Attachment: [text/bzr-bundle] bzr/ole.john.aske@oracle.com-20110616093243-djarhihcuygdjde1.bundle
Thread
bzr commit into mysql-5.1-telco-7.0 branch (ole.john.aske:4458) Ole John Aske16 Jun