List:Internals« Previous MessageNext Message »
From:tomas Date:January 4 2006 3:03pm
Subject:bk commit into 5.1 tree (tomas:1.1988)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of tomas. When tomas 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.1988 06/01/04 16:03:22 tomas@stripped +22 -0
  intermediate commit, not to be pushed

  storage/ndb/tools/restore/restore_main.cpp
    1.37 06/01/04 16:03:14 tomas@stripped +2 -1
    intermediate commit, not to be pushed

  storage/ndb/tools/restore/consumer.hpp
    1.8 06/01/04 16:03:14 tomas@stripped +1 -0
    intermediate commit, not to be pushed

  storage/ndb/src/ndbapi/ndberror.c
    1.45 06/01/04 16:03:14 tomas@stripped +8 -2
    intermediate commit, not to be pushed

  storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp
    1.25 06/01/04 16:03:14 tomas@stripped +0 -13
    intermediate commit, not to be pushed

  storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp
    1.97 06/01/04 16:03:13 tomas@stripped +18 -18
    intermediate commit, not to be pushed

  storage/ndb/src/kernel/blocks/suma/Suma.hpp
    1.10 06/01/04 16:03:13 tomas@stripped +2 -2
    intermediate commit, not to be pushed

  storage/ndb/src/kernel/blocks/suma/Suma.cpp
    1.31 06/01/04 16:03:13 tomas@stripped +20 -10
    intermediate commit, not to be pushed

  storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp
    1.25 06/01/04 16:03:13 tomas@stripped +2 -6
    intermediate commit, not to be pushed

  storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp
    1.64 06/01/04 16:03:13 tomas@stripped +74 -8
    intermediate commit, not to be pushed

  storage/ndb/include/ndbapi/ndberror.h
    1.11 06/01/04 16:03:13 tomas@stripped +2 -1
    intermediate commit, not to be pushed

  storage/ndb/include/ndbapi/NdbError.hpp
    1.10 06/01/04 16:03:13 tomas@stripped +6 -1
    intermediate commit, not to be pushed

  storage/ndb/include/ndbapi/NdbDictionary.hpp
    1.60 06/01/04 16:03:13 tomas@stripped +2 -1
    intermediate commit, not to be pushed

  storage/ndb/include/kernel/signaldata/SumaImpl.hpp
    1.8 06/01/04 16:03:13 tomas@stripped +13 -4
    intermediate commit, not to be pushed

  storage/ndb/include/kernel/signaldata/CreateEvnt.hpp
    1.14 06/01/04 16:03:13 tomas@stripped +36 -87
    intermediate commit, not to be pushed

  sql/sql_base.cc
    1.280 06/01/04 16:03:13 tomas@stripped +5 -3
    intermediate commit, not to be pushed

  sql/mysqld.cc
    1.496 06/01/04 16:03:13 tomas@stripped +2 -2
    intermediate commit, not to be pushed

  sql/mysql_priv.h
    1.347 06/01/04 16:03:13 tomas@stripped +1 -1
    intermediate commit, not to be pushed

  sql/ha_ndbcluster_binlog.h
    1.3 06/01/04 16:03:13 tomas@stripped +4 -3
    intermediate commit, not to be pushed

  sql/ha_ndbcluster_binlog.cc
    1.3 06/01/04 16:03:13 tomas@stripped +56 -42
    intermediate commit, not to be pushed

  sql/ha_ndbcluster.cc
    1.222 06/01/04 16:03:12 tomas@stripped +32 -36
    intermediate commit, not to be pushed

  mysql-test/t/ndb_multi.test
    1.8 06/01/04 16:03:12 tomas@stripped +5 -4
    intermediate commit, not to be pushed

  mysql-test/r/ndb_multi.result
    1.7 06/01/04 16:03:12 tomas@stripped +2 -9
    intermediate commit, not to be pushed

# 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:	tomas
# Host:	poseidon.ndb.mysql.com
# Root:	/home/tomas/mysql-5.1-wl2325-repl

--- 1.346/sql/mysql_priv.h	2005-11-24 09:59:02 +01:00
+++ 1.347/sql/mysql_priv.h	2006-01-04 16:03:13 +01:00
@@ -1022,7 +1022,7 @@
 bool remove_table_from_cache(THD *thd, const char *db, const char *table,
                              uint flags);
 
-bool close_cached_tables(THD *thd, bool wait_for_refresh, TABLE_LIST *tables);
+bool close_cached_tables(THD *thd, bool wait_for_refresh, TABLE_LIST *tables, bool have_lock = FALSE);
 void copy_field_from_tmp_record(Field *field,int offset);
 bool fill_record(THD *thd, Field **field, List<Item> &values,
                  bool ignore_errors);

--- 1.495/sql/mysqld.cc	2005-11-24 09:59:02 +01:00
+++ 1.496/sql/mysqld.cc	2006-01-04 16:03:13 +01:00
@@ -410,6 +410,8 @@
 ulong opt_ndb_cache_check_time;
 const char *opt_ndb_mgmd;
 ulong opt_ndb_nodeid;
+ulong ndb_report_thresh_binlog_epoch_slip;
+ulong ndb_report_thresh_binlog_mem_usage;
 
 extern struct show_var_st ndb_status_variables[];
 extern const char *ndb_distribution_names[];
@@ -5226,7 +5228,6 @@
    (gptr*) &global_system_variables.ndb_force_send,
    (gptr*) &global_system_variables.ndb_force_send,
    0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0},
-#ifdef HAVE_NDB_BINLOG
   {"ndb-report-thresh-binlog-epoch-slip", OPT_NDB_REPORT_THRESH_BINLOG_EPOCH_SLIP,
    "Threshold on number of epochs to be behind before reporting binlog status. "
    "E.g. 3 means that if the difference between what epoch has been received "
@@ -5243,7 +5244,6 @@
    (gptr*) &ndb_report_thresh_binlog_mem_usage,
    (gptr*) &ndb_report_thresh_binlog_mem_usage,
    0, GET_ULONG, REQUIRED_ARG, 10, 0, 100, 0, 0, 0},
-#endif
   {"ndb-use-exact-count", OPT_NDB_USE_EXACT_COUNT,
    "Use exact records count during query planning and for fast "
    "select count(*), disable for faster queries.",

--- 1.279/sql/sql_base.cc	2005-11-19 16:14:06 +01:00
+++ 1.280/sql/sql_base.cc	2006-01-04 16:03:13 +01:00
@@ -264,13 +264,14 @@
 */
 
 bool close_cached_tables(THD *thd, bool if_wait_for_refresh,
-			 TABLE_LIST *tables)
+			 TABLE_LIST *tables, bool have_lock)
 {
   bool result=0;
   DBUG_ENTER("close_cached_tables");
   DBUG_ASSERT(thd || (!if_wait_for_refresh && !tables));
 
-  VOID(pthread_mutex_lock(&LOCK_open));
+  if (!have_lock)
+    VOID(pthread_mutex_lock(&LOCK_open));
   if (!tables)
   {
     while (unused_tables)
@@ -343,7 +344,8 @@
     for (TABLE *table=thd->open_tables; table ; table= table->next)
       table->s->version= refresh_version;
   }
-  VOID(pthread_mutex_unlock(&LOCK_open));
+  if (!have_lock)
+    VOID(pthread_mutex_unlock(&LOCK_open));
   if (if_wait_for_refresh)
   {
     pthread_mutex_lock(&thd->mysys_var->mutex);

--- 1.13/storage/ndb/include/kernel/signaldata/CreateEvnt.hpp	2005-12-06 14:54:38 +01:00
+++ 1.14/storage/ndb/include/kernel/signaldata/CreateEvnt.hpp	2006-01-04 16:03:13 +01:00
@@ -98,32 +98,11 @@
     NoError = 0,
     Undefined = 1,
     NF_FakeErrorREF = 11,
-    Busy = 701
-  };
-#if 0
-  enum ErrorCode {
-    NoError = 0,
-    Undefined = 1,
-    UndefinedTCError = 2,
-    NF_FakeErrorREF = 11,
     Busy = 701,
-    NotMaster = 702,
-    SeizeError = 703,
-    EventNotFound = 4710,
-    EventNameTooLong = 4241,
-    TooManyEvents = 4242,
-    BadRequestType = 4247,
-    InvalidName = 4248,
-    InvalidPrimaryTable = 4249,
-    InvalidEventType = 4250,
-    NotUnique = 4251,
-    AllocationError = 4252,
-    CreateEventTableFailed = 4253,
-    InvalidAttributeOrder = 4255,
-    Temporary = 0x1 << 16
+    NotMaster = 702
   };
-#endif
-  STATIC_CONST( SignalLength = 5 );
+  STATIC_CONST( SignalLength = 7 );
+  STATIC_CONST( SignalLength2 = SignalLength+1 );
 
   union {             // user block reference
     Uint32 senderRef;
@@ -139,16 +118,8 @@
   };
   Uint32 m_errorLine;
   Uint32 m_errorNode;
-#if 0
-  bool isTemporary() const
-  { return (errorCode &  Temporary) > 0; }
-
-  void setTemporary()
-  { errorCode |=  Temporary; }
-
-  ErrorCode setTemporary(ErrorCode ec)
-  { return (ErrorCode) (errorCode = ((Uint32) ec | (Uint32)Temporary)); }
-#endif
+  // with SignalLength2
+  Uint32 m_masterNodeId;
   Uint32 getUserRef() const {
     return m_userRef;
   }
@@ -179,6 +150,12 @@
   void setErrorNode(Uint32 val) {
     m_errorNode = val;
   }
+  Uint32 getMasterNode() const {
+    return m_masterNodeId;
+  }
+  void setMasterNode(Uint32 val) {
+    m_masterNodeId = val;
+  }
 };
 
 /**
@@ -201,6 +178,7 @@
   };
   enum EventFlags {
     EF_REPORT_ALL = 0x1 << 16,
+    EF_REPORT_SUBSCRIBE = 0x2 << 16,
     EF_ALL = 0xFFFF << 16
   };
   STATIC_CONST( SignalLengthGet = 3 );
@@ -274,7 +252,7 @@
     return m_eventType & ~EF_ALL;
   }
   void setEventType(Uint32 val) {
-    m_eventType |= (Uint32)val;
+    m_eventType = (m_eventType & EF_ALL) | (~EF_ALL & (Uint32)val);
   }
   Uint32 getEventId() const {
     return m_eventId;
@@ -291,12 +269,24 @@
   void clearFlags() {
     m_eventType&= ~EF_ALL;
   }
+  Uint32 getReportFlags() const {
+    return  m_eventType & EF_ALL;
+  }
+  void setReportFlags(Uint32 val) {
+    m_eventType = (val & EF_ALL) | (m_eventType & ~EF_ALL);
+  }
   Uint32 getReportAll() const {
     return  m_eventType & EF_REPORT_ALL ;
   }
   void setReportAll() {
     m_eventType|= EF_REPORT_ALL;
   }
+  Uint32 getReportSubscribe() const {
+    return  m_eventType & EF_REPORT_SUBSCRIBE ;
+  }
+  void setReportSubscribe() {
+    m_eventType|= EF_REPORT_SUBSCRIBE;
+  }
 };
 
 /**
@@ -389,42 +379,14 @@
   friend bool printCREATE_EVNT_REF(FILE*, const Uint32*, Uint32, Uint16);
 
   STATIC_CONST( SignalLength = 11 );
+  STATIC_CONST( SignalLength2 = SignalLength + 1 );
   enum ErrorCode {
     NoError = 0,
     Undefined = 1,
     NF_FakeErrorREF = 11,
-    Busy = 701
-  };
-#if 0
-  enum ErrorCode {
-    NoError = 0,
-    Undefined = 1,
-    UndefinedTCError = 2,
-    NF_FakeErrorREF = 11,
     Busy = 701,
-    NotMaster = 702,
-    SeizeError = 703,
-    TooManyEvents = 4707,
-    EventNameTooLong = 4708,
-    EventNameExists = 746,
-    EventNotFound = 4731,
-    AttributeNullable = 4246,
-    BadRequestType = 4247,
-    InvalidName = 4248,
-    InvalidPrimaryTable = 4249,
-    InvalidEventType = 4250,
-    NotUnique = 4251,
-    AllocationError = 4252,
-    CreateEventTableFailed = 4711,
-    InvalidAttributeOrder = 4255,
-    Temporary = 0x1 << 16
-  };
-  bool isTemporary() const;
-  void setTemporary();
-  ErrorCode setTemporary(ErrorCode ec);
-  static ErrorCode makeTemporary(ErrorCode ec);
-#endif
-
+    NotMaster = 702
+  };
   union {
     Uint32 m_userRef;             // user block reference
     Uint32 senderRef;             // user block reference
@@ -443,15 +405,8 @@
   Uint32 errorCode;
   Uint32 m_errorLine;
   Uint32 m_errorNode;
-
-#if 0
-  CreateEvntConf* getConf() {
-    return &m_conf;
-  }
-  const CreateEvntConf* getConf() const {
-    return &m_conf;
-  }
-#endif
+  // with SignalLength2
+  Uint32 m_masterNodeId;
   Uint32 getUserRef() const {
     return m_userRef;
   }
@@ -520,17 +475,11 @@
   void setErrorNode(Uint32 val) {
     m_errorNode = val;
   }
+  Uint32 getMasterNode() const {
+    return m_masterNodeId;
+  }
+  void setMasterNode(Uint32 val) {
+    m_masterNodeId = val;
+  }
 };
-#if 0
-inline bool CreateEvntRef::isTemporary() const
-{ return (errorCode &  CreateEvntRef::Temporary) > 0; }
-inline void CreateEvntRef::setTemporary()
-{ errorCode |=  CreateEvntRef::Temporary; }
-inline CreateEvntRef::ErrorCode CreateEvntRef::setTemporary(ErrorCode ec)
-{ return (CreateEvntRef::ErrorCode) 
-    (errorCode = ((Uint32) ec | (Uint32)CreateEvntRef::Temporary)); }
-inline CreateEvntRef::ErrorCode CreateEvntRef::makeTemporary(ErrorCode ec)
-{ return (CreateEvntRef::ErrorCode) 
-    ( (Uint32) ec | (Uint32)CreateEvntRef::Temporary ); }
-#endif
 #endif

--- 1.7/storage/ndb/include/kernel/signaldata/SumaImpl.hpp	2005-12-15 09:22:19 +01:00
+++ 1.8/storage/ndb/include/kernel/signaldata/SumaImpl.hpp	2006-01-04 16:03:13 +01:00
@@ -40,7 +40,8 @@
     GetFlags     = 0xff << 16,
     AddTableFlag = 0x1 << 16,
     RestartFlag  = 0x2 << 16,
-    ReportAll    = 0x4 << 16
+    ReportAll    = 0x4 << 16,
+    ReportSubscribe= 0x8 << 16
   };
   
   Uint32 senderRef;
@@ -116,7 +117,8 @@
   enum ErrorCode {
     Undefined = 1,
     NF_FakeErrorREF = 11,
-    Busy = 701
+    Busy = 701,
+    NotMaster = 702
   };
 
   STATIC_CONST( SignalLength = 7 );
@@ -131,7 +133,10 @@
   // do not change the order here!
   Uint32 errorCode;
   // with SignalLength2
-  Uint32 subscriberRef;
+  union {
+    Uint32 subscriberRef;
+    Uint32 m_masterNodeId;
+  };
 };
 
 struct SubStartConf {
@@ -182,10 +187,12 @@
   enum ErrorCode {
     Undefined = 1,
     NF_FakeErrorREF = 11,
-    Busy = 701
+    Busy = 701,
+    NotMaster = 702
   };
 
   STATIC_CONST( SignalLength = 8 );
+  STATIC_CONST( SignalLength2 = SignalLength+1 );
   
   Uint32 senderRef;
   Uint32 senderData;
@@ -195,6 +202,8 @@
   Uint32 subscriberData;
   Uint32 subscriberRef;
   Uint32 errorCode;
+  // with SignalLength2
+  Uint32 m_masterNodeId;
 };
 
 struct SubStopConf {

--- 1.59/storage/ndb/include/ndbapi/NdbDictionary.hpp	2005-12-15 09:22:19 +01:00
+++ 1.60/storage/ndb/include/ndbapi/NdbDictionary.hpp	2006-01-04 16:03:13 +01:00
@@ -1066,7 +1066,8 @@
      */
     enum EventReport {
       ER_UPDATED = 0,
-      ER_ALL = 1
+      ER_ALL = 1,
+      ER_SUBSCRIBE = 2
     };
 
     /**

--- 1.9/storage/ndb/include/ndbapi/NdbError.hpp	2005-09-15 10:42:02 +02:00
+++ 1.10/storage/ndb/include/ndbapi/NdbError.hpp	2006-01-04 16:03:13 +01:00
@@ -173,7 +173,12 @@
     /**
      * Schema object already exists
      */
-    SchemaObjectExists = ndberror_cl_schema_object_already_exists
+    SchemaObjectExists = ndberror_cl_schema_object_already_exists,
+
+    /**
+     * Request sent to non master
+     */
+    InternalTemporary = ndberror_cl_internal_temporary
   };
   
   /**

--- 1.36/storage/ndb/tools/restore/restore_main.cpp	2005-11-24 09:59:03 +01:00
+++ 1.37/storage/ndb/tools/restore/restore_main.cpp	2006-01-04 16:03:14 +01:00
@@ -235,7 +235,8 @@
      strcmp(tableName, "NDB$EVENTS_0") != 0 &&
      strcmp(tableName, "sys/def/SYSTAB_0") != 0 &&
      strcmp(tableName, "sys/def/NDB$EVENTS_0") != 0 &&
-     strcmp(tableName, NDB_REP_DB "/def/" NDB_APPLY_TABLE) != 0);
+     strcmp(tableName, NDB_REP_DB "/def/" NDB_APPLY_TABLE) != 0 &&
+     strcmp(tableName, NDB_REP_DB "/def/" NDB_SCHEMA_TABLE) != 0);
 }
 
 static void

--- 1.63/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp	2005-12-01 07:12:20 +01:00
+++ 1.64/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp	2006-01-04 16:03:13 +01:00
@@ -1994,9 +1994,9 @@
   c_opCreateTable.setSize(8);
   c_opDropTable.setSize(8);
   c_opCreateIndex.setSize(8);
-  c_opCreateEvent.setSize(8);
-  c_opSubEvent.setSize(8);
-  c_opDropEvent.setSize(8);
+  c_opCreateEvent.setSize(2);
+  c_opSubEvent.setSize(2);
+  c_opDropEvent.setSize(2);
   c_opSignalUtil.setSize(8);
   c_opDropIndex.setSize(8);
   c_opAlterIndex.setSize(8);
@@ -8602,6 +8602,23 @@
   const CreateEvntReq::RequestType requestType = req->getRequestType();
   const Uint32                     requestFlag = req->getRequestFlag();
 
+  if (refToBlock(signal->senderBlockRef()) != DBDICT &&
+      getOwnNodeId() != c_masterNodeId)
+  {
+    jam();
+    releaseSections(signal);
+    
+    CreateEvntRef * ref = (CreateEvntRef *)signal->getDataPtrSend();
+    ref->setUserRef(reference());
+    ref->setErrorCode(CreateEvntRef::NotMaster);
+    ref->setErrorLine(__LINE__);
+    ref->setErrorNode(reference());
+    ref->setMasterNode(c_masterNodeId);
+    sendSignal(signal->senderBlockRef(), GSN_CREATE_EVNT_REF, signal,
+	       CreateEvntRef::SignalLength2, JBB);
+    return;
+  }
+
   OpCreateEventPtr evntRecPtr;
   // Seize a Create Event record
   if (!c_opCreateEvent.seize(evntRecPtr)) {
@@ -8893,7 +8910,8 @@
       break;
     case CreateEvntReq::RT_USER_CREATE:
       {
-	evntRecPtr.p->m_eventRec.EVENT_TYPE = evntRecPtr.p->m_request.getEventType();
+	evntRecPtr.p->m_eventRec.EVENT_TYPE =
+          evntRecPtr.p->m_request.getEventType() | evntRecPtr.p->m_request.getReportFlags();
 	evntRecPtr.p->m_eventRec.TABLEID  = evntRecPtr.p->m_request.getTableId();
 	evntRecPtr.p->m_eventRec.TABLEVERSION=evntRecPtr.p->m_request.getTableVersion();
 	AttributeMask m = evntRecPtr.p->m_request.getAttrListBitmask();
@@ -9108,6 +9126,7 @@
       parseReadEventSys(signal, evntRecPtr.p->m_eventRec);
 
       evntRec->m_request.setEventType(evntRecPtr.p->m_eventRec.EVENT_TYPE);
+      evntRec->m_request.setReportFlags(evntRecPtr.p->m_eventRec.EVENT_TYPE);
       evntRec->m_request.setTableId(evntRecPtr.p->m_eventRec.TABLEID);
       evntRec->m_request.setTableVersion(evntRecPtr.p->m_eventRec.TABLEVERSION);
       evntRec->m_request.setAttrListBitmask(*(AttributeMask*)
@@ -9360,10 +9379,10 @@
   sumaReq->subscriptionId   = evntRecPtr.p->m_request.getEventId();
   sumaReq->subscriptionKey  = evntRecPtr.p->m_request.getEventKey();
   sumaReq->subscriptionType = SubCreateReq::TableEvent;
-  if (evntRecPtr.p->m_reportAll)
-  {
+  if (evntRecPtr.p->m_request.getReportAll())
     sumaReq->subscriptionType|= SubCreateReq::ReportAll;
-  }
+  if (evntRecPtr.p->m_request.getReportSubscribe())
+    sumaReq->subscriptionType|= SubCreateReq::ReportSubscribe;
   sumaReq->tableId          = evntRecPtr.p->m_request.getTableId();
     
 #ifdef EVENT_PH2_DEBUG
@@ -9535,6 +9554,20 @@
 
   Uint32 origSenderRef = signal->senderBlockRef();
 
+  if (refToBlock(origSenderRef) != DBDICT &&
+      getOwnNodeId() != c_masterNodeId)
+  {
+    /*
+     * Coordinator but not master
+     */
+    SubStartRef * ref = (SubStartRef *)signal->getDataPtrSend();
+    ref->senderRef = reference();
+    ref->errorCode = SubStartRef::NotMaster;
+    ref->m_masterNodeId = c_masterNodeId;
+    sendSignal(origSenderRef, GSN_SUB_START_REF, signal,
+	       SubStartRef::SignalLength2, JBB);
+    return;
+  }
   OpSubEventPtr subbPtr;
   if (!c_opSubEvent.seize(subbPtr)) {
     SubStartRef * ref = (SubStartRef *)signal->getDataPtrSend();
@@ -9714,6 +9747,9 @@
 #ifdef EVENT_DEBUG
     ndbout_c("SUB_START_REF");
 #endif
+    SubStartRef * ref = (SubStartRef *)signal->getDataPtrSend();
+    ref->senderRef = reference();
+    ref->errorCode = subbPtr.p->m_errorCode;
     sendSignal(subbPtr.p->m_senderRef, GSN_SUB_START_REF,
 	       signal, SubStartRef::SignalLength, JBB);
     if (subbPtr.p->m_reqTracker.hasConf()) {
@@ -9742,6 +9778,20 @@
 
   Uint32 origSenderRef = signal->senderBlockRef();
 
+  if (refToBlock(origSenderRef) != DBDICT &&
+      getOwnNodeId() != c_masterNodeId)
+  {
+    /*
+     * Coordinator but not master
+     */
+    SubStopRef * ref = (SubStopRef *)signal->getDataPtrSend();
+    ref->senderRef = reference();
+    ref->errorCode = SubStopRef::NotMaster;
+    ref->m_masterNodeId = c_masterNodeId;
+    sendSignal(origSenderRef, GSN_SUB_STOP_REF, signal,
+	       SubStopRef::SignalLength2, JBB);
+    return;
+  }
   OpSubEventPtr subbPtr;
   if (!c_opSubEvent.seize(subbPtr)) {
     SubStopRef * ref = (SubStopRef *)signal->getDataPtrSend();
@@ -9935,6 +9985,23 @@
   const Uint32 senderRef = signal->senderBlockRef();
   OpDropEventPtr evntRecPtr;
 
+  if (refToBlock(senderRef) != DBDICT &&
+      getOwnNodeId() != c_masterNodeId)
+  {
+    jam();
+    releaseSections(signal);
+
+    DropEvntRef * ref = (DropEvntRef *)signal->getDataPtrSend();
+    ref->setUserRef(reference());
+    ref->setErrorCode(DropEvntRef::NotMaster);
+    ref->setErrorLine(__LINE__);
+    ref->setErrorNode(reference());
+    ref->setMasterNode(c_masterNodeId);
+    sendSignal(senderRef, GSN_DROP_EVNT_REF, signal,
+	       DropEvntRef::SignalLength2, JBB);
+    return;
+  }
+
   // Seize a Create Event record
   if (!c_opDropEvent.seize(evntRecPtr)) {
     // Failed to allocate event record
@@ -10352,7 +10419,6 @@
     ret->setErrorCode(evntRecPtr.p->m_errorCode);
     ret->setErrorLine(evntRecPtr.p->m_errorLine);
     ret->setErrorNode(evntRecPtr.p->m_errorNode);
-
     sendSignal(senderRef, GSN_DROP_EVNT_REF, signal,
 	       DropEvntRef::SignalLength, JBB);
   } else {

--- 1.24/storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp	2005-12-01 07:12:20 +01:00
+++ 1.25/storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp	2006-01-04 16:03:13 +01:00
@@ -1576,17 +1576,15 @@
     RequestTracker m_reqTracker;
     // state info
     CreateEvntReq::RequestType m_requestType;
-    Uint32 m_requestFlag;
-    Uint32 m_reportAll;
     // error info
     Uint32 m_errorCode;
     Uint32 m_errorLine;
-    Uint32 m_errorNode;
+    Uint32 m_errorNode; /* also used to store master node id
+                           in case of NotMaster */
     // ctor
     OpCreateEvent() {
       memset(&m_request, 0, sizeof(m_request));
       m_requestType = CreateEvntReq::RT_UNDEFINED;
-      m_requestFlag = 0;
       m_errorCode = CreateEvntRef::NoError;
       m_errorLine = 0;
       m_errorNode = 0;
@@ -1597,8 +1595,6 @@
       m_errorLine = 0;
       m_errorNode = 0;
       m_requestType = req->getRequestType();
-      m_requestFlag = req->getRequestFlag();
-      m_reportAll = req->getReportAll();
     }
     bool hasError() {
       return m_errorCode != CreateEvntRef::NoError;

--- 1.30/storage/ndb/src/kernel/blocks/suma/Suma.cpp	2005-12-15 09:32:56 +01:00
+++ 1.31/storage/ndb/src/kernel/blocks/suma/Suma.cpp	2006-01-04 16:03:13 +01:00
@@ -1022,7 +1022,10 @@
   const Uint32 flags   = req.subscriptionType & SubCreateReq::GetFlags;
   const bool addTableFlag = (flags & SubCreateReq::AddTableFlag) != 0;
   const bool restartFlag  = (flags & SubCreateReq::RestartFlag)  != 0;
-  const bool reportAll = (flags & SubCreateReq::ReportAll)  != 0;
+  const Uint32 reportAll = (flags & SubCreateReq::ReportAll) ?
+    Subscription::REPORT_ALL : 0;
+  const Uint32 reportSubscribe = (flags & SubCreateReq::ReportSubscribe) ?
+    Subscription::REPORT_SUBSCRIBE : 0;
   const Uint32 tableId = req.tableId;
 
   Subscription key;
@@ -1071,13 +1074,13 @@
     subPtr.p->m_subscriptionId   = subId;
     subPtr.p->m_subscriptionKey  = subKey;
     subPtr.p->m_subscriptionType = type;
-    subPtr.p->m_options          = Subscription::REPORT_SUBSCRIBE;
-    subPtr.p->m_reportAll        = reportAll;
+    subPtr.p->m_options          = reportSubscribe | reportAll;
     subPtr.p->m_tableId          = tableId;
     subPtr.p->m_table_ptrI       = RNIL;
     subPtr.p->m_state            = Subscription::DEFINED;
     subPtr.p->n_subscribers      = 0;
 
+    fprintf(stderr, "table %d options %x\n", subPtr.p->m_tableId, subPtr.p->m_options);
     DBUG_PRINT("info",("Added: key.m_subscriptionId: %u, key.m_subscriptionKey: %u",
 		       key.m_subscriptionId, key.m_subscriptionKey));
 
@@ -1169,7 +1172,7 @@
   TablePtr tabPtr;
   initTable(signal,subPtr.p->m_tableId,tabPtr,syncPtr);
   tabPtr.p->n_subscribers++;
-  if (subPtr.p->m_reportAll)
+  if (subPtr.p->m_options & Subscription::REPORT_ALL)
     tabPtr.p->m_reportAll = true;
   DBUG_PRINT("info",("Suma::Table[%u]::n_subscribers: %u",
 		     tabPtr.p->m_tableId, tabPtr.p->n_subscribers));
@@ -2159,7 +2162,7 @@
     jam();
     initTable(signal,subPtr.p->m_tableId,tabPtr,subbPtr);
     tabPtr.p->n_subscribers++;
-    if (subPtr.p->m_reportAll)
+    if (subPtr.p->m_options & Subscription::REPORT_ALL)
       tabPtr.p->m_reportAll = true;
     DBUG_PRINT("info",("Suma::Table[%u]::n_subscribers: %u",
 		       tabPtr.p->m_tableId, tabPtr.p->n_subscribers));
@@ -2493,22 +2496,21 @@
                            SubscriptionPtr subPtr,
                            SubscriberPtr subbPtr)
 {
-  if (subPtr.p->n_subscribers == 0)
+  if (!(subPtr.p->m_options & Subscription::REPORT_SUBSCRIBE))
   {
-    ndbrequire(table_event != NdbDictionary::Event::_TE_SUBSCRIBE);
     return;
   }
-  if (!(subPtr.p->m_options & Subscription::REPORT_SUBSCRIBE))
+  if (subPtr.p->n_subscribers == 0)
   {
+    ndbrequire(table_event != NdbDictionary::Event::_TE_SUBSCRIBE);
     return;
   }
-
+ 
   SubTableData * data  = (SubTableData*)signal->getDataPtrSend();
   data->gci            = m_last_complete_gci + 1;
   data->tableId        = subPtr.p->m_tableId;
   data->operation      = table_event;
   data->logType        = 0;
-  data->req_nodeid     = refToNode(subbPtr.p->m_senderRef);
   data->ndbd_nodeid    = refToNode(reference());
   
   TablePtr tabPtr;
@@ -2519,9 +2521,17 @@
   {
     if (i_subbPtr.p->m_subPtrI == subPtr.i)
     {
+      data->req_nodeid = refToNode(subbPtr.p->m_senderRef);
       data->senderData = i_subbPtr.p->m_senderData;
       sendSignal(i_subbPtr.p->m_senderRef, GSN_SUB_TABLE_DATA, signal,
                  SubTableData::SignalLength, JBB);
+      if (i_subbPtr.i != subbPtr.i)
+      {
+        data->req_nodeid = refToNode(i_subbPtr.p->m_senderRef);
+        data->senderData = subbPtr.p->m_senderData;
+        sendSignal(subbPtr.p->m_senderRef, GSN_SUB_TABLE_DATA, signal,
+                   SubTableData::SignalLength, JBB);
+      }
     }
   }
 }

--- 1.9/storage/ndb/src/kernel/blocks/suma/Suma.hpp	2005-12-15 09:32:56 +01:00
+++ 1.10/storage/ndb/src/kernel/blocks/suma/Suma.hpp	2006-01-04 16:03:13 +01:00
@@ -155,11 +155,11 @@
     Uint32 m_subscriptionId;
     Uint32 m_subscriptionKey;
     Uint32 m_subscriptionType;
-    Uint32 m_reportAll;
     Uint16 m_options;
 
     enum Options {
-      REPORT_SUBSCRIBE= 1
+      REPORT_ALL       = 0x1,
+      REPORT_SUBSCRIBE = 0x2
     };
 
     enum State {

--- 1.96/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp	2005-12-06 13:06:41 +01:00
+++ 1.97/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp	2006-01-04 16:03:13 +01:00
@@ -1251,13 +1251,13 @@
     
     if(m_error.code && errcodes)
     {
-      for(int j = 0; errcodes[j] ; j++){
+      int j;
+      for(j = 0; errcodes[j] ; j++){
 	if(m_error.code == errcodes[j]){
-	  m_error.code = 0;
 	  break;
 	}
       }
-      if(!m_error.code) // Accepted error code
+      if(errcodes[j]) // Accepted error code
 	continue;
     }
     break;
@@ -2741,13 +2741,10 @@
     req->setAttrListBitmask(evnt.m_attrListBitmask);
     req->setEventType(evnt.mi_type);
     req->clearFlags();
-    switch (evnt.m_rep) {
-    case (NdbDictionary::Event::ER_UPDATED):
-      // Default
-      break;
-    case(NdbDictionary::Event::ER_ALL):
+    if (evnt.m_rep & NdbDictionary::Event::ER_ALL)
       req->setReportAll();
-    }
+    if (evnt.m_rep & NdbDictionary::Event::ER_SUBSCRIBE)
+      req->setReportSubscribe();
   }
 
   UtilBufferWriter w(m_buffer);
@@ -2772,12 +2769,11 @@
   ptr[0].p = (Uint32*)m_buffer.get_data();
   ptr[0].sz = (m_buffer.length()+3) >> 2;
 
-  int errCodes[] = { CreateEvntRef::Busy, 0 };
   int ret = dictSignal(&tSignal,ptr, 1,
 		       0, // master
 		       WAIT_CREATE_INDX_REQ,
 		       WAITFOR_RESPONSE_TIMEOUT, 100,
-		       errCodes, 0);
+		       0, -1);
 
   if (ret) {
     DBUG_RETURN(ret);
@@ -2842,12 +2838,11 @@
 		     "subscriberData=%d",req->subscriptionId,
 		     req->subscriptionKey,req->subscriberData));
 
-  int errCodes[] = { SubStartRef::Busy, 0 };
   DBUG_RETURN(dictSignal(&tSignal,NULL,0,
 			 0 /*use masternode id*/,
 			 WAIT_CREATE_INDX_REQ /*WAIT_CREATE_EVNT_REQ*/,
 			 -1, 100,
-			 errCodes, 0));
+			 0, -1));
 }
 
 int
@@ -2881,12 +2876,11 @@
 		     "subscriberData=%d",req->subscriptionId,
 		     req->subscriptionKey,req->subscriberData));
 
-  int errCodes[] = { SubStopRef::Busy, 0 };
   DBUG_RETURN(dictSignal(&tSignal,NULL,0,
 			 0 /*use masternode id*/,
 			 WAIT_CREATE_INDX_REQ /*WAIT_SUB_STOP__REQ*/,
 			 -1, 100,
-			 errCodes, 0));
+			 0, -1));
 }
 
 NdbEventImpl * 
@@ -3024,6 +3018,8 @@
   m_error.code= ref->getErrorCode();
   DBUG_PRINT("error",("error=%d,line=%d,node=%d",ref->getErrorCode(),
 		      ref->getErrorLine(),ref->getErrorNode()));
+  if (m_error.code == CreateEvntRef::NotMaster)
+    m_masterNodeId = ref->getMasterNode();
   m_waiter.signal(NO_WAIT);
   DBUG_VOID_RETURN;
 }
@@ -3061,6 +3057,8 @@
 
   DBUG_PRINT("error",("subscriptionId=%d,subscriptionKey=%d,subscriberData=%d,error=%d",
 		      subscriptionId,subscriptionKey,subscriberData,m_error.code));
+  if (m_error.code == SubStopRef::NotMaster)
+    m_masterNodeId = subStopRef->m_masterNodeId;
   m_waiter.signal(NO_WAIT);
   DBUG_VOID_RETURN;
 }
@@ -3109,6 +3107,8 @@
   const SubStartRef * const subStartRef=
     CAST_CONSTPTR(SubStartRef, signal->getDataPtr());
   m_error.code= subStartRef->errorCode;
+  if (m_error.code == SubStartRef::NotMaster)
+    m_masterNodeId = subStartRef->m_masterNodeId;
   m_waiter.signal(NO_WAIT);
   DBUG_VOID_RETURN;
 }
@@ -3149,12 +3149,11 @@
   ptr[0].p = (Uint32*)m_buffer.get_data();
   ptr[0].sz = (m_buffer.length()+3) >> 2;
 
-  //TODO
   return dictSignal(&tSignal,ptr, 1,
 		    0 /*use masternode id*/,
 		    WAIT_CREATE_INDX_REQ,
 		    -1, 100,
-		    0, 0);
+		    0, -1);
 }
 
 void
@@ -3177,7 +3176,8 @@
 
   DBUG_PRINT("info",("ErrorCode=%u Errorline=%u ErrorNode=%u",
 	     ref->getErrorCode(), ref->getErrorLine(), ref->getErrorNode()));
-
+  if (m_error.code == DropEvntRef::NotMaster)
+    m_masterNodeId = ref->getMasterNode();
   m_waiter.signal(NO_WAIT);
   DBUG_VOID_RETURN;
 }

--- 1.24/storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp	2005-12-15 09:21:05 +01:00
+++ 1.25/storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp	2006-01-04 16:03:14 +01:00
@@ -1391,10 +1391,6 @@
     /* report less free buffer than m_free_thresh,
        next report when more free than 2 * m_free_thresh
     */
-    fprintf(stderr, "line: %d, m_free_data_sz %d, m_min_free_thresh %d, "
-            "m_max_free_thresh %d, m_total_alloc %d, m_free_thresh %d\n",
-            __LINE__, m_free_data_sz, m_min_free_thresh,
-            m_max_free_thresh, m_total_alloc, m_free_thresh);
     m_min_free_thresh= 0;
     m_max_free_thresh= 2 * m_free_thresh;
     goto send_report;
@@ -1406,10 +1402,6 @@
     /* report more free than 2 * m_free_thresh
        next report when less free than m_free_thresh
     */
-    fprintf(stderr, "line: %d, m_free_data_sz %d, m_min_free_thresh %d, "
-            "m_max_free_thresh %d, m_total_alloc %d, m_free_thresh %d\n",
-            __LINE__, m_free_data_sz, m_min_free_thresh,
-            m_max_free_thresh, m_total_alloc, m_free_thresh);
     m_min_free_thresh= m_free_thresh;
     m_max_free_thresh= 100;
     goto send_report;
@@ -1417,11 +1409,6 @@
 
   if (latest_gci-apply_gci >=  m_gci_slip_thresh)
   {
-    fprintf(stderr, "line: %d, m_free_data_sz %d, m_min_free_thresh %d, "
-            "m_max_free_thresh %d, m_total_alloc %d, m_free_thresh %d\n",
-            __LINE__, m_free_data_sz, m_min_free_thresh,
-            m_max_free_thresh, m_total_alloc, m_free_thresh);
-    fprintf(stderr, "%lld %lld %d\n", latest_gci, apply_gci,  m_gci_slip_thresh);
     goto send_report;
   }
   return;

--- 1.221/sql/ha_ndbcluster.cc	2005-12-15 09:32:56 +01:00
+++ 1.222/sql/ha_ndbcluster.cc	2006-01-04 16:03:12 +01:00
@@ -109,7 +109,7 @@
 static byte *ndbcluster_get_key(NDB_SHARE *share,uint *length,
                                 my_bool not_used __attribute__((unused)));
 #ifdef HAVE_NDB_BINLOG
-static int rename_share(NDB_SHARE *share, const char *new_key);
+static int rename_share(NDB_SHARE *share, const char *new_key, bool have_lock);
 #endif
 static void ndb_set_fragmentation(NDBTAB &tab, TABLE *table, uint pk_len);
 
@@ -134,8 +134,6 @@
 */
 static uint32 dummy_buf;
 
-static int ndbcluster_create_event(Ndb *ndb, const NDBTAB *table,
-                                   const char *event_name, NDB_SHARE *share);
 /*
   Stats that can be retrieved from ndb
 */
@@ -3876,7 +3874,8 @@
 #ifdef HAVE_NDB_BINLOG
     ndbcluster_create_binlog_setup(get_ndb(), name2, m_dbname, m_tabname,
                                    ndb_binlog_thread_running > 0 &&
-                                   !is_prefix(m_tabname, tmp_file_prefix));
+                                   !is_prefix(m_tabname, tmp_file_prefix),
+                                   0, TRUE);
 #endif /* HAVE_NDB_BINLOG */
     DBUG_RETURN(my_errno);
   }
@@ -4037,7 +4036,7 @@
       uint length= (uint) strlen(key);
       if ((share= (NDB_SHARE*) hash_search(&ndbcluster_open_tables,
                                            (byte*) key, length)))
-        handle_trailing_share(share);
+        handle_trailing_share(share, TRUE);
     }
     /*
       get a new share
@@ -4074,20 +4073,18 @@
       sql_print_information("NDB Binlog: CREATE TABLE Event: %s",
                             event_name.c_ptr());
 
-      ndbcluster_log_schema_op(current_thd, share,
-                               current_thd->query, current_thd->query_length,
-                               share->db, share->table_name,
-                               0, 0,
-                               SOT_CREATE_TABLE);
-
       if (share && ndb_binlog_thread_running > 0 &&
           ndbcluster_create_event_ops(share, t, event_name.c_ptr()) < 0)
       {
         sql_print_error("NDB Binlog: FAILED CREATE TABLE event operations."
                         " Event: %s", name2);
         /* a warning has been issued to the client */
-        break;
       }
+      ndbcluster_log_schema_op(current_thd, share,
+                               current_thd->query, current_thd->query_length,
+                               share->db, share->table_name,
+                               0, 0,
+                               SOT_CREATE_TABLE);
       break;
     }
   }
@@ -4192,7 +4189,7 @@
   if (ndb_binlog_thread_running > 0 &&
       (share= get_share(from, false)))
   {
-    int r= rename_share(share, to);
+    int r= rename_share(share, to, TRUE);
     DBUG_ASSERT(r == 0);
   }
 #endif
@@ -4206,7 +4203,7 @@
 #ifdef HAVE_NDB_BINLOG
     if (share)
     {
-      int r= rename_share(share, from);
+      int r= rename_share(share, from, TRUE);
       DBUG_ASSERT(r == 0);
       free_share(&share);
     }
@@ -4241,19 +4238,6 @@
 
   if (!result && !is_prefix(new_tabname, tmp_file_prefix))
   {
-    if (is_old_table_tmpfile)
-      ndbcluster_log_schema_op(current_thd, share,
-                               current_thd->query, current_thd->query_length,
-                               share->db, share->table_name,
-                               0, 0,
-                               SOT_ALTER_TABLE);
-    else
-      ndbcluster_log_schema_op(current_thd, share,
-                               current_thd->query, current_thd->query_length,
-                               share->db, share->table_name,
-                               0, 0,
-                               SOT_RENAME_TABLE);
-
     /* always create an event for the table */
     String event_name(INJECTOR_EVENT_LEN);
     ndb_rep_event_name(&event_name, to + sizeof(share_prefix) - 1, 0);
@@ -4283,6 +4267,18 @@
                           "Creating event for logging table failed. "
                           "See error log for details.");
     }
+    if (is_old_table_tmpfile)
+      ndbcluster_log_schema_op(current_thd, share,
+                               current_thd->query, current_thd->query_length,
+                               share->db, share->table_name,
+                               0, 0,
+                               SOT_ALTER_TABLE);
+    else
+      ndbcluster_log_schema_op(current_thd, share,
+                               current_thd->query, current_thd->query_length,
+                               share->db, share->table_name,
+                               0, 0,
+                               SOT_RENAME_TABLE);
   }
   if (share)
     free_share(&share);
@@ -4381,7 +4377,7 @@
   */
   int table_dropped= dict->getNdbError().code != 709;
 
-  if (!is_prefix(table_name, tmp_file_prefix))
+  if (!is_prefix(table_name, tmp_file_prefix) && share)
   {
     ndbcluster_log_schema_op(current_thd, share,
                              current_thd->query, current_thd->query_length,
@@ -4389,8 +4385,8 @@
                              0, 0,
                              SOT_DROP_TABLE);
   }
-
-  if (table_dropped && share && share->op)
+  else if (table_dropped && share && share->op) /* ndbcluster_log_schema_op
+                                                   will do a force GCP */
     dict->forceGCPWait();
 
   if (!is_prefix(table_name, tmp_file_prefix))
@@ -5011,7 +5007,7 @@
                                          ndb_binlog_thread_running > 0 &&
                                          !is_prefix(elmt.name,
                                                     tmp_file_prefix),
-                                         share);
+                                         share, FALSE);
         }
         else
           pthread_mutex_unlock(&ndbcluster_mutex);
@@ -5149,7 +5145,7 @@
         pthread_mutex_unlock(&ndbcluster_mutex);
         ndbcluster_create_binlog_setup(ndb, name, db, file_name,
                                        !is_prefix(file_name, tmp_file_prefix),
-                                       share);
+                                       share, FALSE);
         pthread_mutex_lock(&ndbcluster_mutex);
       }
     }
@@ -5908,7 +5904,7 @@
   
   Must be called with previous pthread_mutex_lock(&ndbcluster_mutex)
 */
-int handle_trailing_share(NDB_SHARE *share)
+int handle_trailing_share(NDB_SHARE *share, bool have_lock)
 {
   static ulong trailing_share_id= 0;
   DBUG_ENTER("handle_trailing_share");
@@ -5916,7 +5912,7 @@
   ++share->use_count;
   pthread_mutex_unlock(&ndbcluster_mutex);
 
-  close_cached_tables((THD*) 0, 0, (TABLE_LIST*) 0);
+  close_cached_tables((THD*) 0, 0, (TABLE_LIST*) 0, have_lock);
 
   pthread_mutex_lock(&ndbcluster_mutex);
   if (!--share->use_count)
@@ -5978,7 +5974,7 @@
 /*
   Rename share is used during rename table.
 */
-static int rename_share(NDB_SHARE *share, const char *new_key)
+static int rename_share(NDB_SHARE *share, const char *new_key, bool have_lock)
 {
   NDB_SHARE *tmp;
   pthread_mutex_lock(&ndbcluster_mutex);
@@ -5987,7 +5983,7 @@
                               share->key, share->key_length));
   if ((tmp= (NDB_SHARE*) hash_search(&ndbcluster_open_tables,
                                      (byte*) new_key, new_length)))
-    handle_trailing_share(tmp);
+    handle_trailing_share(tmp, have_lock);
 
   /* remove the share from hash */
   hash_delete(&ndbcluster_open_tables, (byte*) share);

--- 1.6/mysql-test/r/ndb_multi.result	2005-11-24 09:59:01 +01:00
+++ 1.7/mysql-test/r/ndb_multi.result	2006-01-04 16:03:12 +01:00
@@ -30,13 +30,6 @@
 create table t1 (a int) engine=ndbcluster;
 insert into t1 value (2);
 select * from t1;
-ERROR HY000: Table definition has changed, please retry transaction
-show warnings;
-Level	Code	Message
-Error	1296	Got error 241 'Invalid schema object version' from NDB
-Error	1412	Table definition has changed, please retry transaction
-Error	1105	Unknown error
-select * from t1;
 a
 2
 flush status;
@@ -59,13 +52,13 @@
 1	Hi!	89	Longtext column
 show status like 'handler_discover%';
 Variable_name	Value
-Handler_discover	1
+Handler_discover	0
 show tables like 't4';
 Tables_in_test (t4)
 t4
 show status like 'handler_discover%';
 Variable_name	Value
-Handler_discover	2
+Handler_discover	0
 show tables;
 Tables_in_test
 t1

--- 1.7/mysql-test/t/ndb_multi.test	2005-11-24 09:59:01 +01:00
+++ 1.8/mysql-test/t/ndb_multi.test	2006-01-04 16:03:12 +01:00
@@ -40,10 +40,11 @@
 create table t1 (a int) engine=ndbcluster;
 insert into t1 value (2);
 connection server1;
-# Currently a retry is required remotely
---error 1412
-select * from t1;
-show warnings;
+## Currently a retry is required remotely
+#--error 1412
+#select * from t1;
+#show warnings;
+# Table definition change should be propagated automatically
 select * from t1;
 
 # Connect to server2 and use the tables from there

--- 1.10/storage/ndb/include/ndbapi/ndberror.h	2005-09-15 10:42:02 +02:00
+++ 1.11/storage/ndb/include/ndbapi/ndberror.h	2006-01-04 16:03:13 +01:00
@@ -50,7 +50,8 @@
   ndberror_cl_unknown_error_code = 14,
   ndberror_cl_node_shutdown = 15,
   ndberror_cl_configuration = 16,
-  ndberror_cl_schema_object_already_exists = 17 
+  ndberror_cl_schema_object_already_exists = 17,
+  ndberror_cl_internal_temporary = 18
 } ndberror_classification_enum;
 
 

--- 1.44/storage/ndb/src/ndbapi/ndberror.c	2005-11-07 12:19:09 +01:00
+++ 1.45/storage/ndb/src/ndbapi/ndberror.c	2006-01-04 16:03:14 +01:00
@@ -59,6 +59,8 @@
 
 #define OE ndberror_cl_schema_object_already_exists
 
+#define IT ndberror_cl_internal_temporary
+
 /* default mysql error code for unmapped codes */
 #define DMEC -1
 
@@ -207,6 +209,7 @@
   /**
    * OverloadError
    */
+  { 701,  DMEC, OL, "System busy with other schema operation" },
   { 410,  DMEC, OL, "REDO log files overloaded, consult online manual (decrease TimeBetweenLocalCheckpoints, and|or increase NoOfFragmentLogFiles)" },
   { 677,  DMEC, OL, "Index UNDO buffers overloaded (increase UndoIndexBuffer)" },
   { 891,  DMEC, OL, "Data UNDO buffers overloaded (increase UndoDataBuffer)" },
@@ -214,6 +217,10 @@
   { 4006, DMEC, OL, "Connect failure - out of connection objects (increase MaxNoOfConcurrentTransactions)" }, 
 
 
+  /*
+   * Internal Temporary
+   */
+  { 702,  DMEC, IT, "Request to non-master" },
   
   /**
    * Internal errors
@@ -238,7 +245,6 @@
   { 287,  DMEC, IE, "Index corrupted" },
   { 631,  DMEC, IE, "631" },
   { 632,  DMEC, IE, "632" },
-  { 702,  DMEC, IE, "Request to non-master" },
   { 706,  DMEC, IE, "Inconsistency during table creation" },
   { 809,  DMEC, IE, "809" },
   { 812,  DMEC, IE, "812" },
@@ -334,7 +340,6 @@
   /**
    * SchemaError
    */
-  { 701,  DMEC, SE, "System busy with other schema operation" },
   { 703,  DMEC, SE, "Invalid table format" },
   { 704,  DMEC, SE, "Attribute name too long" },
   { 705,  DMEC, SE, "Table name too long" },
@@ -614,6 +619,7 @@
   { ST_T, OL, "Overload error"},
   { ST_T, TO, "Timeout expired"},
   { ST_T, NS, "Node shutdown"},
+  { ST_T, IT, "Internal temporary"},
   
   { ST_U , UR, "Unknown result error"},
   { ST_U , UE, "Unknown error code"},

--- 1.7/storage/ndb/tools/restore/consumer.hpp	2005-11-24 09:59:03 +01:00
+++ 1.8/storage/ndb/tools/restore/consumer.hpp	2006-01-04 16:03:14 +01:00
@@ -22,6 +22,7 @@
 #define NDB_REP_DB      "cluster_replication"
 #define NDB_REP_TABLE   "binlog_index"
 #define NDB_APPLY_TABLE "apply_status"
+#define NDB_SCHEMA_TABLE "schema"
 extern const char *Ndb_apply_table;
 
 class BackupConsumer {

--- 1.2/sql/ha_ndbcluster_binlog.cc	2005-12-15 09:21:05 +01:00
+++ 1.3/sql/ha_ndbcluster_binlog.cc	2006-01-04 16:03:13 +01:00
@@ -68,8 +68,6 @@
 pthread_cond_t  injector_cond;
 
 /* NDB Injector thread (used for binlog creation) */
-ulong ndb_report_thresh_binlog_epoch_slip;
-ulong ndb_report_thresh_binlog_mem_usage;
 static ulonglong ndb_latest_applied_binlog_epoch= 0;
 static ulonglong ndb_latest_handled_binlog_epoch= 0;
 static ulonglong ndb_latest_received_binlog_epoch= 0;
@@ -81,6 +79,12 @@
 extern Uint64 g_latest_trans_gci;
 
 /*
+  Global variables for holding the binlog_index table reference
+*/
+static TABLE *binlog_index= 0;
+static TABLE_LIST binlog_tables;
+
+/*
   Helper functions
 */
 
@@ -203,11 +207,20 @@
                     thd->net.report_error, thd->query_error);
   }
 
-  thd->options= thd->options;
+  thd->options= save_thd_options;
   thd->query_length= save_query_length;
   thd->query= save_query;
   thd->variables.pseudo_thread_id= save_thread_id;
   thd->net= save_net;
+
+  if (thd == injector_thd)
+  {
+    /*
+      running the query will close all tables, including the binlog_index
+      used in injector_thd
+    */
+    binlog_index= 0;
+  }
 }
 
 /*
@@ -614,7 +627,7 @@
                    " ( db VARCHAR(63) NOT NULL,"
                    " name VARCHAR(63) NOT NULL,"
                    " slock BINARY(32) NOT NULL,"
-                   " query VARCHAR(2046) NOT NULL,"
+                   " query VARCHAR(4094) NOT NULL,"
                    " node_id INT UNSIGNED NOT NULL,"
                    " epoch BIGINT UNSIGNED NOT NULL,"
                    " id INT UNSIGNED NOT NULL,"
@@ -667,7 +680,7 @@
 #define SCHEMA_TYPE_I 8u
 #define SCHEMA_SIZE 9u
 #define SCHEMA_SLOCK_SIZE 32u
-#define SCHEMA_QUERY_SIZE 2048u
+#define SCHEMA_QUERY_SIZE 4096u
 
 struct Cluster_replication_schema
 {
@@ -1158,7 +1171,8 @@
   Handle _non_ data events from the storage nodes
 */
 static int
-ndb_handle_schema_change(Ndb *ndb, NdbEventOperation *pOp, NDB_SHARE *share)
+ndb_handle_schema_change(THD *thd, Ndb *ndb, NdbEventOperation *pOp,
+                         NDB_SHARE *share)
 {
   int remote_drop_table= 0, do_close_cached_tables= 0;
 
@@ -1207,7 +1221,6 @@
 
   if (do_close_cached_tables)
     close_cached_tables((THD*) 0, 0, (TABLE_LIST*) 0);
-
   return 0;
 }
 
@@ -1231,6 +1244,8 @@
     {
       Cluster_replication_schema *schema= (Cluster_replication_schema *)
         sql_alloc(sizeof(Cluster_replication_schema));
+      MY_BITMAP slock;
+      bitmap_init(&slock, schema->slock, 8*SCHEMA_SLOCK_SIZE, false);
       uint node_id= g_ndb_cluster_connection->node_id();
       ndbcluster_get_schema(share->table, schema);
       if (schema->node_id != node_id)
@@ -1261,20 +1276,17 @@
           pthread_mutex_unlock(&LOCK_open);
           {
             /* signal that schema operation has been handled */
-            MY_BITMAP slock;
-            bitmap_init(&slock, schema->slock, 8*schema->slock_length, false);
+            DBUG_DUMP("slock", (char*)schema->slock, schema->slock_length);
             if (bitmap_is_set(&slock, node_id))
               ndbcluster_update_slock(thd, schema->db, schema->name);
           }
           log_query= 1;
           break;
         case SOT_DROP_DB:
-#if 0
           run_query(thd, schema->query,
                     schema->query + schema->query_length,
                     TRUE,    /* print error */
                     TRUE);   /* don't binlog the query */
-#endif
           /* binlog dropping database after any table operations */
           schema_list->push_back(schema, mem_root);
           log_query= 0;
@@ -1282,15 +1294,11 @@
         case SOT_CREATE_DB:
           /* fall through */
         case SOT_ALTER_DB:
-#if 0
           run_query(thd, schema->query,
                     schema->query + schema->query_length,
                     TRUE,    /* print error */
                     FALSE);  /* binlog the query */
           log_query= 0;
-#else
-          log_query= 1;
-#endif
           break;
         case SOT_CLEAR_SLOCK:
         {
@@ -1331,13 +1339,13 @@
       /* do the rename of the table in the share */
       share->table->s->db= share->db;
       share->table->s->table_name= share->table_name;
-      ndb_handle_schema_change(ndb, pOp, share);
+      ndb_handle_schema_change(thd, ndb, pOp, share);
       break;
     case NDBEVENT::TE_CLUSTER_FAILURE:
     case NDBEVENT::TE_DROP:
       free_share(&schema_share);
       schema_share= 0;
-      ndb_handle_schema_change(ndb, pOp, share);
+      ndb_handle_schema_change(thd, ndb, pOp, share);
       break;
     case NDBEVENT::TE_NODE_FAILURE:
     {
@@ -1393,12 +1401,6 @@
 *********************************************************************/
 
 /*
-  Global variables for holding the binlog_index table reference
-*/
-TABLE *binlog_index= 0;
-TABLE_LIST binlog_tables;
-
-/*
   struct to hold the data to be inserted into the
   cluster_replication.binlog_index table
 */
@@ -1577,7 +1579,8 @@
                                    const char *db,
                                    const char *table_name,
                                    bool do_binlog,
-                                   NDB_SHARE *share)
+                                   NDB_SHARE *share,
+                                   bool have_lock)
 {
   DBUG_ENTER("ndbcluster_create_binlog_setup");
 
@@ -1589,10 +1592,10 @@
     share= (NDB_SHARE*) hash_search(&ndbcluster_open_tables,
                                     (byte*) key, strlen(key));
     if (share)
-      handle_trailing_share(share);
+      handle_trailing_share(share, have_lock);
   }
   else
-    handle_trailing_share(share);
+    handle_trailing_share(share, have_lock);
   
   /* Create share which is needed to hold replication information */
   if (!(share= get_share(key, true, true)))
@@ -1631,7 +1634,7 @@
     */
     if (!dict->getEvent(event_name.c_ptr()))
     {
-      if (ndbcluster_create_event(ndb, ndbtab, event_name.c_ptr()))
+      if (ndbcluster_create_event(ndb, ndbtab, event_name.c_ptr(), share))
       {
         sql_print_error("NDB Binlog: "
                         "FAILED CREATE (DISCOVER) TABLE Event: %s",
@@ -1665,7 +1668,7 @@
 
 int
 ndbcluster_create_event(Ndb *ndb, const NDBTAB *ndbtab,
-                        const char *event_name)
+                        const char *event_name, NDB_SHARE *share)
 {
   DBUG_ENTER("ndbcluster_create_event");
   NDBDICT *dict= ndb->getDictionary();
@@ -1680,6 +1683,27 @@
   NDBEVENT my_event(event_name);
   my_event.setTable(*ndbtab);
   my_event.addTableEvent(NDBEVENT::TE_ALL);
+  if (share->table->s->primary_key == MAX_KEY)
+  {
+    /* No primary key, susbscribe for all attributes */
+    my_event.setReport(NDBEVENT::ER_ALL);
+    DBUG_PRINT("info", ("subscription all"));
+  }
+  else
+  {
+    if (schema_share || strcmp(share->db, NDB_REP_DB) ||
+        strcmp(share->table_name, NDB_SCHEMA_TABLE))
+    {
+      my_event.setReport(NDBEVENT::ER_UPDATED);
+      DBUG_PRINT("info", ("subscription only updated"));
+    }
+    else
+    {
+      my_event.setReport((NDBEVENT::EventReport)
+                         (NDBEVENT::ER_ALL | NDBEVENT::ER_SUBSCRIBE));
+      DBUG_PRINT("info", ("subscription all and subscribe"));
+    }
+  }
 
   /* add all columns to the event */
   int n_cols= ndbtab->getNoOfColumns();
@@ -1796,17 +1820,6 @@
                       "is not supported", share->key);
       DBUG_RETURN(0);
     }
-    /*
-      Logging of a table without primary key is not possible since the event
-      api does not provide a "full" before image, only updated attributes
-      are returned in the before image.
-    */
-    if (table->s->primary_key == MAX_KEY)
-    {
-      sql_print_error("NDB Binlog: logging of table %s without a "
-                      "primary key is not supported", share->key);
-      DBUG_RETURN(0);
-    }
   }
 
   int do_schema_share= 0, do_apply_status_share= 0;
@@ -2063,7 +2076,6 @@
 {
   NDB_SHARE *share= (NDB_SHARE *)pOp->getCustomData();
   NDBEVENT::TableEvent type= pOp->getEventType();
-  int remote_drop_table= 0, do_close_cached_tables= 0;
 
   /* make sure to flush any pending events as they can be dependent
      on one of the tables being changed below
@@ -2123,7 +2135,7 @@
     return 0;
   }
 
-  ndb_handle_schema_change(ndb, pOp, share);
+  ndb_handle_schema_change(injector_thd, ndb, pOp, share);
   return 0;
 }
 
@@ -2445,6 +2457,9 @@
 
     if (unlikely(schema_res > 0))
     {
+      schema_ndb->
+        setReportThreshEventGCISlip(ndb_report_thresh_binlog_epoch_slip);
+      schema_ndb->setReportThreshEventFreeMem(ndb_report_thresh_binlog_mem_usage);
       NdbEventOperation *pOp= schema_ndb->nextEvent();
       while (pOp != NULL)
       {
@@ -2644,7 +2659,6 @@
   ulonglong ndb_latest_epoch= 0;
   DBUG_ENTER("ndbcluster_show_status_binlog");
   
-  ndbcluster_show_status_binlog(thd, stat_print, stat_type);
   pthread_mutex_lock(&injector_mutex);
   if (injector_ndb)
   {

--- 1.2/sql/ha_ndbcluster_binlog.h	2005-12-15 09:21:05 +01:00
+++ 1.3/sql/ha_ndbcluster_binlog.h	2006-01-04 16:03:13 +01:00
@@ -72,9 +72,10 @@
                                    const char *db,
                                    const char *table_name,
                                    bool do_binlog,
-                                   NDB_SHARE *share= 0);
+                                   NDB_SHARE *share,
+                                   bool have_lock);
 int ndbcluster_create_event(Ndb *ndb, const NDBTAB *table,
-                            const char *event_name);
+                            const char *event_name, NDB_SHARE *share);
 int ndbcluster_create_event_ops(NDB_SHARE *share,
                                 const NDBTAB *ndbtab,
                                 const char *event_name);
@@ -120,7 +121,7 @@
 NDB_SHARE *ndbcluster_get_share(NDB_SHARE *share);
 void ndbcluster_free_share(NDB_SHARE **share, bool have_lock);
 void ndbcluster_real_free_share(NDB_SHARE **share);
-int handle_trailing_share(NDB_SHARE *share);
+int handle_trailing_share(NDB_SHARE *share, bool have_lock);
 inline NDB_SHARE *get_share(const char *key,
                             bool create_if_not_exists= TRUE,
                             bool have_lock= FALSE)
Thread
bk commit into 5.1 tree (tomas:1.1988)tomas4 Jan