List:Commits« Previous MessageNext Message »
From:Pekka Nousiainen Date:January 20 2009 11:08am
Subject:bzr commit into mysql-5.1-bugteam branch (pekka:3222) Bug#41905
View as plain text  
#At file:///export/space/pekka/ndb/version/my51-bug41905/

 3222 Pekka Nousiainen	2009-01-20
      bug#41905 02.diff
      In alter table move invalidate old version to commit.
modified:
  storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp
  storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp

=== modified file 'storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp'
--- a/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp	2008-12-15 19:41:01 +0000
+++ b/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp	2009-01-20 11:08:14 +0000
@@ -2895,8 +2895,17 @@ int NdbDictionaryImpl::alterTableGlobal(
   DBUG_ENTER("NdbDictionaryImpl::alterTableGlobal");
   // Alter the table
   int ret = m_receiver.alterTable(m_ndb, old_impl, impl);
+#if ndb_bug41905
   old_impl.m_status = NdbDictionary::Object::Invalid;
+#endif
   if(ret == 0){
+    NdbDictInterface::Tx::Op op;
+    op.m_gsn = GSN_ALTER_TABLE_REQ;
+    op.m_impl = &old_impl;
+    if (m_tx.m_op.push_back(op) == -1) {
+      m_error.code = 4000;
+      DBUG_RETURN(-1);
+    }
     DBUG_RETURN(ret);
   }
   ERR_RETURN(getNdbError(), ret);
@@ -7469,6 +7478,7 @@ NdbDictionaryImpl::endSchemaTrans(Uint32
    */
   if (m_error.code == 787)
   {
+    m_tx.m_op.clear();
     if (flags & NdbDictionary::Dictionary::SchemaTransAbort)
     {
       m_error.code = 0;
@@ -7481,6 +7491,7 @@ NdbDictionaryImpl::endSchemaTrans(Uint32
   int ret = m_receiver.endSchemaTrans(flags);
   m_tx.m_transOn = false;
   if (ret == -1) {
+    m_tx.m_op.clear();
     if (m_error.code == 787)
     {
       if (flags & NdbDictionary::Dictionary::SchemaTransAbort)
@@ -7491,12 +7502,24 @@ NdbDictionaryImpl::endSchemaTrans(Uint32
     }
     DBUG_RETURN(-1);
   }
+
+  // invalidate old version of altered table
+  uint i;
+  for (i = 0; i < m_tx.m_op.size(); i++) {
+    NdbDictInterface::Tx::Op& op = m_tx.m_op[i];
+    if (op.m_gsn == GSN_ALTER_TABLE_REQ)
+    {
+      op.m_impl->m_status = NdbDictionary::Object::Invalid;
+    }
+  }
+  m_tx.m_op.clear();
   DBUG_RETURN(0);
 }
 
 int
 NdbDictInterface::beginSchemaTrans()
 {
+  assert(m_tx.m_op.size() == 0);
   NdbApiSignal tSignal(m_reference);
   SchemaTransBeginReq* req =
     CAST_PTR(SchemaTransBeginReq, tSignal.getDataPtrSend());
@@ -7632,3 +7655,5 @@ const NdbDictionary::Column * NdbDiction
 const NdbDictionary::Column * NdbDictionary::Column::ANY_VALUE = 0;
 const NdbDictionary::Column * NdbDictionary::Column::COPY_ROWID = 0;
 const NdbDictionary::Column * NdbDictionary::Column::OPTIMIZE = 0;
+
+template class Vector<NdbDictInterface::Tx::Op>;

=== modified file 'storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp'
--- a/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp	2008-12-12 14:30:54 +0000
+++ b/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp	2009-01-20 11:08:14 +0000
@@ -548,9 +548,15 @@ class NdbDictInterface {
 public:
   // one transaction per Dictionary instance is supported
   struct Tx {
+    // api-side schema op, currently only for alter table
+    struct Op {
+      Uint32 m_gsn;
+      NdbTableImpl* m_impl;
+    };
     bool m_transOn;
     Uint32 m_transId;   // API
     Uint32 m_transKey;  // DICT
+    Vector<Op> m_op;
     Tx() :
       m_transOn(false),
       m_transId(0),

Thread
bzr commit into mysql-5.1-bugteam branch (pekka:3222) Bug#41905Pekka Nousiainen20 Jan