List:Internals« Previous MessageNext Message »
From:jonas Date:August 18 2005 12:02pm
Subject:bk commit into 4.1 tree (jonas:1.2338) BUG#12118
View as plain text  
Below is the list of changes that have just been committed into a local
4.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
  1.2338 05/08/18 14:02:25 jonas@eel.(none) +31 -0
  bug#12118 - ndb alter table data loss 
    Split table version into 2 (major, minor)
    Impl. signaling to API when table has been altered
    Allow running transactions to use any minor number for transactions

  ndb/include/kernel/signaldata/ApiBroadcast.hpp
    1.1 05/08/18 14:02:20 jonas@eel.(none) +31 -0
    New BitKeeper file ``ndb/include/kernel/signaldata/ApiBroadcast.hpp''

  sql/ha_ndbcluster.cc
    1.164 05/08/18 14:02:20 jonas@eel.(none) +4 -1
    Allow running transactions to use tables in state ALTERED...but new transactions may not...

  ndb/src/ndbapi/TransporterFacade.cpp
    1.31 05/08/18 14:02:20 jonas@eel.(none) +12 -0
    Add support for ALTER_TABLE_REP

  ndb/src/ndbapi/NdbDictionaryImpl.cpp
    1.54 05/08/18 14:02:20 jonas@eel.(none) +9 -12
    Change alter table so that remove from global cache is used wo/ retreiving it from there first
      as ALTER_TABLE_REP might already have changed the table object...

  ndb/src/ndbapi/DictCache.hpp
    1.8 05/08/18 14:02:20 jonas@eel.(none) +3 -0
    Add support for alter_table_rep
      by setting status to Altered
    
    NOTE special handling of tables in state RETREIVING

  ndb/src/ndbapi/DictCache.cpp
    1.13 05/08/18 14:02:20 jonas@eel.(none) +68 -4
    Add support for alter_table_rep
      by setting status to Altered
    
    NOTE special handling of tables in state RETREIVING

  ndb/src/mgmsrv/MgmtSrvr.cpp
    1.60 05/08/18 14:02:20 jonas@eel.(none) +1 -38
    remove GREP

  ndb/src/kernel/blocks/suma/Suma.cpp
    1.15 05/08/18 14:02:20 jonas@eel.(none) +2 -18
    remove GREP

  ndb/src/kernel/blocks/qmgr/QmgrMain.cpp
    1.13 05/08/18 14:02:20 jonas@eel.(none) +28 -10
    Add support for sending REP to ALL api nodes

  ndb/src/kernel/blocks/qmgr/QmgrInit.cpp
    1.4 05/08/18 14:02:20 jonas@eel.(none) +2 -1
    Add support for sending REP to ALL api nodes

  ndb/src/kernel/blocks/qmgr/Qmgr.hpp
    1.3 05/08/18 14:02:20 jonas@eel.(none) +1 -0
    Add support for sending REP to ALL api nodes

  ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp
    1.12 05/08/18 14:02:20 jonas@eel.(none) +1 -6
    remove GREP

  ndb/src/kernel/blocks/dbtc/DbtcMain.cpp
    1.57 05/08/18 14:02:20 jonas@eel.(none) +2 -2
    1) Use table_ version_major when checking table version
    2) Dummy fix for BUG that tableSchemaVersion is only 16 bit in LQHKEYREQ

  ndb/src/kernel/blocks/dbtc/Dbtc.hpp
    1.21 05/08/18 14:02:20 jonas@eel.(none) +2 -1
    1) Use table_ version_major when checking table version
    2) Dummy fix for BUG that tableSchemaVersion is only 16 bit in LQHKEYREQ

  ndb/include/kernel/signaldata/ApiBroadcast.hpp
    1.0 05/08/18 14:02:20 jonas@eel.(none) +0 -0
    BitKeeper file /home/jonas/src/mysql-4.1/ndb/include/kernel/signaldata/ApiBroadcast.hpp

  ndb/src/kernel/blocks/dblqh/DblqhMain.cpp
    1.53 05/08/18 14:02:19 jonas@eel.(none) +4 -3
    1) Use table_ version_major when checking table version
    2) Dummy fix for BUG that tableSchemaVersion is only 16 bit in LQHKEYREQ

  ndb/src/kernel/blocks/dbdih/DbdihMain.cpp
    1.23 05/08/18 14:02:19 jonas@eel.(none) +0 -2
    remove grep

  ndb/src/kernel/blocks/dbdict/printSchemaFile.cpp
    1.7 05/08/18 14:02:19 jonas@eel.(none) +2 -1
    Update schema printer

  ndb/src/kernel/blocks/dbdict/Dbdict.hpp
    1.9 05/08/18 14:02:19 jonas@eel.(none) +1 -0
    Check for same ndb versions

  ndb/src/kernel/blocks/dbdict/Dbdict.cpp
    1.37 05/08/18 14:02:19 jonas@eel.(none) +81 -8
    Split tableSchemaVersion into 2 part
    24 bit real version
     8 bit for online alter table where old table definition is still usable

  ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp
    1.18 05/08/18 14:02:19 jonas@eel.(none) +0 -1
    remove GREP

  ndb/src/kernel/blocks/Makefile.am
    1.3 05/08/18 14:02:19 jonas@eel.(none) +0 -1
    remove GREP

  ndb/src/kernel/SimBlockList.cpp
    1.7 05/08/18 14:02:19 jonas@eel.(none) +3 -3
    remove GREP

  ndb/src/common/util/version.c
    1.18 05/08/18 14:02:19 jonas@eel.(none) +3 -1
    Fix upgrades

  ndb/src/common/debugger/BlockNames.cpp
    1.2 05/08/18 14:02:19 jonas@eel.(none) +0 -1
    remove GREP

  ndb/include/ndbapi/NdbDictionary.hpp
    1.22 05/08/18 14:02:19 jonas@eel.(none) +3 -2
    Add state on table object to represent an altered but still valid table object

  ndb/include/kernel/signaldata/AlterTable.hpp
    1.4 05/08/18 14:02:19 jonas@eel.(none) +24 -1
    New error code for alter table during rolling upgrade

  ndb/include/kernel/kernel_types.h
    1.2 05/08/18 14:02:19 jonas@eel.(none) +7 -0
    table_version_major

  ndb/include/kernel/GlobalSignalNumbers.h
    1.8 05/08/18 14:02:19 jonas@eel.(none) +2 -2
    Add ALTER_TABL_REP and API_BROADCAST_REP

  ndb/include/kernel/BlockNumbers.h
    1.4 05/08/18 14:02:19 jonas@eel.(none) +1 -3
    remove GREP

  mysql-test/t/ndb_alter_table.test
    1.20 05/08/18 14:02:19 jonas@eel.(none) +25 -1
    Allow running transactions to use old table definition when possible.

  mysql-test/r/ndb_alter_table.result
    1.21 05/08/18 14:02:19 jonas@eel.(none) +17 -1
    Allow running transactions to use old table definition when possible.

# 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:	eel.(none)
# Root:	/home/jonas/src/mysql-4.1
--- New file ---
+++ ndb/include/kernel/signaldata/ApiBroadcast.hpp	05/08/18 14:02:20
/* Copyright (C) 2003 MySQL AB

   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
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */

#ifndef API_BROADCAST_HPP
#define API_BROADCAST_HPP

#include "SignalData.hpp"

struct ApiBroadcastRep
{
  STATIC_CONST( SignalLength = 2 );
  
  Uint32 gsn;
  Uint32 minVersion;
  Uint32 theData[1];
};

#endif


--- 1.20/mysql-test/r/ndb_alter_table.result	2005-04-04 12:26:02 +02:00
+++ 1.21/mysql-test/r/ndb_alter_table.result	2005-08-18 14:02:19 +02:00
@@ -179,8 +179,24 @@
 2	two	two
 alter table t1 drop index c;
 select * from t1 where b = 'two';
-ERROR HY000: Table definition has changed, please retry transaction
+a	b	c
+2	two	two
 select * from t1 where b = 'two';
 a	b	c
 2	two	two
 drop table t1;
+create table t3 (a int primary key) engine=ndbcluster;
+begin;
+insert into t3 values (1);
+alter table t3 rename t4;
+delete from t3;
+insert into t3 values (1);
+commit;
+select * from t3;
+ERROR HY000: Can't lock file (errno: 155)
+select * from t4;
+a
+1
+drop table t4;
+show tables;
+Tables_in_test

--- 1.19/mysql-test/t/ndb_alter_table.test	2005-04-19 17:23:00 +02:00
+++ 1.20/mysql-test/t/ndb_alter_table.test	2005-08-18 14:02:19 +02:00
@@ -144,7 +144,6 @@
 connection server1;
 alter table t1 drop index c;
 connection server2;
---error 1105
 select * from t1 where b = 'two';
 select * from t1 where b = 'two';
 connection server1;
@@ -172,3 +171,28 @@
 #truncate table t2;
 #select count(*) from t2;
 #drop table t2;
+
+connection server1;
+create table t3 (a int primary key) engine=ndbcluster;
+
+connection server2;
+begin;
+insert into t3 values (1);
+
+connection server1;
+alter table t3 rename t4;
+
+connection server2;
+# This should work as transaction is ongoing...
+delete from t3;
+insert into t3 values (1);
+commit; 
+
+# This should fail as its a new transaction
+--error 1015
+select * from t3;
+select * from t4;
+drop table t4;
+show tables;
+connection server1;
+

--- 1.3/ndb/include/kernel/BlockNumbers.h	2004-10-22 13:59:53 +02:00
+++ 1.4/ndb/include/kernel/BlockNumbers.h	2005-08-18 14:02:19 +02:00
@@ -44,8 +44,7 @@
 #define TRIX        0xFF
 #define DBUTIL     0x100
 #define SUMA       0x101
-#define GREP       0x102
-#define DBTUX      0x103
+#define DBTUX      0x102
 
 const BlockReference BACKUP_REF  = numberToRef(BACKUP, 0);
 const BlockReference DBTC_REF    = numberToRef(DBTC, 0);
@@ -61,7 +60,6 @@
 const BlockReference TRIX_REF    = numberToRef(TRIX, 0);
 const BlockReference DBUTIL_REF  = numberToRef(DBUTIL, 0);
 const BlockReference SUMA_REF    = numberToRef(SUMA, 0);
-const BlockReference GREP_REF    = numberToRef(GREP, 0);
 const BlockReference DBTUX_REF   = numberToRef(DBTUX, 0);
 
 const BlockNumber MIN_BLOCK_NO = BACKUP;

--- 1.7/ndb/include/kernel/GlobalSignalNumbers.h	2004-10-22 13:59:53 +02:00
+++ 1.8/ndb/include/kernel/GlobalSignalNumbers.h	2005-08-18 14:02:19 +02:00
@@ -777,8 +777,8 @@
 /**
  * Grep signals
  */
-#define GSN_GREP_SUB_CREATE_REQ         606
-#define GSN_GREP_SUB_CREATE_REF         607
+#define GSN_ALTER_TABLE_REP             606
+#define GSN_API_BROADCAST_REP           607
 #define GSN_GREP_SUB_CREATE_CONF        608
 #define GSN_GREP_CREATE_REQ             609
 #define GSN_GREP_CREATE_REF             610

--- 1.1/ndb/include/kernel/kernel_types.h	2004-04-14 10:23:52 +02:00
+++ 1.2/ndb/include/kernel/kernel_types.h	2005-08-18 14:02:19 +02:00
@@ -36,6 +36,13 @@
 #endif
 };
 
+inline
+Uint32 
+table_version_major(Uint32 ver)
+{
+  return ver & 0x00FFFFFF;
+}
+
 #endif
 
 

--- 1.3/ndb/include/kernel/signaldata/AlterTable.hpp	2005-07-20 13:21:46 +02:00
+++ 1.4/ndb/include/kernel/signaldata/AlterTable.hpp	2005-08-18 14:02:19 +02:00
@@ -129,7 +129,8 @@
     InvalidPrimaryKeySize  = 739,
     NullablePrimaryKey = 740,
     UnsupportedChange = 741,
-    BackupInProgress = 762
+    BackupInProgress = 762,
+    IncompatibleVersions = 763
   };
 
 private:
@@ -175,6 +176,28 @@
   Uint32 senderRef;
   Uint32 tableId;
   Uint32 tableVersion;
+};
+
+/**
+ * Inform API about change of table definition
+ */
+struct AlterTableRep 
+{
+  friend bool printALTER_TABLE_REP(FILE*, const Uint32*, Uint32, Uint16);
+  
+  STATIC_CONST( SignalLength = 3 );
+  
+  enum Change_type 
+  {
+    CT_ALTERED = 0x1,
+    CT_DROPPED = 0x2
+  };
+  
+  Uint32 tableId;
+  Uint32 tableVersion;
+  Uint32 changeType;
+  
+  SECTION( TABLE_NAME = 0 );
 };
 
 #endif

--- 1.21/ndb/include/ndbapi/NdbDictionary.hpp	2005-07-20 11:48:45 +02:00
+++ 1.22/ndb/include/ndbapi/NdbDictionary.hpp	2005-08-18 14:02:19 +02:00
@@ -77,9 +77,10 @@
                               ///< changes to take effect
       Retrieved,              ///< The object exist and has been read 
                               ///< into main memory from NDB Kernel
-      Invalid                 ///< The object has been invalidated
+      Invalid,                ///< The object has been invalidated
                               ///< and should not be used
-      
+      Altered                 ///< Table has been altered in NDB kernel
+                              ///< but is still valid for usage
     };
 
     /**

--- 1.1/ndb/src/common/debugger/BlockNames.cpp	2004-04-14 10:24:07 +02:00
+++ 1.2/ndb/src/common/debugger/BlockNames.cpp	2005-08-18 14:02:19 +02:00
@@ -32,7 +32,6 @@
   { "BACKUP", BACKUP },
   { "DBUTIL", DBUTIL },
   { "SUMA", SUMA },
-  { "GREP", GREP },
   { "DBTUX", DBTUX }
 };
                                                                        

--- 1.17/ndb/src/common/util/version.c	2005-06-22 11:18:00 +02:00
+++ 1.18/ndb/src/common/util/version.c	2005-08-18 14:02:19 +02:00
@@ -90,7 +90,8 @@
 
 #ifndef TEST_VERSION
 struct NdbUpGradeCompatible ndbCompatibleTable_full[] = {
-  { MAKE_VERSION(4,1,NDB_VERSION_BUILD), MAKE_VERSION(4,1,10), UG_Range },
+  { MAKE_VERSION(4,1,NDB_VERSION_BUILD), MAKE_VERSION(4,1,15), UG_Range },
+  { MAKE_VERSION(4,1,14), MAKE_VERSION(4,1,10), UG_Range },
   { MAKE_VERSION(4,1,10), MAKE_VERSION(4,1,9), UG_Exact },
   { MAKE_VERSION(4,1,9), MAKE_VERSION(4,1,8), UG_Exact },
   { MAKE_VERSION(3,5,2), MAKE_VERSION(3,5,1), UG_Exact },
@@ -98,6 +99,7 @@
 };
 
 struct NdbUpGradeCompatible ndbCompatibleTable_upgrade[] = {
+  { MAKE_VERSION(4,1,15), MAKE_VERSION(4,1,14), UG_Exact },
   { MAKE_VERSION(3,5,4), MAKE_VERSION(3,5,3), UG_Exact },
   { 0, 0, UG_Null }
 };

--- 1.17/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp	2005-04-22 09:07:22 +02:00
+++ 1.18/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp	2005-08-18 14:02:19 +02:00
@@ -987,7 +987,6 @@
   sendSignal(BACKUP_REF, GSN_DUMP_STATE_ORD,  signal, signal->length(), JBB);
   sendSignal(DBUTIL_REF, GSN_DUMP_STATE_ORD,  signal, signal->length(), JBB);
   sendSignal(SUMA_REF, GSN_DUMP_STATE_ORD,    signal, signal->length(), JBB);
-  sendSignal(GREP_REF, GSN_DUMP_STATE_ORD,    signal, signal->length(), JBB);
   sendSignal(TRIX_REF, GSN_DUMP_STATE_ORD,    signal, signal->length(), JBB);
   sendSignal(DBTUX_REF, GSN_DUMP_STATE_ORD,   signal, signal->length(), JBB);
   

--- 1.36/ndb/src/kernel/blocks/dbdict/Dbdict.cpp	2005-07-21 11:13:04 +02:00
+++ 1.37/ndb/src/kernel/blocks/dbdict/Dbdict.cpp	2005-08-18 14:02:19 +02:00
@@ -77,6 +77,7 @@
 #include <signaldata/CreateFragmentation.hpp>
 #include <signaldata/CreateTab.hpp>
 #include <NdbSleep.h>
+#include <signaldata/ApiBroadcast.hpp>
 
 #define ZNOT_FOUND 626
 #define ZALREADYEXIST 630
@@ -91,6 +92,27 @@
 #define DIV(x,y) (((x)+(y)-1)/(y))
 #include <ndb_version.h>
 
+static
+Uint32
+alter_table_inc_schema_version(Uint32 old)
+{
+   return (old & 0x00FFFFFF) + ((old + 0x1000000) & 0xFF000000);
+}
+
+static
+Uint32
+alter_table_dec_schema_version(Uint32 old)
+{
+  return (old & 0x00FFFFFF) + ((old - 0x1000000) & 0xFF000000);
+}
+
+static
+Uint32
+create_table_inc_schema_version(Uint32 old)
+{
+  return (old + 0x00000001) & 0x00FFFFFF;
+}
+
 /* **************************************************************** */
 /* ---------------------------------------------------------------- */
 /* MODULE:          GENERAL MODULE -------------------------------- */
@@ -584,7 +606,7 @@
     jam();
     fsOpenReq->fileFlags = FsOpenReq::OM_READONLY;
   }//if
-  ndbrequire(tablePtr.p->tableVersion < ZNIL);
+
   fsOpenReq->fileNumber[3] = 0; // Initialise before byte changes
   FsOpenReq::setVersion(fsOpenReq->fileNumber, 1);
   FsOpenReq::setSuffix(fsOpenReq->fileNumber, FsOpenReq::S_TABLELIST);
@@ -776,7 +798,7 @@
   case SchemaFile::ADD_STARTED:
     jam();
     ok = true;
-    ndbrequire((oldVersion + 1) == newVersion);
+    ndbrequire(create_table_inc_schema_version(oldVersion) == newVersion);
     ndbrequire(oldState == SchemaFile::INIT ||
 	       oldState == SchemaFile::DROP_TABLE_COMMITTED);
     break;
@@ -789,7 +811,7 @@
   case SchemaFile::ALTER_TABLE_COMMITTED:
     jam();
     ok = true;
-    ndbrequire((oldVersion + 1) == newVersion);
+    ndbrequire(alter_table_inc_schema_version(oldVersion) == newVersion);
     ndbrequire(oldState == SchemaFile::TABLE_ADD_COMMITTED ||
 	       oldState == SchemaFile::ALTER_TABLE_COMMITTED);
     break;
@@ -2806,6 +2828,21 @@
   }
 }
 
+bool
+Dbdict::check_ndb_versions() const
+{
+  Uint32 node = 0;
+  Uint32 version = getNodeInfo(getOwnNodeId()).m_version;
+  while((node = c_aliveNodes.find(node + 1)) != BitmaskImpl::NotFound)
+  {
+    if(getNodeInfo(node).m_version != version)
+    {
+      return false;
+    }
+  }
+  return true;
+}
+
 void
 Dbdict::execALTER_TABLE_REQ(Signal* signal)
 {
@@ -2842,6 +2879,13 @@
     alterTableRef(signal, req, AlterTableRef::Busy);
     return;
   }
+
+  if (!check_ndb_versions())
+  {
+    jam();
+    alterTableRef(signal, req, AlterTableRef::IncompatibleVersions);
+    return;
+  }
   
   const TableRecord::TabState tabState = tablePtr.p->tabState;
   bool ok = false;
@@ -2992,7 +3036,7 @@
   lreq->clientData = alterTabPtr.p->m_senderData;
   lreq->changeMask = alterTabPtr.p->m_changeMask;
   lreq->tableId = tablePtr.p->tableId;
-  lreq->tableVersion = tablePtr.p->tableVersion + 1;
+  lreq->tableVersion = alter_table_inc_schema_version(tablePtr.p->tableVersion);
   lreq->gci = tablePtr.p->gciTableCreated;
   lreq->requestType = AlterTabReq::AlterTablePrepare;
   
@@ -3072,6 +3116,14 @@
     alterTabRef(signal, req, AlterTableRef::Busy);
     return;
   }
+
+  if (!check_ndb_versions())
+  {
+    jam();
+    alterTabRef(signal, req, AlterTableRef::IncompatibleVersions);
+    return;
+  }
+
   alterTabPtr.p->m_alterTableId = tableId;
   alterTabPtr.p->m_coordinatorRef = senderRef;
   
@@ -3114,7 +3166,7 @@
     }
     ndbrequire(ok);
 
-    if(tablePtr.p->tableVersion + 1 != tableVersion){
+    if(alter_table_inc_schema_version(tablePtr.p->tableVersion) != tableVersion){
       jam();
       alterTabRef(signal, req, AlterTableRef::InvalidTableVersion);
       return;
@@ -3599,7 +3651,7 @@
     // Restore name
     strcpy(tablePtr.p->tableName, alterTabPtrP->previousTableName);
     // Revert schema version
-    tablePtr.p->tableVersion = tablePtr.p->tableVersion - 1;
+    tablePtr.p->tableVersion = alter_table_dec_schema_version(tablePtr.p->tableVersion);
     // Put it back
 #ifdef VM_TRACE
     ndbrequire(!c_tableRecordHash.find(tmp, * tablePtr.p));
@@ -3659,6 +3711,27 @@
   conf->requestType = AlterTabReq::AlterTableCommit;
   sendSignal(coordinatorRef, GSN_ALTER_TAB_CONF, signal, 
 	       AlterTabConf::SignalLength, JBB);
+
+
+  {
+    ApiBroadcastRep* api= (ApiBroadcastRep*)signal->getDataPtrSend();
+    api->gsn = GSN_ALTER_TABLE_REP;
+    api->minVersion = MAKE_VERSION(4,1,15);
+
+    AlterTableRep* rep = (AlterTableRep*)api->theData;
+    rep->tableId = tabPtr.p->tableId;
+    rep->tableVersion = alter_table_dec_schema_version(tabPtr.p->tableVersion);
+    rep->changeType = AlterTableRep::CT_ALTERED;
+    
+    LinearSectionPtr ptr[3];
+    ptr[0].p = (Uint32*)alterTabPtr.p->previousTableName;
+    ptr[0].sz = (sizeof(alterTabPtr.p->previousTableName) + 3) >> 2;
+    
+    sendSignal(QMGR_REF, GSN_API_BROADCAST_REP, signal, 
+	       ApiBroadcastRep::SignalLength + AlterTableRep::SignalLength,
+	       JBB, ptr,1);
+  }
+
   if(coordinatorRef != reference()) {
     jam();
     // Release resources
@@ -3711,7 +3784,7 @@
   c_pageRecordArray.getPtr(pagePtr, c_schemaRecord.schemaPage);
   SchemaFile::TableEntry * tabEntry = getTableEntry(pagePtr.p, tabPtr.i);
 
-  tabPtr.p->tableVersion = tabEntry->m_tableVersion + 1;
+  tabPtr.p->tableVersion = create_table_inc_schema_version(tabEntry->m_tableVersion);
 
   /**
    * Pack
@@ -3740,7 +3813,7 @@
 
   req->gci = 0;
   req->tableId = tabPtr.i;
-  req->tableVersion = tabEntry->m_tableVersion + 1;
+  req->tableVersion = create_table_inc_schema_version(tabEntry->m_tableVersion);
   
   sendFragmentedSignal(rg, GSN_CREATE_TAB_REQ, signal, 
 		       CreateTabReq::SignalLength, JBB);

--- 1.8/ndb/src/kernel/blocks/dbdict/Dbdict.hpp	2005-07-20 11:48:45 +02:00
+++ 1.9/ndb/src/kernel/blocks/dbdict/Dbdict.hpp	2005-08-18 14:02:19 +02:00
@@ -578,6 +578,7 @@
   void execALTER_TAB_REQ(Signal* signal);
   void execALTER_TAB_REF(Signal* signal);
   void execALTER_TAB_CONF(Signal* signal);
+  bool check_ndb_versions() const;
 
   /*
    *  2.4 COMMON STORED VARIABLES

--- 1.6/ndb/src/kernel/blocks/dbdict/printSchemaFile.cpp	2005-03-28 11:48:35 +02:00
+++ 1.7/ndb/src/kernel/blocks/dbdict/printSchemaFile.cpp	2005-08-18 14:02:19 +02:00
@@ -58,7 +58,8 @@
     SchemaFile::TableEntry te = file->TableEntries[i];
     if(te.m_tableState != SchemaFile::INIT){
       ndbout << "Table " << i << ": State = " << te.m_tableState 
-	     << " version = " << te.m_tableVersion
+	     << " version = " << table_version_major(te.m_tableVersion) <<
+	     << "(" << table_version_minor(te.m_tableVersion) << ")"
              << " type = " << te.m_tableType
 	     << " noOfPages = " << te.m_noOfPages
 	     << " gcp: " << te.m_gcp << endl;

--- 1.22/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp	2005-05-30 14:17:55 +02:00
+++ 1.23/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp	2005-08-18 14:02:19 +02:00
@@ -1886,8 +1886,6 @@
     
     // Suma will not send response to this for now, later...
     sendSignal(SUMA_REF, GSN_INCL_NODEREQ, signal, 2, JBB);
-   // Grep will not send response to this for now, later...
-    sendSignal(GREP_REF, GSN_INCL_NODEREQ, signal, 2, JBB);
     return;
   }//if
   if (TstartNode_or_blockref == numberToRef(BACKUP, getOwnNodeId())){

--- 1.52/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp	2005-06-07 15:10:54 +02:00
+++ 1.53/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp	2005-08-18 14:02:19 +02:00
@@ -3512,7 +3512,8 @@
     LQHKEY_abort(signal, 4);
     return;
   }
-  if(tabptr.p->schemaVersion != schemaVersion){
+  if(table_version_major(tabptr.p->schemaVersion) != 
+     table_version_major(schemaVersion)){
     LQHKEY_abort(signal, 5);
     return;
   }
@@ -4451,7 +4452,7 @@
   lqhKeyReq->requestInfo = Treqinfo;
   lqhKeyReq->tcBlockref = sig4;
 
-  sig0 = regTcPtr->tableref + (regTcPtr->schemaVersion << 16);
+  sig0 = regTcPtr->tableref + ((regTcPtr->schemaVersion << 16) & 0xFFFF0000);
   sig1 = regTcPtr->fragmentid + (regTcPtr->nodeAfterNext[0] << 16);
   sig2 = regTcPtr->transid[0];
   sig3 = regTcPtr->transid[1];
@@ -15840,7 +15841,7 @@
   tabptr.i = tcConnectptr.p->tableref;
   ptrCheckGuard(tabptr, ctabrecFileSize, tablerec);
   if (getFragmentrec(signal, tcConnectptr.p->fragmentid) &&
-      (tabptr.p->schemaVersion == tcConnectptr.p->schemaVersion)) {
+      (table_version_major(tabptr.p->schemaVersion) == table_version_major(tcConnectptr.p->schemaVersion))) {
     if (fragptr.p->execSrStatus != Fragrecord::IDLE) {
       if (fragptr.p->execSrNoReplicas > logPartPtr.p->execSrExecuteIndex) {
         ndbrequire((fragptr.p->execSrNoReplicas - 1) < 4);

--- 1.20/ndb/src/kernel/blocks/dbtc/Dbtc.hpp	2005-05-03 12:16:28 +02:00
+++ 1.21/ndb/src/kernel/blocks/dbtc/Dbtc.hpp	2005-08-18 14:02:20 +02:00
@@ -958,7 +958,8 @@
     Uint8 storedTable;
     
     bool checkTable(Uint32 schemaVersion) const {
-      return enabled && !dropping && (schemaVersion == currentSchemaVersion);
+      return enabled && !dropping && 
+	(table_version_major(schemaVersion) == table_version_major(currentSchemaVersion));
     }
     
     Uint32 getErrorCode(Uint32 schemaVersion) const;

--- 1.56/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp	2005-06-13 19:44:15 +02:00
+++ 1.57/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp	2005-08-18 14:02:20 +02:00
@@ -3196,7 +3196,7 @@
   lqhKeyReq->tcBlockref = sig4;
   lqhKeyReq->savePointId = sig5;
 
-  sig0 = regCachePtr->tableref + (regCachePtr->schemaVersion << 16);
+  sig0 = regCachePtr->tableref + ((regCachePtr->schemaVersion << 16) & 0xFFFF0000);
   sig1 = regCachePtr->fragmentid + (regTcPtr->tcNodedata[1] << 16);
   sig2 = regApiPtr->transid[0];
   sig3 = regApiPtr->transid[1];
@@ -12877,7 +12877,7 @@
     return ZNO_SUCH_TABLE;
   if(dropping)
     return ZDROP_TABLE_IN_PROGRESS;
-  if(schemaVersion != currentSchemaVersion)
+  if(table_version_major(schemaVersion) != table_version_major(currentSchemaVersion))
     return ZWRONG_SCHEMA_VERSION_ERROR;
   ErrorReporter::handleAssert("Dbtc::TableRecord::getErrorCode",
 			      __FILE__, __LINE__);

--- 1.11/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp	2005-03-08 10:25:19 +01:00
+++ 1.12/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp	2005-08-18 14:02:20 +02:00
@@ -76,7 +76,6 @@
   { BACKUP_REF,  1 , 10000, 10999 },
   { DBUTIL_REF,  1 , 11000, 11999 },
   { SUMA_REF,    1 , 13000, 13999 },
-  { GREP_REF,    1 ,     0,     0 },
   { DBTUX_REF,   1 , 12000, 12999 }
 };
 
@@ -1453,9 +1452,6 @@
   sendSignal(SUMA_REF, GSN_NODE_FAILREP, signal,
 	     NodeFailRep::SignalLength, JBB);
 
-  sendSignal(GREP_REF, GSN_NODE_FAILREP, signal,
-	     NodeFailRep::SignalLength, JBB);
-
   Uint32 nodeId = 0;
   while(!allFailed.isclear()){
     nodeId = allFailed.find(nodeId + 1);
@@ -2381,7 +2377,6 @@
 
 void Ndbcntr::execSTART_ORD(Signal* signal){
   jamEntry();
-  ndbrequire(NO_OF_BLOCKS == ALL_BLOCKS_SZ);
   c_missra.execSTART_ORD(signal);
 }
 
@@ -2456,7 +2451,7 @@
    * Finished...
    */
   currentStartPhase = 0;
-  for(Uint32 i = 0; i<NO_OF_BLOCKS; i++){
+  for(Uint32 i = 0; i<ALL_BLOCKS_SZ; i++){
     if(ALL_BLOCKS[i].NextSP < currentStartPhase)
       currentStartPhase = ALL_BLOCKS[i].NextSP;
   }

--- 1.2/ndb/src/kernel/blocks/qmgr/Qmgr.hpp	2004-05-26 10:55:43 +02:00
+++ 1.3/ndb/src/kernel/blocks/qmgr/Qmgr.hpp	2005-08-18 14:02:20 +02:00
@@ -220,6 +220,7 @@
 
 
   void execAPI_VERSION_REQ(Signal* signal);
+  void execAPI_BROADCAST_REP(Signal* signal);
 
   // Arbitration signals
   void execARBIT_CFG(Signal* signal);

--- 1.3/ndb/src/kernel/blocks/qmgr/QmgrInit.cpp	2004-12-16 14:16:24 +01:00
+++ 1.4/ndb/src/kernel/blocks/qmgr/QmgrInit.cpp	2005-08-18 14:02:20 +02:00
@@ -80,7 +80,8 @@
   addRecSignal(GSN_API_FAILCONF, &Qmgr::execAPI_FAILCONF);
   addRecSignal(GSN_READ_NODESREQ, &Qmgr::execREAD_NODESREQ);
   addRecSignal(GSN_SET_VAR_REQ,  &Qmgr::execSET_VAR_REQ);
-
+  addRecSignal(GSN_API_BROADCAST_REP,  &Qmgr::execAPI_BROADCAST_REP);
+  
   // Arbitration signals
   addRecSignal(GSN_ARBIT_PREPREQ, &Qmgr::execARBIT_PREPREQ);
   addRecSignal(GSN_ARBIT_PREPCONF, &Qmgr::execARBIT_PREPCONF);

--- 1.12/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp	2004-11-18 16:47:23 +01:00
+++ 1.13/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp	2005-08-18 14:02:20 +02:00
@@ -34,6 +34,7 @@
 #include <signaldata/BlockCommitOrd.hpp>
 #include <signaldata/FailRep.hpp>
 #include <signaldata/DisconnectRep.hpp>
+#include <signaldata/ApiBroadcast.hpp>
 
 #include <ndb_version.h>
 
@@ -1702,16 +1703,6 @@
   sendSignal(DBDICT_REF, GSN_API_FAILREQ, signal, 2, JBA);
   sendSignal(SUMA_REF, GSN_API_FAILREQ, signal, 2, JBA);
 
-  /**
-   * GREP also need the information that an API node 
-   * (actually a REP node) has failed.
-   *
-   * GREP does however NOT send a CONF on this signal, i.e.
-   * the API_FAILREQ signal to GREP is like a REP signal 
-   * (i.e. without any confirmation).
-   */
-  sendSignal(GREP_REF, GSN_API_FAILREQ, signal, 2, JBA);
-  
   /**-------------------------------------------------------------------------
    * THE OTHER NODE WAS AN API NODE. THE COMMUNICATION LINK IS ALREADY 
    * BROKEN AND THUS NO ACTION IS NEEDED TO BREAK THE CONNECTION. 
@@ -3926,3 +3917,30 @@
   }// switch
 #endif
 }//execSET_VAR_REQ()
+
+void
+Qmgr::execAPI_BROADCAST_REP(Signal* signal)
+{
+  jamEntry();
+  ApiBroadcastRep api= *(const ApiBroadcastRep*)signal->getDataPtr();
+
+  Uint32 len = signal->getLength() - ApiBroadcastRep::SignalLength;
+  memmove(signal->theData, signal->theData+ApiBroadcastRep::SignalLength, 
+	  4*len);
+  
+  NodeBitmask mask;
+  NodeRecPtr nodePtr;
+  for (nodePtr.i = 1; nodePtr.i < MAX_NODES; nodePtr.i++) 
+  {
+    jam();
+    ptrAss(nodePtr, nodeRec);
+    if (nodePtr.p->phase == ZAPI_ACTIVE && 
+	getNodeInfo(nodePtr.i).m_version >= api.minVersion)
+    {
+      mask.set(nodePtr.i);
+    }
+  }
+  
+  NodeReceiverGroup rg(API_CLUSTERMGR, mask);
+  sendSignal(rg, api.gsn, signal, len, JBB); // forward sections
+}

--- 1.14/ndb/src/kernel/blocks/suma/Suma.cpp	2005-01-11 14:54:12 +01:00
+++ 1.15/ndb/src/kernel/blocks/suma/Suma.cpp	2005-08-18 14:02:20 +02:00
@@ -2143,7 +2143,8 @@
   case SubCreateReq::DatabaseSnapshot:
   case SubCreateReq::SelectiveTableSnapshot:
     jam();
-    subbPtr.p->m_subscriberRef = GREP_REF;
+    ndbrequire(false);
+    //subbPtr.p->m_subscriberRef = GREP_REF;
     subbPtr.p->m_subscriberData = subPtr.p->m_subscriberData;
     break;
   case SubCreateReq::SingleTableScan:
@@ -2972,16 +2973,6 @@
   c_lastCompleteGCI = gci;
 
   /**
-   * always send SUB_GCP_COMPLETE_REP to Grep (so 
-   * Lars can do funky stuff calculating intervals,
-   * even before the subscription is started
-   */
-  rep->senderRef  = reference();
-  rep->senderData = 0; //ignored in grep
-  EXECUTE_DIRECT(refToBlock(GREP_REF), GSN_SUB_GCP_COMPLETE_REP, signal,
-		 SubGcpCompleteRep::SignalLength);  
-
-  /**
    * Signal to subscriber(s)
    */
 
@@ -3005,13 +2996,6 @@
     ndbout_c("GSN_SUB_GCP_COMPLETE_REP to %s:",
 	     getBlockName(refToBlock(ref)));
 #else
-    /**
-     * Ignore sending to GREP (since we sent earlier)
-     */
-    if (ref == GREP_REF) {
-      jam();
-      continue;
-    }
 
     CRASH_INSERTION(13018);
 

--- 1.6/ndb/src/kernel/SimBlockList.cpp	2005-06-20 07:18:47 +02:00
+++ 1.7/ndb/src/kernel/SimBlockList.cpp	2005-08-18 14:02:19 +02:00
@@ -30,7 +30,6 @@
 #include <Backup.hpp>
 #include <DbUtil.hpp>
 #include <Suma.hpp>
-#include <Grep.hpp>
 #include <Dbtux.hpp>
 #include <NdbEnv.h>
 
@@ -97,13 +96,14 @@
   theList[11] = NEW_BLOCK(Backup)(conf);
   theList[12] = NEW_BLOCK(DbUtil)(conf);
   theList[13] = NEW_BLOCK(Suma)(conf);
-  theList[14] = NEW_BLOCK(Grep)(conf);
+  theList[14] = 0; //NEW_BLOCK(Grep)(conf);
   theList[15] = NEW_BLOCK(Dbtux)(conf);
 
   // Metadata common part shared by block instances
   ptrMetaDataCommon = new MetaData::Common(*dbdict, *dbdih);
   for (int i = 0; i < noOfBlocks; i++)
-    theList[i]->setMetaDataCommon(ptrMetaDataCommon);
+    if(theList[i])
+      theList[i]->setMetaDataCommon(ptrMetaDataCommon);
 }
 
 void

--- 1.59/ndb/src/mgmsrv/MgmtSrvr.cpp	2005-04-22 09:07:22 +02:00
+++ 1.60/ndb/src/mgmsrv/MgmtSrvr.cpp	2005-08-18 14:02:20 +02:00
@@ -2541,44 +2541,7 @@
 int
 MgmtSrvr::repCommand(Uint32* repReqId, Uint32 request, bool waitCompleted)
 {
-  bool    next;
-  NodeId  nodeId = 0;
-  
-  while((next = getNextNodeId(&nodeId, NDB_MGM_NODE_TYPE_NDB)) == true &&
-	theFacade->get_node_alive(nodeId) == false);
-  
-  if(!next){
-    return NO_CONTACT_WITH_DB_NODES;
-  }
-
-  NdbApiSignal* signal = getSignal();
-  if (signal == NULL) {
-    return COULD_NOT_ALLOCATE_MEMORY;
-  }
-
-  GrepReq* req = CAST_PTR(GrepReq, signal->getDataPtrSend());
-  signal->set(TestOrd::TraceAPI, GREP, GSN_GREP_REQ, GrepReq::SignalLength);
-  req->senderRef = _ownReference;
-  req->request   = request;
-
-  int result;
-  if (waitCompleted)
-    result = sendRecSignal(nodeId, NO_WAIT, signal, true);
-  else
-    result = sendRecSignal(nodeId, NO_WAIT, signal, true);
-  if (result == -1) {
-    return SEND_OR_RECEIVE_FAILED;
-  }
-
-  /**
-   * @todo
-   * Maybe add that we should receive a confirmation that the 
-   * request was received ok.
-   * Then we should give the user the correct repReqId.
-   */
-
-  *repReqId = 4711;
-
+  abort();
   return 0;
 }
 

--- 1.12/ndb/src/ndbapi/DictCache.cpp	2005-06-04 10:14:28 +02:00
+++ 1.13/ndb/src/ndbapi/DictCache.cpp	2005-08-18 14:02:20 +02:00
@@ -21,6 +21,9 @@
 #include <NdbCondition.h>
 #include <NdbSleep.h>
 
+static NdbTableImpl f_invalid_table;
+static NdbTableImpl f_altered_table;
+
 Ndb_local_table_info *
 Ndb_local_table_info::create(NdbTableImpl *table_impl, Uint32 sz)
 {
@@ -164,21 +167,41 @@
   
   TableVersion & ver = vers->back();
   if(ver.m_status != RETREIVING || 
-     ver.m_impl != 0 || 
+     !(ver.m_impl == 0 || 
+       ver.m_impl == &f_invalid_table || ver.m_impl == &f_altered_table) || 
      ver.m_version != 0 || 
      ver.m_refCount == 0){
     abort();
   }
   
-  if(tab == 0){
+  if(tab == 0)
+  {
     // No table found in db
     vers->erase(sz - 1);
-  } else {
+  } 
+  else if (ver.m_impl == 0) {
     ver.m_impl = tab;
     ver.m_version = tab->m_version;
     ver.m_status = OK;
+  } 
+  else if (ver.m_impl == &f_invalid_table) 
+  {
+    ver.m_impl = tab;
+    ver.m_version = tab->m_version;
+    ver.m_status = DROPPED;
+    ver.m_impl->m_status = NdbDictionary::Object::Invalid;    
+  }
+  else if(ver.m_impl == &f_altered_table)
+  {
+    ver.m_impl = tab;
+    ver.m_version = tab->m_version;
+    ver.m_status = DROPPED;
+    ver.m_impl->m_status = NdbDictionary::Object::Altered;    
+  }
+  else
+  {
+    abort();
   }
-  
   NdbCondition_Broadcast(m_waitForTableCondition);
   return tab;
 } 
@@ -273,6 +296,47 @@
   }
   
   abort();
+}
+
+void
+GlobalDictCache::alter_table_rep(const char * name, 
+				 Uint32 tableId, 
+				 Uint32 tableVersion,
+				 bool altered)
+{
+  const Uint32 len = strlen(name);
+  Vector<TableVersion> * vers = 
+    m_tableHash.getData(name, len);
+  
+  if(vers == 0)
+  {
+    return;
+  }
+
+  const Uint32 sz = vers->size();
+  if(sz == 0)
+  {
+    return;
+  }
+  
+  for(Uint32 i = 0; i < sz; i++)
+  {
+    TableVersion & ver = (* vers)[i];
+    if(ver.m_version == tableVersion && ver.m_impl && 
+       ver.m_impl->m_tableId == tableId)
+    {
+      ver.m_status = DROPPED;
+      ver.m_impl->m_status = altered ? 
+	NdbDictionary::Object::Altered : NdbDictionary::Object::Invalid;
+      return;
+    }
+
+    if(i == sz - 1 && ver.m_status == RETREIVING)
+    {
+      ver.m_impl = altered ? &f_altered_table : &f_invalid_table;
+      return;
+    } 
+  }
 }
 
 template class Vector<GlobalDictCache::TableVersion>;

--- 1.7/ndb/src/ndbapi/DictCache.hpp	2005-06-04 10:14:28 +02:00
+++ 1.8/ndb/src/ndbapi/DictCache.hpp	2005-08-18 14:02:20 +02:00
@@ -68,6 +68,9 @@
   NdbTableImpl* put(const char * name, NdbTableImpl *);
   void drop(NdbTableImpl *);
   void release(NdbTableImpl *);
+
+  void alter_table_rep(const char * name, 
+		       Uint32 tableId, Uint32 tableVersion, bool altered);
 public:
   enum Status {
     OK = 0,

--- 1.53/ndb/src/ndbapi/NdbDictionaryImpl.cpp	2005-07-20 11:48:45 +02:00
+++ 1.54/ndb/src/ndbapi/NdbDictionaryImpl.cpp	2005-08-18 14:02:20 +02:00
@@ -1439,25 +1439,22 @@
   const char * originalExternalName = externalName.c_str();
 
   DBUG_ENTER("NdbDictionaryImpl::alterTable");
-  if(!get_local_table_info(originalInternalName, false)){
+  Ndb_local_table_info * local = 0;
+  if((local= get_local_table_info(originalInternalName, false)) == 0)
+  {
     m_error.code = 709;
     DBUG_RETURN(-1);
   }
+
   // Alter the table
   int ret = m_receiver.alterTable(m_ndb, impl);
   if(ret == 0){
     // Remove cached information and let it be refreshed at next access
-    if (m_localHash.get(originalInternalName) != NULL) {
-      m_localHash.drop(originalInternalName);
-      m_globalHash->lock();
-      NdbTableImpl * cachedImpl = m_globalHash->get(originalInternalName);
-      // If in local cache it must be in global
-      if (!cachedImpl)
-	abort();
-      cachedImpl->m_status = NdbDictionary::Object::Invalid;
-      m_globalHash->drop(cachedImpl);
-      m_globalHash->unlock();
-    }
+    m_globalHash->lock();
+    local->m_table_impl->m_status = NdbDictionary::Object::Invalid;
+    m_globalHash->drop(local->m_table_impl);
+    m_globalHash->unlock();
+    m_localHash.drop(originalInternalName);
   }
   DBUG_RETURN(ret);
 }

--- 1.30/ndb/src/ndbapi/TransporterFacade.cpp	2005-04-20 15:35:20 +02:00
+++ 1.31/ndb/src/ndbapi/TransporterFacade.cpp	2005-08-18 14:02:20 +02:00
@@ -35,6 +35,7 @@
 #include <ndb_version.h>
 #include <SignalLoggerManager.hpp>
 #include <kernel/ndb_limits.h>
+#include <signaldata/AlterTable.hpp>
 
 //#define REPORT_TRANSPORTER
 //#define API_TRACE;
@@ -305,6 +306,17 @@
 	 theFacade->theArbitMgr->doStop(theData);
        break;
 
+     case GSN_ALTER_TABLE_REP:
+     {
+       const AlterTableRep* rep = (const AlterTableRep*)theData;
+       theFacade->m_globalDictCache.lock();
+       theFacade->m_globalDictCache.
+	 alter_table_rep((const char*)ptr[0].p, 
+			 rep->tableId,
+			 rep->tableVersion,
+			 rep->changeType == AlterTableRep::CT_ALTERED);
+       theFacade->m_globalDictCache.unlock();
+     }
      default:
        break;
        

--- 1.163/sql/ha_ndbcluster.cc	2005-06-27 15:47:38 +02:00
+++ 1.164/sql/ha_ndbcluster.cc	2005-08-18 14:02:20 +02:00
@@ -3266,7 +3266,10 @@
       DBUG_PRINT("info", ("Table schema version: %d", 
                           tab->getObjectVersion()));
       // Check if thread has stale local cache
-      if (tab->getObjectStatus() == NdbDictionary::Object::Invalid)
+      // New transaction must not use old tables... (trans != 0)
+      // Running might...
+      if ((trans && tab->getObjectStatus() != NdbDictionary::Object::Retrieved)
+	  || tab->getObjectStatus() == NdbDictionary::Object::Invalid)
       {
         invalidate_dictionary_cache(FALSE);
         if (!(tab= dict->getTable(m_tabname, &tab_info)))

--- 1.2/ndb/src/kernel/blocks/Makefile.am	2004-11-10 00:02:57 +01:00
+++ 1.3/ndb/src/kernel/blocks/Makefile.am	2005-08-18 14:02:19 +02:00
@@ -13,7 +13,6 @@
         backup          \
         dbutil          \
         suma            \
-        grep		\
 	dbtux
 
 windoze-dsp:
Thread
bk commit into 4.1 tree (jonas:1.2338) BUG#12118jonas18 Aug