List:Commits« Previous MessageNext Message »
From:Alex Ivanov Date:December 13 2005 8:56pm
Subject:bk commit into 5.1 tree (aivanov:1.1962)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of alexi. When alexi 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.1962 05/12/13 23:56:22 aivanov@stripped +22 -0
  Merge mysql.com:/home/alexi/innodb-ss/mysql-5.0-ss92
  into  mysql.com:/home/alexi/innodb-ss/mysql-5.1-ss92

  support-files/mysql.spec.sh
    1.120 05/12/13 23:56:12 aivanov@stripped +0 -0
    Auto-merge

  storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp
    1.96 05/12/13 23:56:12 aivanov@stripped +0 -0
    Auto-merge

  storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp
    1.41 05/12/13 23:56:11 aivanov@stripped +0 -6
    Auto-merge

  storage/innobase/srv/srv0start.c
    1.88 05/12/13 23:56:11 aivanov@stripped +1 -26
    Null merge

  storage/innobase/srv/srv0srv.c
    1.94 05/12/13 23:56:11 aivanov@stripped +0 -12
    Null merge

  storage/innobase/row/row0mysql.c
    1.115 05/12/13 23:56:11 aivanov@stripped +0 -19
    Null merge

  storage/innobase/row/row0ins.c
    1.73 05/12/13 23:56:11 aivanov@stripped +12 -13
    Null merge

  storage/innobase/rem/rem0cmp.c
    1.30 05/12/13 23:56:11 aivanov@stripped +0 -2
    Null merge

  storage/innobase/include/srv0srv.h
    1.57 05/12/13 23:56:11 aivanov@stripped +0 -12
    Null merge

  storage/innobase/include/rem0cmp.h
    1.10 05/12/13 23:56:11 aivanov@stripped +0 -2
    Null merge

  storage/innobase/include/os0file.h
    1.41 05/12/13 23:56:11 aivanov@stripped +1 -1
    Null merge

  storage/innobase/include/dict0load.h
    1.10 05/12/13 23:56:11 aivanov@stripped +0 -2
    Null merge

  storage/innobase/include/dict0dict.h
    1.39 05/12/13 23:56:11 aivanov@stripped +0 -2
    Null merge

  storage/innobase/include/buf0buf.h
    1.33 05/12/13 23:56:11 aivanov@stripped +0 -8
    Null merge

  storage/innobase/dict/dict0load.c
    1.42 05/12/13 23:56:11 aivanov@stripped +0 -4
    Null merge

  storage/innobase/dict/dict0dict.c
    1.72 05/12/13 23:56:11 aivanov@stripped +0 -12
    Null merge

  storage/innobase/btr/btr0sea.c
    1.36 05/12/13 23:56:11 aivanov@stripped +1 -2
    Null merge

  sql/ha_innodb.cc
    1.242 05/12/13 23:56:11 aivanov@stripped +56 -53
    Null merge

  mysql-test/t/innodb.test
    1.120 05/12/13 23:56:11 aivanov@stripped +0 -34
    Null merge

  mysql-test/r/innodb.result
    1.151 05/12/13 23:56:11 aivanov@stripped +0 -29
    Null merge

  configure.in
    1.319 05/12/13 23:56:11 aivanov@stripped +5 -0
    Merged

  mysql-test/t/ndb_read_multi_range.test
    1.6 05/12/13 23:51:52 aivanov@stripped +0 -1
    Auto merged

  storage/innobase/include/srv0srv.h
    1.51.5.3 05/12/13 23:46:40 aivanov@stripped +0 -0
    Merge rename: innobase/include/srv0srv.h -> storage/innobase/include/srv0srv.h

  storage/innobase/include/rem0cmp.h
    1.6.2.2 05/12/13 23:46:40 aivanov@stripped +0 -0
    Merge rename: innobase/include/rem0cmp.h -> storage/innobase/include/rem0cmp.h

  storage/innobase/include/os0file.h
    1.34.5.3 05/12/13 23:46:40 aivanov@stripped +0 -0
    Merge rename: innobase/include/os0file.h -> storage/innobase/include/os0file.h

  storage/innobase/include/dict0load.h
    1.5.4.2 05/12/13 23:46:40 aivanov@stripped +0 -0
    Merge rename: innobase/include/dict0load.h -> storage/innobase/include/dict0load.h

  storage/innobase/include/dict0dict.h
    1.31.6.2 05/12/13 23:46:40 aivanov@stripped +0 -0
    Merge rename: innobase/include/dict0dict.h -> storage/innobase/include/dict0dict.h

  storage/innobase/include/buf0buf.h
    1.28.3.2 05/12/13 23:46:40 aivanov@stripped +0 -0
    Merge rename: innobase/include/buf0buf.h -> storage/innobase/include/buf0buf.h

  storage/innobase/dict/dict0load.c
    1.37.3.2 05/12/13 23:46:40 aivanov@stripped +0 -0
    Merge rename: innobase/dict/dict0load.c -> storage/innobase/dict/dict0load.c

  storage/innobase/dict/dict0dict.c
    1.65.5.2 05/12/13 23:46:40 aivanov@stripped +0 -0
    Merge rename: innobase/dict/dict0dict.c -> storage/innobase/dict/dict0dict.c

  storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp
    1.73.14.2 05/12/13 23:46:39 aivanov@stripped +0 -0
    Merge rename: ndb/src/kernel/blocks/dbtc/DbtcMain.cpp -> storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp

  storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp
    1.24.12.2 05/12/13 23:46:39 aivanov@stripped +0 -0
    Merge rename: ndb/src/kernel/blocks/dbdih/DbdihMain.cpp -> storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp

  storage/innobase/srv/srv0start.c
    1.80.7.3 05/12/13 23:46:39 aivanov@stripped +0 -0
    Merge rename: innobase/srv/srv0start.c -> storage/innobase/srv/srv0start.c

  storage/innobase/srv/srv0srv.c
    1.87.7.3 05/12/13 23:46:39 aivanov@stripped +0 -0
    Merge rename: innobase/srv/srv0srv.c -> storage/innobase/srv/srv0srv.c

  storage/innobase/row/row0mysql.c
    1.103.10.2 05/12/13 23:46:39 aivanov@stripped +0 -0
    Merge rename: innobase/row/row0mysql.c -> storage/innobase/row/row0mysql.c

  storage/innobase/row/row0ins.c
    1.65.8.3 05/12/13 23:46:39 aivanov@stripped +0 -0
    Merge rename: innobase/row/row0ins.c -> storage/innobase/row/row0ins.c

  storage/innobase/rem/rem0cmp.c
    1.25.3.2 05/12/13 23:46:39 aivanov@stripped +0 -0
    Merge rename: innobase/rem/rem0cmp.c -> storage/innobase/rem/rem0cmp.c

  storage/innobase/btr/btr0sea.c
    1.30.4.2 05/12/13 23:46:39 aivanov@stripped +0 -0
    Merge rename: innobase/btr/btr0sea.c -> storage/innobase/btr/btr0sea.c

# 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:	aivanov
# Host:	mysql.creware.com
# Root:	/home/alexi/innodb-ss/mysql-5.1-ss92/RESYNC

--- 1.318/configure.in	2005-12-07 17:17:10 +03:00
+++ 1.319/configure.in	2005-12-13 23:56:11 +03:00
@@ -14,6 +14,12 @@
 # See the libtool docs for information on how to do shared lib versions.
 SHARED_LIB_VERSION=15:0:0
 
+# ndb version
+NDB_VERSION_MAJOR=5
+NDB_VERSION_MINOR=0
+NDB_VERSION_BUILD=18
+NDB_VERSION_STATUS=""
+
 # Set all version vars based on $VERSION. How do we do this more elegant ?
 # Remember that regexps needs to quote [ and ] since this is run through m4
 MYSQL_NO_DASH_VERSION=`echo $VERSION | sed -e "s|[[a-z]]*-.*$||"`

--- 1.119/support-files/mysql.spec.sh	2005-12-05 20:59:57 +03:00
+++ 1.120/support-files/mysql.spec.sh	2005-12-13 23:56:12 +03:00
@@ -35,7 +35,7 @@
 License:	%{license}
 Source:		http://www.mysql.com/Downloads/MySQL-@MYSQL_BASE_VERSION@/mysql-%{mysql_version}.tar.gz
 URL:		http://www.mysql.com/
-Packager:	Lenz Grimmer <build@stripped>
+Packager:	MySQL Production Engineering Team <build@stripped>
 Vendor:		MySQL AB
 Provides:	msqlormysql MySQL-server mysql
 BuildRequires: ncurses-devel
@@ -325,7 +325,13 @@
 make test-force || true
 
 # Save mysqld-max
-mv sql/mysqld sql/mysqld-max
+# check if mysqld was installed in .libs/
+if test -f sql/.libs/mysqld
+then
+	cp sql/.libs/mysqld sql/mysqld-max
+else
+	cp sql/mysqld sql/mysqld-max
+fi
 nm --numeric-sort sql/mysqld-max > sql/mysqld-max.sym
 # Save the perror binary so it supports the NDB error codes (BUG#13740)
 mv extra/perror extra/perror.ndb
@@ -363,14 +369,19 @@
 		--with-client-ldflags='-all-static' \
 		$USE_OTHER_LIBC_DIR \
 %else
-		--with-zlib-dir=bundled \
 %endif
+		--with-zlib-dir=bundled \
 		--with-comment=\"MySQL Community Edition - Standard (GPL)\" \
 		--with-server-suffix='%{server_suffix}' \
 		--with-archive-storage-engine \
 		--with-innodb \
 		--with-big-tables"
-nm --numeric-sort sql/mysqld > sql/mysqld.sym
+if test -f sql/.libs/mysqld
+then
+	nm --numeric-sort sql/.libs/mysqld > sql/mysqld.sym
+else
+	nm --numeric-sort sql/mysqld > sql/mysqld.sym
+fi
 
 # We might want to save the config log file
 if test -n "$MYSQL_CONFLOG_DEST"
@@ -678,6 +689,8 @@
 %{_libdir}/mysql/libndbclient.a
 %{_libdir}/mysql/libndbclient.la
 %{_libdir}/mysql/libvio.a
+%{_libdir}/mysql/libz.a
+%{_libdir}/mysql/libz.la
 
 %files shared
 %defattr(-, root, root, 0755)
@@ -706,6 +719,13 @@
 # itself - note that they must be ordered by date (important when
 # merging BK trees)
 %changelog 
+* Fri Dec 12 2005 Rodrigo Novo <rodrigo@stripped>
+
+- Added zlib to the list of (static) libraries installed
+- Added check against libtool wierdness (WRT: sql/mysqld || sql/.libs/mysqld)
+- Compile MySQL with bundled zlib
+- Fixed %packager name to "MySQL Production Engineering Team"
+
 * Mon Dec 05 2005 Joerg Bruehe <joerg@stripped>
 
 - Avoid using the "bundled" zlib on "shared" builds: 

--- 1.24.12.1/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp	2005-12-13 16:41:25 +03:00
+++ 1.41/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp	2005-12-13 23:56:11 +03:00
@@ -639,9 +639,11 @@
     c_copyGCISlave.m_expectedNextWord += CopyGCIReq::DATA_SIZE;
     return;
   }//if
-  
+
+  Uint32 tmp= SYSFILE->m_restart_seq;
   memcpy(sysfileData, cdata, sizeof(sysfileData));
-  
+  SYSFILE->m_restart_seq = tmp;
+
   c_copyGCISlave.m_copyReason = reason;
   c_copyGCISlave.m_senderRef  = signal->senderBlockRef();
   c_copyGCISlave.m_senderData = copyGCI->anyData;
@@ -1613,12 +1615,15 @@
    *
    * But dont copy lastCompletedGCI:s
    */
+  Uint32 key = SYSFILE->m_restart_seq;
   Uint32 tempGCP[MAX_NDB_NODES];
   for(i = 0; i < MAX_NDB_NODES; i++)
     tempGCP[i] = SYSFILE->lastCompletedGCI[i];
 
   for(i = 0; i < Sysfile::SYSFILE_SIZE32; i++)
     sysfileData[i] = cdata[i];
+
+  SYSFILE->m_restart_seq = key;
   for(i = 0; i < MAX_NDB_NODES; i++)
     SYSFILE->lastCompletedGCI[i] = tempGCP[i];
 
@@ -3497,6 +3502,7 @@
   /*     WE ALSO COPY TO OUR OWN NODE. TO ENABLE US TO DO THIS PROPERLY WE   */
   /*     START BY CLOSING THIS FILE.                                         */
   /* ----------------------------------------------------------------------- */
+  globalData.m_restart_seq = ++SYSFILE->m_restart_seq;
   closeFile(signal, filePtr);
   filePtr.p->reqStatus = FileRecord::CLOSING_GCP;
 }//Dbdih::readingGcpLab()
@@ -5559,11 +5565,9 @@
 #endif
   }
 
-  bool ok = false;
   MasterLCPConf::State lcpState;
   switch (c_lcpState.lcpStatus) {
   case LCP_STATUS_IDLE:
-    ok = true;
     jam();
     /*------------------------------------------------*/
     /*       LOCAL CHECKPOINT IS CURRENTLY NOT ACTIVE */
@@ -5574,7 +5578,6 @@
     lcpState = MasterLCPConf::LCP_STATUS_IDLE;
     break;
   case LCP_STATUS_ACTIVE:
-    ok = true;
     jam();
     /*--------------------------------------------------*/
     /*       COPY OF RESTART INFORMATION HAS BEEN       */
@@ -5583,7 +5586,6 @@
     lcpState = MasterLCPConf::LCP_STATUS_ACTIVE;
     break;
   case LCP_TAB_COMPLETED:
-    ok = true;
     jam();
     /*--------------------------------------------------------*/
     /*       ALL LCP_REPORT'S HAVE BEEN COMPLETED FOR         */
@@ -5593,7 +5595,6 @@
     lcpState = MasterLCPConf::LCP_TAB_COMPLETED;
     break;
   case LCP_TAB_SAVED:
-    ok = true;
     jam();
     /*--------------------------------------------------------*/
     /*       ALL LCP_REPORT'S HAVE BEEN COMPLETED FOR         */
@@ -5617,15 +5618,15 @@
     break;
   case LCP_COPY_GCI:
   case LCP_INIT_TABLES:
-    ok = true;
     /**
      * These two states are handled by if statements above
      */
     ndbrequire(false);
     lcpState= MasterLCPConf::LCP_STATUS_IDLE; // remove warning
     break;
+  default:
+    ndbrequire(false);
   }//switch
-  ndbrequire(ok);
 
   Uint32 failedNodeId = c_lcpState.m_MASTER_LCPREQ_FailedNodeId;
   MasterLCPConf * const conf = (MasterLCPConf *)&signal->theData[0];
@@ -6226,96 +6227,147 @@
   3.7.1   A D D   T A B L E   M A I N L Y
   ***************************************
   */
-void Dbdih::execCREATE_FRAGMENTATION_REQ(Signal * signal){
+
+#define UNDEF_NODEGROUP 65535
+static inline void inc_node_or_group(Uint32 &node, Uint32 max_node)
+{
+  Uint32 next = node + 1;
+  node = (next == max_node ? 0 : next);
+}
+
+/*
+  Spread fragments in backwards compatible mode
+*/
+static void set_default_node_groups(Signal *signal, Uint32 noFrags)
+{
+  Uint16 *node_group_array = (Uint16*)&signal->theData[25];
+  Uint32 i;
+  node_group_array[0] = 0;
+  for (i = 1; i < noFrags; i++)
+    node_group_array[i] = UNDEF_NODEGROUP;
+}
+void Dbdih::execCREATE_FRAGMENTATION_REQ(Signal * signal)
+{
+  Uint16 node_group_id[MAX_NDB_PARTITIONS];
   jamEntry();
   CreateFragmentationReq * const req = 
     (CreateFragmentationReq*)signal->getDataPtr();
   
   const Uint32 senderRef = req->senderRef;
   const Uint32 senderData = req->senderData;
-  const Uint32 fragmentNode = req->fragmentNode;
-  const Uint32 fragmentType = req->fragmentationType;
-  //const Uint32 fragmentCount = req->noOfFragments;
+  Uint32 noOfFragments = req->noOfFragments;
+  const Uint32 fragType = req->fragmentationType;
   const Uint32 primaryTableId = req->primaryTableId;
 
   Uint32 err = 0;
   
   do {
-    Uint32 noOfFragments = 0;
-    Uint32 noOfReplicas = cnoReplicas;
-    switch(fragmentType){
-    case DictTabInfo::AllNodesSmallTable:
-      jam();
-      noOfFragments = csystemnodes;
-      break;
-    case DictTabInfo::AllNodesMediumTable:
-      jam();
-      noOfFragments = 2 * csystemnodes;
-      break;
-    case DictTabInfo::AllNodesLargeTable:
-      jam();
-      noOfFragments = 4 * csystemnodes;
-      break;
-    case DictTabInfo::SingleFragment:
-      jam();
-      noOfFragments = 1;
-      break;
-#if 0
-    case DictTabInfo::SpecifiedFragmentCount:
-      noOfFragments = (fragmentCount == 0 ? 1 : (fragmentCount + 1)/ 2);
-      break;
-#endif
-    default:
-      jam();
-      err = CreateFragmentationRef::InvalidFragmentationType;
-      break;
-    }
-    if(err)
-      break;
-   
     NodeGroupRecordPtr NGPtr;
     TabRecordPtr primTabPtr;
+    Uint32 count = 2;
+    Uint16 noOfReplicas = cnoReplicas;
+    Uint16 *fragments = (Uint16*)(signal->theData+25);
     if (primaryTableId == RNIL) {
-      if(fragmentNode == 0){
-        jam();
-        NGPtr.i = 0; 
-	if(noOfFragments < csystemnodes)
-	{
-	  NGPtr.i = c_nextNodeGroup; 
-	  c_nextNodeGroup = (NGPtr.i + 1 == cnoOfNodeGroups ? 0 : NGPtr.i + 1);
-	}
-      } else if(! (fragmentNode < MAX_NDB_NODES)) {
-        jam();
-        err = CreateFragmentationRef::InvalidNodeId;
-      } else {
-        jam();
-        const Uint32 stat = Sysfile::getNodeStatus(fragmentNode,
-                                                   SYSFILE->nodeStatus);
-        switch (stat) {
-        case Sysfile::NS_Active:
-        case Sysfile::NS_ActiveMissed_1:
-        case Sysfile::NS_ActiveMissed_2:
-        case Sysfile::NS_TakeOver:
+      jam();
+      switch ((DictTabInfo::FragmentType)fragType)
+      {
+        /*
+          Backward compatability and for all places in code not changed.
+        */
+        case DictTabInfo::AllNodesSmallTable:
+          jam();
+          noOfFragments = csystemnodes;
+          set_default_node_groups(signal, noOfFragments);
+          break;
+        case DictTabInfo::AllNodesMediumTable:
           jam();
+          noOfFragments = 2 * csystemnodes;
+          set_default_node_groups(signal, noOfFragments);
           break;
-        case Sysfile::NS_NotActive_NotTakenOver:
+        case DictTabInfo::AllNodesLargeTable:
           jam();
+          noOfFragments = 4 * csystemnodes;
+          set_default_node_groups(signal, noOfFragments);
           break;
-        case Sysfile::NS_HotSpare:
+        case DictTabInfo::SingleFragment:
           jam();
-        case Sysfile::NS_NotDefined:
+          noOfFragments = 1;
+          set_default_node_groups(signal, noOfFragments);
+          break;
+        case DictTabInfo::DistrKeyHash:
+          jam();
+        case DictTabInfo::DistrKeyLin:
           jam();
+          if (noOfFragments == 0)
+          {
+            jam();
+            noOfFragments = csystemnodes;
+            set_default_node_groups(signal, noOfFragments);
+          }
+          break;
         default:
           jam();
-          err = CreateFragmentationRef::InvalidNodeType;
+          if (noOfFragments == 0)
+          {
+            jam();
+            err = CreateFragmentationRef::InvalidFragmentationType;
+          }
           break;
+      }
+      if (err)
+        break;
+      /*
+        When we come here the the exact partition is specified
+        and there is an array of node groups sent along as well.
+      */
+      memcpy(&node_group_id[0], &signal->theData[25], 2 * noOfFragments);
+      Uint16 next_replica_node[MAX_NDB_NODES];
+      memset(next_replica_node,0,sizeof(next_replica_node));
+      Uint32 default_node_group= c_nextNodeGroup;
+      for(Uint32 fragNo = 0; fragNo < noOfFragments; fragNo++)
+      {
+        jam();
+        NGPtr.i = node_group_id[fragNo];
+        if (NGPtr.i == UNDEF_NODEGROUP)
+        {
+          jam();
+	  NGPtr.i = default_node_group; 
         }
-        if(err)
+        if (NGPtr.i > cnoOfNodeGroups)
+        {
+          jam();
+          err = CreateFragmentationRef::InvalidNodeGroup;
           break;
-        NGPtr.i = Sysfile::getNodeGroup(fragmentNode,
-                                        SYSFILE->nodeGroups);
+        }
+        ptrCheckGuard(NGPtr, MAX_NDB_NODES, nodeGroupRecord);
+        const Uint32 max = NGPtr.p->nodeCount;
+	
+	Uint32 tmp= next_replica_node[NGPtr.i];
+        for(Uint32 replicaNo = 0; replicaNo < noOfReplicas; replicaNo++)
+        {
+          jam();
+          const Uint16 nodeId = NGPtr.p->nodesInGroup[tmp];
+          fragments[count++]= nodeId;
+          inc_node_or_group(tmp, max);
+        }
+        inc_node_or_group(tmp, max);
+	next_replica_node[NGPtr.i]= tmp;
+	
+        /**
+         * Next node group for next fragment
+         */
+        inc_node_or_group(default_node_group, cnoOfNodeGroups);
+      }
+      if (err)
+      {
+        jam();
         break;
       }
+      else
+      {
+        jam();
+        c_nextNodeGroup = default_node_group;
+      }
     } else {
       if (primaryTableId >= ctabFileSize) {
         jam();
@@ -6329,49 +6381,14 @@
         err = CreateFragmentationRef::InvalidPrimaryTable;
         break;
       }
-      if (noOfFragments != primTabPtr.p->totalfragments) {
-        jam();
-        err = CreateFragmentationRef::InvalidFragmentationType;
-        break;
-      }
-    }
-    
-    Uint32 count = 2;
-    Uint16 *fragments = (Uint16*)(signal->theData+25);
-    if (primaryTableId == RNIL) {
-      jam();
-      Uint8 next_replica_node[MAX_NDB_NODES];
-      memset(next_replica_node,0,sizeof(next_replica_node));
-      for(Uint32 fragNo = 0; fragNo<noOfFragments; fragNo++){
-        jam();
-        ptrCheckGuard(NGPtr, MAX_NDB_NODES, nodeGroupRecord);      
-        const Uint32 max = NGPtr.p->nodeCount;
-	
-	Uint32 tmp= next_replica_node[NGPtr.i];
-        for(Uint32 replicaNo = 0; replicaNo<noOfReplicas; replicaNo++)
-        {
-          jam();
-          const Uint32 nodeId = NGPtr.p->nodesInGroup[tmp++];
-          fragments[count++] = nodeId;
-          tmp = (tmp >= max ? 0 : tmp);
-        }
-	tmp++;
-	next_replica_node[NGPtr.i]= (tmp >= max ? 0 : tmp);
-	
-        /**
-         * Next node group for next fragment
-         */
-        NGPtr.i++;
-        NGPtr.i = (NGPtr.i == cnoOfNodeGroups ? 0 : NGPtr.i);
-      }
-    } else {
+      noOfFragments= primTabPtr.p->totalfragments;
       for (Uint32 fragNo = 0;
-           fragNo < primTabPtr.p->totalfragments; fragNo++) {
+           fragNo < noOfFragments; fragNo++) {
         jam();
         FragmentstorePtr fragPtr;
         ReplicaRecordPtr replicaPtr;
         getFragstore(primTabPtr.p, fragNo, fragPtr);
-        fragments[count++] = fragPtr.p->preferredPrimary;
+        fragments[count++]= fragPtr.p->preferredPrimary;
         for (replicaPtr.i = fragPtr.p->storedReplicas;
              replicaPtr.i != RNIL;
              replicaPtr.i = replicaPtr.p->nextReplica) {
@@ -6379,9 +6396,9 @@
           ptrCheckGuard(replicaPtr, creplicaFileSize, replicaRecord);
           if (replicaPtr.p->procNode != fragPtr.p->preferredPrimary) {
             jam();
-            fragments[count++] = replicaPtr.p->procNode;
-          }//if
-        }//for
+            fragments[count++]= replicaPtr.p->procNode;
+          }
+        }
         for (replicaPtr.i = fragPtr.p->oldStoredReplicas;
              replicaPtr.i != RNIL;
              replicaPtr.i = replicaPtr.p->nextReplica) {
@@ -6389,25 +6406,26 @@
           ptrCheckGuard(replicaPtr, creplicaFileSize, replicaRecord);
           if (replicaPtr.p->procNode != fragPtr.p->preferredPrimary) {
             jam();
-            fragments[count++] = replicaPtr.p->procNode;
-          }//if
-        }//for
+            fragments[count++]= replicaPtr.p->procNode;
+          }
+        }
       }
     }
-    ndbrequire(count == (2 + noOfReplicas * noOfFragments)); 
+    ndbrequire(count == (2U + noOfReplicas * noOfFragments)); 
     
     CreateFragmentationConf * const conf = 
       (CreateFragmentationConf*)signal->getDataPtrSend();
     conf->senderRef = reference();
     conf->senderData = senderData;
-    conf->noOfReplicas = noOfReplicas;
-    conf->noOfFragments = noOfFragments;
+    conf->noOfReplicas = (Uint32)noOfReplicas;
+    conf->noOfFragments = (Uint32)noOfFragments;
 
-    fragments[0] = noOfReplicas;
-    fragments[1] = noOfFragments;
+    fragments[0]= noOfReplicas;
+    fragments[1]= noOfFragments;
     
     if(senderRef != 0)
     {
+      jam();
       LinearSectionPtr ptr[3];
       ptr[0].p = (Uint32*)&fragments[0];
       ptr[0].sz = (count + 1) / 2;
@@ -6419,33 +6437,17 @@
 		 ptr,
 		 1);
     }
-    else
-    {
-      // Execute direct
-      signal->theData[0] = 0;
-    }
+    // Always ACK/NACK (here ACK)
+    signal->theData[0] = 0;
     return;
   } while(false);
-
-  if(senderRef != 0)
-  {
-    CreateFragmentationRef * const ref = 
-      (CreateFragmentationRef*)signal->getDataPtrSend();
-    ref->senderRef = reference();
-    ref->senderData = senderData;
-    ref->errorCode = err;
-    sendSignal(senderRef, GSN_CREATE_FRAGMENTATION_REF, signal, 
-	       CreateFragmentationRef::SignalLength, JBB);
-  }
-  else
-  {
-    // Execute direct
-    signal->theData[0] = err;
-  }
+  // Always ACK/NACK (here NACK)
+  signal->theData[0] = err;
 }
 
 void Dbdih::execDIADDTABREQ(Signal* signal) 
 {
+  Uint32 fragType;
   jamEntry();
 
   DiAddTabReq * const req = (DiAddTabReq*)signal->getDataPtr();
@@ -6470,6 +6472,7 @@
   ptrCheckGuard(tabPtr, ctabFileSize, tabRecord);
   tabPtr.p->connectrec = connectPtr.i;
   tabPtr.p->tableType = req->tableType;
+  fragType= req->fragType;
   tabPtr.p->schemaVersion = req->schemaVersion;
   tabPtr.p->primaryTableId = req->primaryTableId;
 
@@ -6506,9 +6509,33 @@
   /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
   tabPtr.p->tabStatus = TabRecord::TS_CREATING;
   tabPtr.p->storedTable = req->storedTable;
-  tabPtr.p->method = TabRecord::HASH;
   tabPtr.p->kvalue = req->kValue;
 
+  switch ((DictTabInfo::FragmentType)fragType)
+  {
+    case DictTabInfo::AllNodesSmallTable:
+    case DictTabInfo::AllNodesMediumTable:
+    case DictTabInfo::AllNodesLargeTable:
+    case DictTabInfo::SingleFragment:
+      jam();
+    case DictTabInfo::DistrKeyLin:
+      jam();
+      tabPtr.p->method= TabRecord::LINEAR_HASH;
+      break;
+    case DictTabInfo::DistrKeyHash:
+    case DictTabInfo::DistrKeyUniqueHashIndex:
+    case DictTabInfo::DistrKeyOrderedIndex:
+      jam();
+      tabPtr.p->method= TabRecord::NORMAL_HASH;
+      break;
+    case DictTabInfo::UserDefined:
+      jam();
+      tabPtr.p->method= TabRecord::USER_DEFINED;
+      break;
+    default:
+      ndbrequire(false);
+  }
+
   union {
     Uint16 fragments[2 + MAX_FRAG_PER_NODE*MAX_REPLICAS*MAX_NDB_NODES];
     Uint32 align;
@@ -6943,17 +6970,40 @@
   tabPtr.i = req->tableId;
   Uint32 hashValue = req->hashValue;
   Uint32 ttabFileSize = ctabFileSize;
+  Uint32 fragId;
+  DiGetNodesConf * const conf = (DiGetNodesConf *)&signal->theData[0];
   TabRecord* regTabDesc = tabRecord;
   jamEntry();
   ptrCheckGuard(tabPtr, ttabFileSize, regTabDesc);
-  Uint32 fragId = hashValue & tabPtr.p->mask;
-  ndbrequire(tabPtr.p->tabStatus == TabRecord::TS_ACTIVE);
-  if (fragId < tabPtr.p->hashpointer) {
+  if (tabPtr.p->method == TabRecord::LINEAR_HASH)
+  {
     jam();
-    fragId = hashValue & ((tabPtr.p->mask << 1) + 1);
-  }//if
+    fragId = hashValue & tabPtr.p->mask;
+    ndbrequire(tabPtr.p->tabStatus == TabRecord::TS_ACTIVE);
+    if (fragId < tabPtr.p->hashpointer) {
+      jam();
+      fragId = hashValue & ((tabPtr.p->mask << 1) + 1);
+    }//if
+  }
+  else if (tabPtr.p->method == TabRecord::NORMAL_HASH)
+  {
+    jam();
+    fragId= hashValue % tabPtr.p->totalfragments;
+  }
+  else
+  {
+    jam();
+    ndbassert(tabPtr.p->method == TabRecord::USER_DEFINED);
+    fragId= hashValue;
+    if (fragId >= tabPtr.p->totalfragments)
+    {
+      jam();
+      conf->zero= 1; //Indicate error;
+      signal->theData[1]= ZUNDEFINED_FRAGMENT_ERROR;
+      return;
+    }
+  }
   getFragstore(tabPtr.p, fragId, fragPtr);
-  DiGetNodesConf * const conf = (DiGetNodesConf *)&signal->theData[0];
   Uint32 nodeCount = extractNodeInfo(fragPtr.p, conf->nodes);
   Uint32 sig2 = (nodeCount - 1) + 
     (fragPtr.p->distributionKey << 16);
@@ -7909,9 +7959,12 @@
     
     SubGcpCompleteRep * const rep = (SubGcpCompleteRep*)signal->getDataPtr();
     rep->gci = coldgcp;
-    rep->senderData = 0;
     sendSignal(SUMA_REF, GSN_SUB_GCP_COMPLETE_REP, signal, 
 	       SubGcpCompleteRep::SignalLength, JBB);
+
+    EXECUTE_DIRECT(LGMAN, GSN_SUB_GCP_COMPLETE_REP, signal, 
+		   SubGcpCompleteRep::SignalLength);
+    jamEntry();
   }
   
   jam();
@@ -8478,8 +8531,7 @@
   rf.rwfTabPtr.p->hashpointer = readPageWord(&rf);
   rf.rwfTabPtr.p->kvalue = readPageWord(&rf);
   rf.rwfTabPtr.p->mask = readPageWord(&rf);
-  ndbrequire(readPageWord(&rf) == TabRecord::HASH);
-  rf.rwfTabPtr.p->method = TabRecord::HASH;
+  rf.rwfTabPtr.p->method = (TabRecord::Method)readPageWord(&rf);
   /* ---------------------------------- */
   /* Type of table, 2 = temporary table */
   /* ---------------------------------- */
@@ -8573,7 +8625,7 @@
   writePageWord(&wf, tabPtr.p->hashpointer);
   writePageWord(&wf, tabPtr.p->kvalue);
   writePageWord(&wf, tabPtr.p->mask);
-  writePageWord(&wf, TabRecord::HASH);
+  writePageWord(&wf, tabPtr.p->method);
   writePageWord(&wf, tabPtr.p->storedTable);
 
   signal->theData[0] = DihContinueB::ZPACK_FRAG_INTO_PAGES;
@@ -11097,6 +11149,7 @@
   cnoHotSpare = 0;
   cnoOfActiveTables = 0;
   cnoOfNodeGroups = 0;
+  c_nextNodeGroup = 0;
   cnoReplicas = 0;
   coldgcp = 0;
   coldGcpId = 0;
@@ -11196,6 +11249,8 @@
     SYSFILE->takeOver[i] = 0;
   }//for
   Sysfile::setInitialStartOngoing(SYSFILE->systemRestartBits);
+  srand(time(0));
+  globalData.m_restart_seq = SYSFILE->m_restart_seq = 0;
 }//Dbdih::initRestartInfo()
 
 /*--------------------------------------------------------------------*/

--- 1.73.14.1/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp	2005-12-13 13:58:43 +03:00
+++ 1.96/storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp	2005-12-13 23:56:12 +03:00
@@ -340,7 +340,7 @@
   tabptr.p->noOfKeyAttr = desc->noOfKeyAttr;
   tabptr.p->hasCharAttr = desc->hasCharAttr;
   tabptr.p->noOfDistrKeys = desc->noOfDistrKeys;
-  
+  tabptr.p->hasVarKeys = desc->noOfVarKeys > 0;
   signal->theData[0] = tabptr.i;
   signal->theData[1] = retPtr;
   sendSignal(retRef, GSN_TC_SCHVERCONF, signal, 2, JBB);
@@ -2302,14 +2302,15 @@
 {
   Uint64 Tmp[MAX_KEY_SIZE_IN_WORDS * MAX_XFRM_MULTIPLY];
   const TableRecord* tabPtrP = &tableRecord[tabPtrI];
+  const bool hasVarKeys = tabPtrP->hasVarKeys;
   const bool hasCharAttr = tabPtrP->hasCharAttr;
-  const bool hasDistKeys = tabPtrP->noOfDistrKeys > 0;
+  const bool compute_distkey = distr && (tabPtrP->noOfDistrKeys > 0);
   
   Uint32 *dst = (Uint32*)Tmp;
   Uint32 dstPos = 0;
   Uint32 keyPartLen[MAX_ATTRIBUTES_IN_INDEX];
   Uint32 * keyPartLenPtr;
-  if(hasCharAttr)
+  if(hasCharAttr || (compute_distkey && hasVarKeys))
   {
     keyPartLenPtr = keyPartLen;
     dstPos = xfrm_key(tabPtrI, src, dst, sizeof(Tmp) >> 2, keyPartLenPtr);
@@ -2324,7 +2325,7 @@
   
   md5_hash(dstHash, (Uint64*)dst, dstPos);
   
-  if(distr && hasDistKeys)
+  if(compute_distkey)
   {
     jam();
     
@@ -2728,12 +2729,14 @@
   Uint8 TDirtyFlag          = tcKeyReq->getDirtyFlag(Treqinfo);
   Uint8 TInterpretedFlag    = tcKeyReq->getInterpretedFlag(Treqinfo);
   Uint8 TDistrKeyFlag       = tcKeyReq->getDistributionKeyFlag(Treqinfo);
+  Uint8 TNoDiskFlag         = TcKeyReq::getNoDiskFlag(Treqinfo);
   Uint8 TexecuteFlag        = TexecFlag;
   
   regCachePtr->opSimple = TSimpleFlag;
   regCachePtr->opExec   = TInterpretedFlag;
   regTcPtr->dirtyOp  = TDirtyFlag;
   regCachePtr->distributionKeyIndicator = TDistrKeyFlag;
+  regCachePtr->m_no_disk_flag = TNoDiskFlag;
 
   //-------------------------------------------------------------
   // The next step is to read the upto three conditional words.
@@ -3198,6 +3201,8 @@
   LqhKeyReq::setInterpretedFlag(Tdata10, regCachePtr->opExec);
   LqhKeyReq::setSimpleFlag(Tdata10, regCachePtr->opSimple);
   LqhKeyReq::setOperation(Tdata10, regTcPtr->operation);
+  LqhKeyReq::setNoDiskFlag(Tdata10, regCachePtr->m_no_disk_flag);
+
   /* ----------------------------------------------------------------------- 
    * Sequential Number of first LQH = 0, bit 22-23                           
    * IF ATTRIBUTE INFORMATION IS SENT IN TCKEYREQ,
@@ -3910,7 +3915,7 @@
   const UintR TopWords = (UintR)regApiPtr->tckeyrec;
   localHostptr.i = refToNode(regApiPtr->ndbapiBlockref);
   const Uint32 type = getNodeInfo(localHostptr.i).m_type;
-  const bool is_api = (type >= NodeInfo::API && type <= NodeInfo::REP);
+  const bool is_api = (type >= NodeInfo::API && type <= NodeInfo::MGM);
   const BlockNumber TblockNum = refToBlock(regApiPtr->ndbapiBlockref);
   const Uint32 Tmarker = (regApiPtr->commitAckMarker == RNIL) ? 0 : 1;
   ptrAss(localHostptr, hostRecord);
@@ -4592,7 +4597,8 @@
     commitConf->transId1 = regApiPtr->transid[0];
     commitConf->transId2 = regApiPtr->transid[1];
     commitConf->gci = regApiPtr->globalcheckpointid;
-    sendSignal(regApiPtr->ndbapiBlockref, GSN_TC_COMMITCONF, signal, 
+
+    sendSignal(regApiPtr->ndbapiBlockref, GSN_TC_COMMITCONF, signal,
 	       TcCommitConf::SignalLength, JBB);
   } else if (regApiPtr->returnsignal == RS_NO_RETURN) {
     jam();
@@ -5130,6 +5136,19 @@
 	return;
       }
       
+      /* Only ref in certain situations */
+      {
+	const Uint32 opType = regTcPtr->operation;
+	if (   (opType == ZDELETE && errCode != ZNOT_FOUND)
+	    || (opType == ZINSERT && errCode != ZALREADYEXIST)
+	    || (opType == ZUPDATE && errCode != ZNOT_FOUND)
+	    || (opType == ZWRITE  && errCode != 839 && errCode != 840))
+	{
+	  TCKEY_abort(signal, 49);
+	  return;
+	}
+      }
+
       /* *************** */
       /*    TCKEYREF   < */
       /* *************** */
@@ -8748,6 +8767,7 @@
   ScanFragReq::setDescendingFlag(tmp, ScanTabReq::getDescendingFlag(ri));
   ScanFragReq::setTupScanFlag(tmp, ScanTabReq::getTupScanFlag(ri));
   ScanFragReq::setAttrLen(tmp, scanTabReq->attrLenKeyLen & 0xFFFF);
+  ScanFragReq::setNoDiskFlag(tmp, ScanTabReq::getNoDiskFlag(ri));
   
   scanptr.p->scanRequestInfo = tmp;
   scanptr.p->scanStoredProcId = scanTabReq->storedProcId;
@@ -10105,6 +10125,7 @@
     tabptr.p->noOfKeyAttr = 0;
     tabptr.p->hasCharAttr = 0;
     tabptr.p->noOfDistrKeys = 0;
+    tabptr.p->hasVarKeys = 0;
   }//for
 }//Dbtc::initTable()
 
@@ -11139,7 +11160,6 @@
   ApiConnectRecordPtr transPtr;
   TcConnectRecord *localTcConnectRecord = tcConnectRecord;
   TcConnectRecordPtr opPtr;
-
   /**
    * TODO
    * Check transid,
@@ -11153,6 +11173,7 @@
     
     c_firedTriggerHash.remove(trigPtr);
 
+    trigPtr.p->fragId= fireOrd->fragId;
     bool ok = trigPtr.p->keyValues.getSize() == fireOrd->m_noPrimKeyWords;
     ok &= trigPtr.p->afterValues.getSize() == fireOrd->m_noAfterValueWords;
     ok &= trigPtr.p->beforeValues.getSize() == fireOrd->m_noBeforeValueWords;
@@ -11364,7 +11385,7 @@
   const UintR TopWords = (UintR)regApiPtr->tcindxrec;
   localHostptr.i = refToNode(regApiPtr->ndbapiBlockref);
   const Uint32 type = getNodeInfo(localHostptr.i).m_type;
-  const bool is_api = (type >= NodeInfo::API && type <= NodeInfo::REP);
+  const bool is_api = (type >= NodeInfo::API && type <= NodeInfo::MGM);
   const BlockNumber TblockNum = refToBlock(regApiPtr->ndbapiBlockref);
   const Uint32 Tmarker = (regApiPtr->commitAckMarker == RNIL ? 0 : 1);
   ptrAss(localHostptr, hostRecord);
@@ -12052,7 +12073,11 @@
   Uint32 dataPos = 0;
   TcKeyReq * const tcIndxReq = &indexOp->tcIndxReq;
   TcKeyReq * const tcKeyReq = (TcKeyReq *)signal->getDataPtrSend();
-  Uint32 * dataPtr = &tcKeyReq->scanInfo;
+  /*
+    Data points to distrGroupHashValue since scanInfo is used to send
+    fragment id of receiving fragment
+  */
+  Uint32 * dataPtr = &tcKeyReq->distrGroupHashValue;
   Uint32 tcKeyLength = TcKeyReq::StaticLength;
   Uint32 tcKeyRequestInfo = tcIndxReq->requestInfo;
   TcIndexData* indexData;
@@ -12091,11 +12116,16 @@
   regApiPtr->executingIndexOp = indexOp->indexOpId;;
   regApiPtr->noIndexOp++; // Increase count
 
-  // Filter out AttributeHeader:s since this should not be in key
+  /*
+    Filter out AttributeHeader:s since this should not be in key.
+    Also filter out fragment id from primary key and handle that
+    separately by setting it as Distribution Key and set indicator.
+  */
+
   AttributeHeader* attrHeader = (AttributeHeader *) aiIter.data;
     
   Uint32 headerSize = attrHeader->getHeaderSize();
-  Uint32 keySize = attrHeader->getDataSize();
+  Uint32 keySize = attrHeader->getDataSize() - 1;
   TcKeyReq::setKeyLength(tcKeyRequestInfo, keySize);
   // Skip header
   if (headerSize == 1) {
@@ -12105,6 +12135,9 @@
     jam();
     moreKeyData = indexOp->transIdAI.next(aiIter, headerSize - 1);
   }//if
+  tcKeyReq->scanInfo = *aiIter.data; //Fragment Id
+  moreKeyData = indexOp->transIdAI.next(aiIter);
+  TcKeyReq::setDistributionKeyFlag(tcKeyRequestInfo, 1U);
   while(// If we have not read complete key
 	(keySize != 0) &&
 	(dataPos < keyBufSize)) {
@@ -12460,7 +12493,7 @@
   AttributeBuffer::DataBufferIterator iter;
   Uint32 attrId = 0;
   Uint32 keyLength = 0;
-  Uint32 totalPrimaryKeyLength = 0;
+  Uint32 totalPrimaryKeyLength = 1; // fragment length
   Uint32 hops;
 
   indexTabPtr.i = indexData->indexId;
@@ -12513,11 +12546,12 @@
     hops = attrHeader->getHeaderSize() + attrHeader->getDataSize();
     moreAttrData = keyValues.next(iter, hops);
   }
-  AttributeHeader pkAttrHeader(attrId, totalPrimaryKeyLength);
+  AttributeHeader pkAttrHeader(attrId, totalPrimaryKeyLength << 2);
+  Uint32 attributesLength = afterValues.getSize() + 
+    pkAttrHeader.getHeaderSize() + pkAttrHeader.getDataSize();
   
   TcKeyReq::setKeyLength(tcKeyRequestInfo, keyLength);
-  tcKeyReq->attrLen = afterValues.getSize() + 
-    pkAttrHeader.getHeaderSize() + pkAttrHeader.getDataSize();
+  tcKeyReq->attrLen = attributesLength;
   tcKeyReq->tableId = indexData->indexId;
   TcKeyReq::setOperationType(tcKeyRequestInfo, ZINSERT);
   TcKeyReq::setExecutingTrigger(tcKeyRequestInfo, true);
@@ -12567,8 +12601,11 @@
   }
 
   tcKeyLength += dataPos;
-  Uint32 attributesLength = afterValues.getSize() + 
-    pkAttrHeader.getHeaderSize() + pkAttrHeader.getDataSize();
+  /*
+    Size of attrinfo is unique index attributes one by one, header for each
+    of them (all contained in the afterValues data structure), plus a header,
+    the primary key (compacted) and the fragment id before the primary key
+  */
   if (attributesLength <= attrBufSize) {
     jam();
     // ATTRINFO fits in TCKEYREQ
@@ -12585,6 +12622,10 @@
     // as one attribute
     pkAttrHeader.insertHeader(dataPtr);
     dataPtr += pkAttrHeader.getHeaderSize();
+    /*
+      Insert fragment id before primary key as part of reference to tuple
+    */
+    *dataPtr++ = firedTriggerData->fragId;
     moreAttrData = keyValues.first(iter);
     while(moreAttrData) {
       jam();
@@ -12749,6 +12790,29 @@
     pkAttrHeader.insertHeader(dataPtr);
     dataPtr += pkAttrHeader.getHeaderSize();
     attrInfoPos += pkAttrHeader.getHeaderSize();
+    /*
+      Add fragment id before primary key
+      TODO: This code really needs to be made into a long signal
+      to remove this messy code.
+    */
+    if (attrInfoPos == AttrInfo::DataLength)
+    {
+      jam();
+      // Flush ATTRINFO
+#if INTERNAL_TRIGGER_TCKEYREQ_JBA
+      sendSignal(reference(), GSN_ATTRINFO, signal, 
+                 AttrInfo::HeaderLength + AttrInfo::DataLength, JBA);
+#else
+      EXECUTE_DIRECT(DBTC, GSN_ATTRINFO, signal,
+                     AttrInfo::HeaderLength + AttrInfo::DataLength);
+      jamEntry();
+#endif
+      dataPtr = (Uint32 *) &attrInfo->attrData;	  
+      attrInfoPos = 0;
+    }
+    attrInfoPos++;
+    *dataPtr++ = firedTriggerData->fragId;
+
     moreAttrData = keyValues.first(iter);
     while(moreAttrData) {
       jam();

--- 1.30.4.1/innobase/btr/btr0sea.c	2005-12-13 21:35:14 +03:00
+++ 1.36/storage/innobase/btr/btr0sea.c	2005-12-13 23:56:11 +03:00
@@ -889,8 +889,7 @@
 void
 btr_search_drop_page_hash_index(
 /*============================*/
-	page_t*	page)	/* in: index page, s- or x-latched, or an index page
-			for which we know that block->buf_fix_count == 0 */
+	page_t*	page)	/* in: index page, s- or x-latched */
 {
 	hash_table_t*	table;
 	buf_block_t*	block;
@@ -905,7 +904,6 @@
 	ulint*		folds;
 	ulint		i;
 	mem_heap_t*	heap;
-	dict_index_t*	index;
 	ulint*		offsets;
 
 #ifdef UNIV_SYNC_DEBUG
@@ -934,16 +932,11 @@
 
 	n_fields = block->curr_n_fields;
 	n_bytes = block->curr_n_bytes;
-	index = block->index;
 
-	/* NOTE: The fields of block must not be accessed after
-	releasing btr_search_latch, as the index page might only
-	be s-latched! */
+	ut_a(n_fields + n_bytes > 0);
 
 	rw_lock_s_unlock(&btr_search_latch);
 	
-	ut_a(n_fields + n_bytes > 0);
-
 	n_recs = page_get_n_recs(page);
 
 	/* Calculate and cache fold values into an array for fast deletion
@@ -956,6 +949,14 @@
 	rec = page_get_infimum_rec(page);
 	rec = page_rec_get_next(rec);
 
+	if (!page_rec_is_supremum(rec)) {
+		ut_a(n_fields <= rec_get_n_fields(rec, block->index));
+
+		if (n_bytes > 0) {
+			ut_a(n_fields < rec_get_n_fields(rec, block->index));
+		}
+	}
+
 	tree_id = btr_page_get_index_id(page);
 	
 	prev_fold = 0;
@@ -963,12 +964,18 @@
 	heap = NULL;
 	offsets = NULL;
 
+	if (block->index == NULL) {
+
+		mem_analyze_corruption((byte*)block);
+
+		ut_a(block->index != NULL);
+	}
+
 	while (!page_rec_is_supremum(rec)) {
 		/* FIXME: in a mixed tree, not all records may have enough
 		ordering fields: */
-		offsets = rec_get_offsets(rec, index, offsets,
-					n_fields + (n_bytes > 0), &heap);
-		ut_a(rec_offs_n_fields(offsets) == n_fields + (n_bytes > 0));
+		offsets = rec_get_offsets(rec, block->index,
+				offsets, n_fields + (n_bytes > 0), &heap);
 		fold = rec_fold(rec, offsets, n_fields, n_bytes, tree_id);
 
 		if (fold == prev_fold && prev_fold != 0) {

--- 1.65.5.1/innobase/dict/dict0dict.c	2005-12-13 16:12:46 +03:00
+++ 1.72/storage/innobase/dict/dict0dict.c	2005-12-13 23:56:11 +03:00
@@ -2104,11 +2104,8 @@
 	dict_table_t*	table,	/* in: table */
 	const char**	columns,/* in: array of column names */
 	ulint		n_cols,	/* in: number of columns */
-	dict_index_t*	types_idx, /* in: NULL or an index to whose types the
-				   column types must match */
-	ibool		check_charsets)	/* in: whether to check charsets.
-					only has an effect if types_idx !=
-					NULL. */
+	dict_index_t*	types_idx)/* in: NULL or an index to whose types the
+				column types must match */
 {
 #ifndef UNIV_HOTBACKUP
 	dict_index_t*	index;
@@ -2138,8 +2135,7 @@
 
 				if (types_idx && !cmp_types_are_equal(
 				     dict_index_get_nth_type(index, i),
-				     dict_index_get_nth_type(types_idx, i),
-				     check_charsets)) {
+				     dict_index_get_nth_type(types_idx, i))) {
 
 				  	break;
 				}		
@@ -2216,8 +2212,7 @@
 /*======================*/
 					/* out: DB_SUCCESS or error code */
 	dict_foreign_t*	foreign,	/* in, own: foreign key constraint */
-	ibool		check_charsets)	/* in: TRUE=check charset
-					compatibility */
+	ibool		check_types)	/* in: TRUE=check type compatibility */
 {
 	dict_table_t*	for_table;
 	dict_table_t*	ref_table;
@@ -2253,10 +2248,16 @@
 	}
 
 	if (for_in_cache->referenced_table == NULL && ref_table) {
+		dict_index_t*	types_idx;
+		if (check_types) {
+			types_idx = for_in_cache->foreign_index;
+		} else {
+			types_idx = NULL;
+		}
 		index = dict_foreign_find_index(ref_table,
 			(const char**) for_in_cache->referenced_col_names,
 			for_in_cache->n_fields,
-			for_in_cache->foreign_index, check_charsets);
+			types_idx);
 
 		if (index == NULL) {
 			dict_foreign_error_report(ef, for_in_cache,
@@ -2280,10 +2281,16 @@
 	}
 
 	if (for_in_cache->foreign_table == NULL && for_table) {
+		dict_index_t*	types_idx;
+		if (check_types) {
+			types_idx = for_in_cache->referenced_index;
+		} else {
+			types_idx = NULL;
+		}
 		index = dict_foreign_find_index(for_table,
 			(const char**) for_in_cache->foreign_col_names,
 			for_in_cache->n_fields,
-			for_in_cache->referenced_index, check_charsets);
+			types_idx);
 
 		if (index == NULL) {
 			dict_foreign_error_report(ef, for_in_cache,
@@ -3090,7 +3097,7 @@
 	/* Try to find an index which contains the columns
 	as the first fields and in the right order */
 
-	index = dict_foreign_find_index(table, column_names, i, NULL, TRUE);
+	index = dict_foreign_find_index(table, column_names, i, NULL);
 
 	if (!index) {
 		mutex_enter(&dict_foreign_err_mutex);
@@ -3355,7 +3362,8 @@
 
 	if (referenced_table) {
 		index = dict_foreign_find_index(referenced_table,
-			column_names, i, foreign->foreign_index, TRUE);
+						column_names, i,
+						foreign->foreign_index);
 		if (!index) {
 			dict_foreign_free(foreign);
 			mutex_enter(&dict_foreign_err_mutex);

--- 1.37.3.1/innobase/dict/dict0load.c	2005-12-13 16:29:23 +03:00
+++ 1.42/storage/innobase/dict/dict0load.c	2005-12-13 23:56:11 +03:00
@@ -1091,7 +1091,7 @@
 				/* out: DB_SUCCESS or error code */
 	const char*	id,	/* in: foreign constraint id as a
 				null-terminated string */
-	ibool		check_charsets)/* in: TRUE=check charset compatibility */
+	ibool		check_types)/* in: TRUE=check type compatibility */
 {	
 	dict_foreign_t*	foreign;
 	dict_table_t*	sys_foreign;
@@ -1204,7 +1204,7 @@
 	a new foreign key constraint but loading one from the data
 	dictionary. */
 
-	return(dict_foreign_add_to_cache(foreign, check_charsets));
+	return(dict_foreign_add_to_cache(foreign, check_types));
 }
 
 /***************************************************************************
@@ -1219,8 +1219,7 @@
 /*===============*/
 					/* out: DB_SUCCESS or error code */
 	const char*	table_name,	/* in: table name */
-	ibool		check_charsets)	/* in: TRUE=check charset
-					compatibility */
+	ibool		check_types)	/* in: TRUE=check type compatibility */
 {
 	btr_pcur_t	pcur;
 	mem_heap_t* 	heap;
@@ -1320,7 +1319,7 @@
 
 	/* Load the foreign constraint definition to the dictionary cache */
 	
-	err = dict_load_foreign(id, check_charsets);
+	err = dict_load_foreign(id, check_types);
 
 	if (err != DB_SUCCESS) {
 		btr_pcur_close(&pcur);

--- 1.28.3.1/innobase/include/buf0buf.h	2005-12-13 21:35:14 +03:00
+++ 1.33/storage/innobase/include/buf0buf.h	2005-12-13 23:56:11 +03:00
@@ -745,6 +745,8 @@
 					buffer pool which are index pages,
 					but this flag is not set because
 					we do not keep track of all pages */
+	dict_index_t*	index;		/* index for which the adaptive
+					hash index has been created */
 	/* 2. Page flushing fields */
 
 	UT_LIST_NODE_T(buf_block_t) flush_list;
@@ -831,13 +833,7 @@
 					records with the same prefix should be
 					indexed in the hash index */
 					
-	/* These 6 fields may only be modified when we have
-	an x-latch on btr_search_latch AND
-	a) we are holding an s-latch or x-latch on block->lock or
-	b) we know that block->buf_fix_count == 0.
-
-	An exception to this is when we init or create a page
-	in the buffer pool in buf0buf.c. */
+	/* The following 4 fields are protected by btr_search_latch: */
 
 	ibool		is_hashed;	/* TRUE if hash index has already been
 					built on this page; note that it does
@@ -854,8 +850,6 @@
 	ulint		curr_side;	/* BTR_SEARCH_LEFT_SIDE or
 					BTR_SEARCH_RIGHT_SIDE in hash
 					indexing */
-	dict_index_t*	index;		/* Index for which the adaptive
-					hash index has been created. */
 	/* 6. Debug fields */
 #ifdef UNIV_SYNC_DEBUG
 	rw_lock_t	debug_latch;	/* in the debug version, each thread

--- 1.31.6.1/innobase/include/dict0dict.h	2005-12-13 16:12:46 +03:00
+++ 1.39/storage/innobase/include/dict0dict.h	2005-12-13 23:56:11 +03:00
@@ -197,8 +197,7 @@
 /*======================*/
 					/* out: DB_SUCCESS or error code */
 	dict_foreign_t*	foreign,	/* in, own: foreign key constraint */
-	ibool		check_charsets);/* in: TRUE=check charset
-					compatibility */
+	ibool		check_types);	/* in: TRUE=check type compatibility */
 /*************************************************************************
 Checks if a table is referenced by foreign keys. */
 

--- 1.5.4.1/innobase/include/dict0load.h	2005-12-13 16:11:27 +03:00
+++ 1.10/storage/innobase/include/dict0load.h	2005-12-13 23:56:11 +03:00
@@ -82,8 +82,7 @@
 /*===============*/
 					/* out: DB_SUCCESS or error code */
 	const char*	table_name,	/* in: table name */
-	ibool		check_charsets);/* in: TRUE=check charsets
-					compatibility */
+	ibool		check_types);	/* in: TRUE=check type compatibility */
 /************************************************************************
 Prints to the standard output information on all tables found in the data
 dictionary system table. */

--- 1.34.5.2/innobase/include/os0file.h	2005-12-13 21:35:14 +03:00
+++ 1.41/storage/innobase/include/os0file.h	2005-12-13 23:56:11 +03:00
@@ -187,7 +187,7 @@
 FILE*
 os_file_create_tmpfile(void);
 /*========================*/
-			/* out: temporary file handle, or NULL on error */
+			/* out: temporary file handle (never NULL) */
 /***************************************************************************
 The os_file_opendir() function opens a directory stream corresponding to the
 directory named by the dirname argument. The directory stream is positioned

--- 1.6.2.1/innobase/include/rem0cmp.h	2005-12-13 16:12:46 +03:00
+++ 1.10/storage/innobase/include/rem0cmp.h	2005-12-13 23:56:11 +03:00
@@ -24,8 +24,7 @@
 				/* out: TRUE if the types are considered
 				equal in comparisons */
 	dtype_t*	type1,	/* in: type 1 */
-	dtype_t*	type2,	/* in: type 2 */
-	ibool		check_charsets); /* in: whether to check charsets */
+	dtype_t*	type2);	/* in: type 2 */
 /*****************************************************************
 This function is used to compare two data fields for which we know the
 data type. */

--- 1.51.5.2/innobase/include/srv0srv.h	2005-12-13 21:35:14 +03:00
+++ 1.57/storage/innobase/include/srv0srv.h	2005-12-13 23:56:11 +03:00
@@ -34,18 +34,6 @@
 extern mutex_t	srv_monitor_file_mutex;
 /* Temporary file for innodb monitor output */
 extern FILE*	srv_monitor_file;
-/* Mutex for locking srv_dict_tmpfile.
-This mutex has a very high rank; threads reserving it should not
-be holding any InnoDB latches. */
-extern mutex_t	srv_dict_tmpfile_mutex;
-/* Temporary file for output from the data dictionary */
-extern FILE*	srv_dict_tmpfile;
-/* Mutex for locking srv_misc_tmpfile.
-This mutex has a very low rank; threads reserving it should not
-acquire any further latches or sleep before releasing this one. */
-extern mutex_t	srv_misc_tmpfile_mutex;
-/* Temporary file for miscellanous diagnostic output */
-extern FILE*	srv_misc_tmpfile;
 
 /* Server parameters which are read from the initfile */
 

--- 1.25.3.1/innobase/rem/rem0cmp.c	2005-12-13 16:12:46 +03:00
+++ 1.30/storage/innobase/rem/rem0cmp.c	2005-12-13 23:56:11 +03:00
@@ -99,8 +99,7 @@
 				/* out: TRUE if the types are considered
 				equal in comparisons */
 	dtype_t*	type1,	/* in: type 1 */
-	dtype_t*	type2,	/* in: type 2 */
-	ibool		check_charsets) /* in: whether to check charsets */
+	dtype_t*	type2)	/* in: type 2 */
 {
 	if (dtype_is_non_binary_string_type(type1->mtype, type1->prtype)
 	    && dtype_is_non_binary_string_type(type2->mtype, type2->prtype)) {
@@ -108,12 +107,12 @@
 		/* Both are non-binary string types: they can be compared if
 		and only if the charset-collation is the same */
 
-		if (check_charsets) {
-			return(dtype_get_charset_coll(type1->prtype)
-			    == dtype_get_charset_coll(type2->prtype));
-		} else {
+		if (dtype_get_charset_coll(type1->prtype)
+				== dtype_get_charset_coll(type2->prtype)) {
 			return(TRUE);
 		}
+
+		return(FALSE);
         }
 
 	if (dtype_is_binary_string_type(type1->mtype, type1->prtype)

--- 1.65.8.2/innobase/row/row0ins.c	2005-12-13 21:35:14 +03:00
+++ 1.73/storage/innobase/row/row0ins.c	2005-12-13 23:56:11 +03:00
@@ -588,21 +588,20 @@
 	trx_t*		trx,		/* in: transaction */
 	dict_foreign_t*	foreign)	/* in: foreign key constraint */
 {
-	mutex_enter(&srv_misc_tmpfile_mutex);
-	rewind(srv_misc_tmpfile);
+		
+	FILE*	tf = os_file_create_tmpfile();
 
-	if (os_file_set_eof(srv_misc_tmpfile)) {
-		ut_print_name(srv_misc_tmpfile, trx,
-				foreign->foreign_table_name);
-		dict_print_info_on_foreign_key_in_create_format(
-				srv_misc_tmpfile,
-				trx, foreign, FALSE);
-		trx_set_detailed_error_from_file(trx, srv_misc_tmpfile);
+	if (tf) {
+		ut_print_name(tf, trx, foreign->foreign_table_name);
+		dict_print_info_on_foreign_key_in_create_format(tf, trx,
+			foreign, FALSE);
+
+		trx_set_detailed_error_from_file(trx, tf);
+
+		fclose(tf);
 	} else {
-		trx_set_detailed_error(trx, "temp file operation failed");
+		trx_set_detailed_error(trx, "temp file creation failed");
 	}
-
-	mutex_exit(&srv_misc_tmpfile_mutex);
 }
 
 /*************************************************************************
@@ -710,7 +709,7 @@
 	}
 
 	if (rec) {
-		rec_print(ef, rec, foreign->referenced_index);
+		rec_print(ef, rec, foreign->foreign_index);
 	}
 	putc('\n', ef);
 

--- 1.103.10.1/innobase/row/row0mysql.c	2005-12-13 16:12:46 +03:00
+++ 1.115/storage/innobase/row/row0mysql.c	2005-12-13 23:56:11 +03:00
@@ -2132,7 +2132,7 @@
 
 	if (err == DB_SUCCESS) {
 		/* Check that also referencing constraints are ok */
-		err = dict_load_foreigns(name, TRUE);
+		err = dict_load_foreigns(name, trx->check_foreigns);
 	}
 
 	if (err != DB_SUCCESS) {
@@ -3590,8 +3590,7 @@
 	mem_heap_t*	heap			= NULL;
 	const char**	constraints_to_drop	= NULL;
 	ulint		n_constraints_to_drop	= 0;
-	ibool           recovering_temp_table   = FALSE;
-	ibool		old_is_tmp, new_is_tmp;
+        ibool           recovering_temp_table   = FALSE;
 	ulint		len;
 	ulint		i;
         ibool		success;
@@ -3631,9 +3630,6 @@
 	trx->op_info = "renaming table";
 	trx_start_if_not_started(trx);
 
-	old_is_tmp = row_is_mysql_tmp_table_name(old_name);
-	new_is_tmp = row_is_mysql_tmp_table_name(new_name);
-	
 	if (row_mysql_is_recovered_tmp_table(new_name)) {
 
                 recovering_temp_table = TRUE;
@@ -3680,7 +3676,7 @@
 	len = (sizeof str1) + (sizeof str2) + (sizeof str3) + (sizeof str5) - 4
 		+ ut_strlenq(new_name, '\'') + ut_strlenq(old_name, '\'');
 
-	if (new_is_tmp) {
+	if (row_is_mysql_tmp_table_name(new_name)) {
 		db_name_len = dict_get_db_name_len(old_name) + 1;
 
 		/* MySQL is doing an ALTER TABLE command and it renames the
@@ -3833,7 +3829,7 @@
 		the table is stored in a single-table tablespace */
 
 		success = dict_table_rename_in_cache(table, new_name,
-				!new_is_tmp);
+				!row_is_mysql_tmp_table_name(new_name));
 		if (!success) {
 			trx->error_state = DB_SUCCESS;
 			trx_general_rollback_for_mysql(trx, FALSE, NULL);
@@ -3850,16 +3846,19 @@
 			goto funct_exit;
 		}
 
-		/* We only want to switch off some of the type checking in
-		an ALTER, not in a RENAME. */
-		
-		err = dict_load_foreigns(new_name,
-			old_is_tmp ? trx->check_foreigns : TRUE);
+		err = dict_load_foreigns(new_name, trx->check_foreigns);
 
-		if (err != DB_SUCCESS) {
-			ut_print_timestamp(stderr);
+		if (row_is_mysql_tmp_table_name(old_name)) {
+
+			/* MySQL is doing an ALTER TABLE command and it
+			renames the created temporary table to the name
+			of the original table. In the ALTER TABLE we maybe
+			created some FOREIGN KEY constraints for the temporary
+			table. But we want to load also the foreign key
+			constraint definitions for the original table name. */
 
-			if (old_is_tmp) {
+			if (err != DB_SUCCESS) {
+	    			ut_print_timestamp(stderr);
 				fputs("  InnoDB: Error: in ALTER TABLE ",
 					stderr);
 				ut_print_name(stderr, trx, new_name);
@@ -3867,23 +3866,36 @@
 	"InnoDB: has or is referenced in foreign key constraints\n"
 	"InnoDB: which are not compatible with the new table definition.\n",
 					stderr);
-			} else {
+
+				ut_a(dict_table_rename_in_cache(table,
+					old_name, FALSE));
+				trx->error_state = DB_SUCCESS;
+				trx_general_rollback_for_mysql(trx, FALSE,
+									NULL);
+				trx->error_state = DB_SUCCESS;
+			}
+		} else {
+			if (err != DB_SUCCESS) {
+
+	    			ut_print_timestamp(stderr);
+
 				fputs(
 				"  InnoDB: Error: in RENAME TABLE table ",
 					stderr);
 				ut_print_name(stderr, trx, new_name);
 				fputs("\n"
-	"InnoDB: is referenced in foreign key constraints\n"
-	"InnoDB: which are not compatible with the new table definition.\n",
+     "InnoDB: is referenced in foreign key constraints\n"
+     "InnoDB: which are not compatible with the new table definition.\n",
 					stderr);
-			}
-
-			ut_a(dict_table_rename_in_cache(table,
+     
+				ut_a(dict_table_rename_in_cache(table,
 					old_name, FALSE));
-			trx->error_state = DB_SUCCESS;
-			trx_general_rollback_for_mysql(trx, FALSE,
-				NULL);
-			trx->error_state = DB_SUCCESS;
+						
+				trx->error_state = DB_SUCCESS;
+				trx_general_rollback_for_mysql(trx, FALSE,
+									NULL);
+				trx->error_state = DB_SUCCESS;
+			}
 		}
 	}
 funct_exit:	

--- 1.87.7.2/innobase/srv/srv0srv.c	2005-12-13 21:35:14 +03:00
+++ 1.94/storage/innobase/srv/srv0srv.c	2005-12-13 23:56:11 +03:00
@@ -397,18 +397,6 @@
 mutex_t	srv_monitor_file_mutex;
 /* Temporary file for innodb monitor output */
 FILE*	srv_monitor_file;
-/* Mutex for locking srv_dict_tmpfile.
-This mutex has a very high rank; threads reserving it should not
-be holding any InnoDB latches. */
-mutex_t	srv_dict_tmpfile_mutex;
-/* Temporary file for output from the data dictionary */
-FILE*	srv_dict_tmpfile;
-/* Mutex for locking srv_misc_tmpfile.
-This mutex has a very low rank; threads reserving it should not
-acquire any further latches or sleep before releasing this one. */
-mutex_t	srv_misc_tmpfile_mutex;
-/* Temporary file for miscellanous diagnostic output */
-FILE*	srv_misc_tmpfile;
 
 ulint	srv_main_thread_process_no	= 0;
 ulint	srv_main_thread_id		= 0;

--- 1.80.7.2/innobase/srv/srv0start.c	2005-12-13 21:35:14 +03:00
+++ 1.88/storage/innobase/srv/srv0start.c	2005-12-13 23:56:11 +03:00
@@ -1180,20 +1180,6 @@
 		}
 	}
 
-	mutex_create(&srv_dict_tmpfile_mutex);
-	mutex_set_level(&srv_dict_tmpfile_mutex, SYNC_DICT_OPERATION);
-	srv_dict_tmpfile = os_file_create_tmpfile();
-	if (!srv_dict_tmpfile) {
-		return(DB_ERROR);
-	}
-
-	mutex_create(&srv_misc_tmpfile_mutex);
-	mutex_set_level(&srv_misc_tmpfile_mutex, SYNC_ANY_LATCH);
-	srv_misc_tmpfile = os_file_create_tmpfile();
-	if (!srv_misc_tmpfile) {
-		return(DB_ERROR);
-	}
-
 	/* Restrict the maximum number of file i/o threads */
 	if (srv_n_file_io_threads > SRV_MAX_N_IO_THREADS) {
 
@@ -1836,19 +1822,8 @@
 			mem_free(srv_monitor_file_name);
 		}
 	}
-	if (srv_dict_tmpfile) {
-		fclose(srv_dict_tmpfile);
-		srv_dict_tmpfile = 0;
-	}
-
-	if (srv_misc_tmpfile) {
-		fclose(srv_misc_tmpfile);
-		srv_misc_tmpfile = 0;
-	}
-
+	
 	mutex_free(&srv_monitor_file_mutex);
-	mutex_free(&srv_dict_tmpfile_mutex);
-	mutex_free(&srv_misc_tmpfile_mutex);
 
 	/* 3. Free all InnoDB's own mutexes and the os_fast_mutexes inside
 	them */
Thread
bk commit into 5.1 tree (aivanov:1.1962)Alex Ivanov13 Dec