List:Commits« Previous MessageNext Message »
From:lzhou Date:September 3 2007 5:02pm
Subject:bk commit into 5.1 tree (lzhou:1.2491)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of zhl. When zhl 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@stripped, 2007-09-03 17:02:11+00:00, lzhou@dev3-63.(none) +35 -0
  TMP 26498 implement "start backup n" and abort backup when backup files exist

  storage/ndb/include/kernel/GlobalSignalNumbers.h@stripped, 2007-09-03 17:02:02+00:00, lzhou@dev3-63.(none) +3 -3
    Add 3 signal for get file status

  storage/ndb/include/kernel/ndb_limits.h@stripped, 2007-09-03 17:02:02+00:00, lzhou@dev3-63.(none) +1 -0
    Add max bakup number

  storage/ndb/include/kernel/signaldata/BackupImpl.hpp@stripped, 2007-09-03 17:02:02+00:00, lzhou@dev3-63.(none) +2 -1
    Add one kind of error number

  storage/ndb/include/kernel/signaldata/BackupSignalData.hpp@stripped, 2007-09-03 17:02:02+00:00, lzhou@dev3-63.(none) +2 -1
    Add backupId in BackupReq signal

  storage/ndb/include/kernel/signaldata/FsConf.hpp@stripped, 2007-09-03 17:02:02+00:00, lzhou@dev3-63.(none) +1 -1
    Add comment in FsConf for new signal

  storage/ndb/include/kernel/signaldata/FsRef.hpp@stripped, 2007-09-03 17:02:02+00:00, lzhou@dev3-63.(none) +1 -1
    Add comment for new signal

  storage/ndb/include/kernel/signaldata/FsStatReq.hpp@stripped, 2007-09-03 17:02:05+00:00, lzhou@dev3-63.(none) +125 -0
    New file to define FSSTAT structure

  storage/ndb/include/kernel/signaldata/FsStatReq.hpp@stripped, 2007-09-03 17:02:05+00:00, lzhou@dev3-63.(none) +0 -0

  storage/ndb/include/kernel/signaldata/SignalData.hpp@stripped, 2007-09-03 17:02:02+00:00, lzhou@dev3-63.(none) +3 -0
    Add three item for the 3 new signals

  storage/ndb/include/kernel/signaldata/UtilSequence.hpp@stripped, 2007-09-03 17:02:02+00:00, lzhou@dev3-63.(none) +4 -2
    Add SetVal type for set user define backup id

  storage/ndb/include/mgmapi/mgmapi.h@stripped, 2007-09-03 17:02:02+00:00, lzhou@dev3-63.(none) +3 -1
    Add new function declaration 

  storage/ndb/src/common/debugger/signaldata/FsStatReq.cpp@stripped, 2007-09-03 17:02:04+00:00, lzhou@dev3-63.(none) +33 -0
    New file to implement printFSSTATREQ

  storage/ndb/src/common/debugger/signaldata/FsStatReq.cpp@stripped, 2007-09-03 17:02:04+00:00, lzhou@dev3-63.(none) +0 -0

  storage/ndb/src/common/debugger/signaldata/Makefile.am@stripped, 2007-09-03 17:02:02+00:00, lzhou@dev3-63.(none) +1 -1
    Add new FsStatReq.cpp file

  storage/ndb/src/common/debugger/signaldata/SignalDataPrint.cpp@stripped, 2007-09-03 17:02:03+00:00, lzhou@dev3-63.(none) +3 -0
    Add three item for new signals

  storage/ndb/src/common/debugger/signaldata/SignalNames.cpp@stripped, 2007-09-03 17:02:03+00:00, lzhou@dev3-63.(none) +3 -0
    Add three sinal names

  storage/ndb/src/common/debugger/signaldata/UtilSequence.cpp@stripped, 2007-09-03 17:02:03+00:00, lzhou@dev3-63.(none) +2 -0
    Set name of sequence type

  storage/ndb/src/kernel/blocks/backup/Backup.cpp@stripped, 2007-09-03 17:02:03+00:00, lzhou@dev3-63.(none) +163 -3
    Set new sequence id if user set backup id

  storage/ndb/src/kernel/blocks/backup/Backup.hpp@stripped, 2007-09-03 17:02:03+00:00, lzhou@dev3-63.(none) +7 -0
    Add function declaration

  storage/ndb/src/kernel/blocks/backup/BackupInit.cpp@stripped, 2007-09-03 17:02:03+00:00, lzhou@dev3-63.(none) +2 -0
    Regist signal and signal function

  storage/ndb/src/kernel/blocks/dbutil/DbUtil.cpp@stripped, 2007-09-03 17:02:03+00:00, lzhou@dev3-63.(none) +53 -1
    Get backup files' status before execute backup

  storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp@stripped, 2007-09-03 17:02:03+00:00, lzhou@dev3-63.(none) +14 -0
    Add new function to deal with file status

  storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp@stripped, 2007-09-03 17:02:03+00:00, lzhou@dev3-63.(none) +2 -0
    Add new function declaration and new type of action

  storage/ndb/src/kernel/blocks/ndbfs/Filename.cpp@stripped, 2007-09-03 17:02:03+00:00, lzhou@dev3-63.(none) +1 -0
    Include new signal defination

  storage/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp@stripped, 2007-09-03 17:02:03+00:00, lzhou@dev3-63.(none) +47 -0
    Add new fucntion to get file status

  storage/ndb/src/kernel/blocks/ndbfs/Ndbfs.hpp@stripped, 2007-09-03 17:02:03+00:00, lzhou@dev3-63.(none) +1 -0
    Add new function declaration

  storage/ndb/src/kernel/vm/SimulatedBlock.cpp@stripped, 2007-09-03 17:02:04+00:00, lzhou@dev3-63.(none) +7 -0
    Add new signal's handle function

  storage/ndb/src/kernel/vm/SimulatedBlock.hpp@stripped, 2007-09-03 17:02:04+00:00, lzhou@dev3-63.(none) +1 -0
    Add new function declaration 

  storage/ndb/src/mgmapi/mgmapi.cpp@stripped, 2007-09-03 17:02:04+00:00, lzhou@dev3-63.(none) +4 -1
    Add new function to deal with user input backup id

  storage/ndb/src/mgmclient/CommandInterpreter.cpp@stripped, 2007-09-03 17:02:04+00:00, lzhou@dev3-63.(none) +96 -4
    Check bakcupid

  storage/ndb/src/mgmsrv/MgmtSrvr.cpp@stripped, 2007-09-03 17:02:04+00:00, lzhou@dev3-63.(none) +3 -1
    Deal with new bakcup id

  storage/ndb/src/mgmsrv/MgmtSrvr.hpp@stripped, 2007-09-03 17:02:04+00:00, lzhou@dev3-63.(none) +1 -1
    Redeclare function

  storage/ndb/src/mgmsrv/Services.cpp@stripped, 2007-09-03 17:02:04+00:00, lzhou@dev3-63.(none) +9 -1
    Get backupid from arguments

  storage/ndb/src/ndbapi/ndberror.c@stripped, 2007-09-03 17:02:04+00:00, lzhou@dev3-63.(none) +1 -0
    Add new error message

  storage/ndb/test/include/NDBT_Test.hpp@stripped, 2007-09-03 17:02:04+00:00, lzhou@dev3-63.(none) +1 -0
    Add ndb limits head file

  storage/ndb/test/ndbapi/testBackup.cpp@stripped, 2007-09-03 17:02:04+00:00, lzhou@dev3-63.(none) +27 -0
    Add test case for backup n

  storage/ndb/test/src/NdbBackup.cpp@stripped, 2007-09-03 17:02:04+00:00, lzhou@dev3-63.(none) +2 -1
    add test case for backup file existing

# 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:	lzhou
# Host:	dev3-63.(none)
# Root:	/home/zhl/mysql/mysql-5.1/bug26498
--- New file ---
+++ storage/ndb/include/kernel/signaldata/FsStatReq.hpp	07/09/03 17:02:05
/* Copyright (C) 2003 MySQL AB

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; version 2 of the License.

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

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

#ifndef FS_STAT_REQ_H
#define FS_STAT_REQ_H

#include "SignalData.hpp"

/**
 * 
 * SENDER:  Backup
 * RECIVER: Ndbfs
 */
class FsStatReq {
  /**
   * Reciver(s)
   */
  friend class Ndbfs;         // Reciver

  /**
   * Sender(s)
   */
  friend class Backup;

  /**
   * For printing
   */
  friend bool printFSSTATREQ(FILE * output, const Uint32 * theData, Uint32 len, Uint16 receiverBlockNo);

public:
  /**
   * Length of signal
   */
  STATIC_CONST( SignalLength = 6 );
  SECTION( FILENAME = 0 );
  
private:

  /**
   * DATA VARIABLES
   */

  UintR userReference;        // DATA 0
  UintR userPointer;          // DATA 1
  UintR fileNumber[4];        // DATA 2 - 5

  enum Suffixes {
    S_DATA = 0,
    S_FRAGLOG = 1,
    S_LOGLOG = 2,
    S_FRAGLIST = 3,
    S_TABLELIST = 4,
    S_SCHEMALOG = 5,
    S_SYSFILE = 6,
    S_LOG = 7,
    S_CTL = 8
  };
  
  static void setVersion(Uint32 fileNumber[], Uint8 val);
  static void setSuffix(Uint32 fileNumber[], Uint8 val);
  
  /**
   * V2 - Backup
   */
  static void v2_setSequence(Uint32 fileNumber[], Uint32 no);
  static void v2_setNodeId(Uint32 fileNumber[], Uint32 no);
  static void v2_setCount(Uint32 fileNumber[], Uint32 no);

};

/**
 * -- v2 --
 * File number[0] = Backup Sequence Number
 * File number[1] = Node Id
 * File number[3] =
 *   v = version   24 - 31
 *   s = v1_suffix 16 - 23
 * 
 *           1111111111222222222233
 * 01234567890123456789012345678901
 *                 ssssssssvvvvvvvv
 */ 

inline
void FsStatReq::setVersion(Uint32 fileNumber[], Uint8 val){
  const Uint32 t = fileNumber[3];
  fileNumber[3] = t & 0x00FFFFFF | (((Uint32)val) << 24);
}

inline
void FsStatReq::setSuffix(Uint32 fileNumber[], Uint8 val){
  const Uint32 t = fileNumber[3];
  fileNumber[3] = t & 0xFF00FFFF | (((Uint32)val) << 16);
}

/****************/
inline
void FsStatReq::v2_setSequence(Uint32 fileNumber[], Uint32 val){
  fileNumber[0] = val;
}

inline
void FsStatReq::v2_setNodeId(Uint32 fileNumber[], Uint32 val){
  fileNumber[1] = val;
}

inline
void FsStatReq::v2_setCount(Uint32 fileNumber[], Uint32 val){
  fileNumber[2] = val;
}

#endif


--- New file ---
+++ storage/ndb/src/common/debugger/signaldata/FsStatReq.cpp	07/09/03 17:02:04
/* Copyright (C) 2003 MySQL AB

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; version 2 of the License.

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

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



#include <signaldata/FsStatReq.hpp>

bool 
printFSSTATREQ(FILE * output, const Uint32 * theData, Uint32 len, Uint16 receiverBlockNo){
  
  const FsStatReq * const sig = (FsStatReq *) theData;
  

  fprintf(output, " UserReference: H\'%.8x, userPointer: H\'%.8x\n", 
	  sig->userReference, sig->userPointer);
  fprintf(output, " FileNumber[1-4]: H\'%.8x H\'%.8x H\'%.8x H\'%.8x\n", 
	  sig->fileNumber[0], sig->fileNumber[1], sig->fileNumber[2], sig->fileNumber[3]);
  
  fprintf(output, "\n");
  return true;
}


--- 1.33/storage/ndb/include/kernel/GlobalSignalNumbers.h	2007-09-03 17:02:32 +00:00
+++ 1.34/storage/ndb/include/kernel/GlobalSignalNumbers.h	2007-09-03 17:02:32 +00:00
@@ -377,10 +377,10 @@ extern const GlobalSignalNumber NO_OF_SI
 #define GSN_GCP_SAVEREF                 282
 #define GSN_GCP_SAVEREQ                 283
 #define GSN_GCP_TCFINISHED              284
+#define GSN_FSSTATREQ                   285
+#define GSN_FSSTATREF                   286
+#define GSN_FSSTATCONF                  287
 
-/* 285 unused */
-/* 286 unused */
-/* 287 unused */
 #define GSN_GETGCICONF                  288
 #define GSN_GETGCIREQ                   289
 #define GSN_HOT_SPAREREP                290

--- 1.27/storage/ndb/include/kernel/ndb_limits.h	2007-09-03 17:02:32 +00:00
+++ 1.28/storage/ndb/include/kernel/ndb_limits.h	2007-09-03 17:02:32 +00:00
@@ -27,6 +27,7 @@
 #define MAX_NDB_NODES 49
 #define MAX_NODES     64
 #define UNDEF_NODEGROUP 0xFFFF
+#define MAX_BACKUPS   0xFFFFFFFF
 
 /**
  * MAX_API_NODES = MAX_NODES - No of NDB Nodes in use

--- 1.9/storage/ndb/include/kernel/signaldata/BackupImpl.hpp	2007-09-03 17:02:32 +00:00
+++ 1.10/storage/ndb/include/kernel/signaldata/BackupImpl.hpp	2007-09-03 17:02:32 +00:00
@@ -94,7 +94,8 @@ public:
     FailedInsertTableList = 1346,
     FailedAllocateTableMem = 1347,
     FailedToAllocateFileRecord = 1348,
-    FailedToAllocateAttributeRecord = 1349
+    FailedToAllocateAttributeRecord = 1349,
+    FailedForBackupFilesAleadyExist  = 1350
   };
 private:
   Uint32 backupId;

--- 1.7/storage/ndb/include/kernel/signaldata/BackupSignalData.hpp	2007-09-03 17:02:32 +00:00
+++ 1.8/storage/ndb/include/kernel/signaldata/BackupSignalData.hpp	2007-09-03 17:02:32 +00:00
@@ -35,7 +35,7 @@ class BackupReq {
 
   friend bool printBACKUP_REQ(FILE *, const Uint32 *, Uint32, Uint16);
 public:
-  STATIC_CONST( SignalLength = 3 );
+  STATIC_CONST( SignalLength = 4 );
 
 private:
   Uint32 senderData;
@@ -43,6 +43,7 @@ private:
   /* & 0x3 - waitCompleted
    */
   Uint32 flags;
+  Uint32 inputBackupId;
 };
 
 class BackupData {

--- 1.4/storage/ndb/include/kernel/signaldata/FsConf.hpp	2007-09-03 17:02:32 +00:00
+++ 1.5/storage/ndb/include/kernel/signaldata/FsConf.hpp	2007-09-03 17:02:32 +00:00
@@ -21,7 +21,7 @@
 /**
  * FsConf - Common signal class for all CONF signals sent from Ndbfs
  * GSN_FSCLOSECONF, GSN_FSOPENCONF, GSN_FSWRITECONF, GSN_FSREADCONF,
- * GSN_FSSYNCCONF, GSN_FSREMOVECONF
+ * GSN_FSSYNCCONF, GSN_FSREMOVECONF, GSN_FSSTATCONF
  */
 
 /**

--- 1.6/storage/ndb/include/kernel/signaldata/FsRef.hpp	2007-09-03 17:02:32 +00:00
+++ 1.7/storage/ndb/include/kernel/signaldata/FsRef.hpp	2007-09-03 17:02:32 +00:00
@@ -22,7 +22,7 @@
 /**
  * FsRef - Common signal class for all REF signals sent from Ndbfs
  * GSN_FSCLOSEREF, GSN_FSOPENREF, GSN_FSWRITEREF, GSN_FSREADREF,
- * GSN_FSSYNCREF
+ * GSN_FSSYNCREF,GSN_FSSTATREF
  */
 
 

--- 1.12/storage/ndb/include/kernel/signaldata/SignalData.hpp	2007-09-03 17:02:32 +00:00
+++ 1.13/storage/ndb/include/kernel/signaldata/SignalData.hpp	2007-09-03 17:02:32 +00:00
@@ -63,6 +63,7 @@ GSN_PRINT_SIGNATURE(printTUPKEYCONF);
 GSN_PRINT_SIGNATURE(printTUPKEYREF);
 GSN_PRINT_SIGNATURE(printTUPCOMMITREQ);
 GSN_PRINT_SIGNATURE(printCONTINUEB);
+GSN_PRINT_SIGNATURE(printFSSTATREQ);
 GSN_PRINT_SIGNATURE(printFSOPENREQ);
 GSN_PRINT_SIGNATURE(printFSCLOSEREQ);
 GSN_PRINT_SIGNATURE(printFSREADWRITEREQ);
@@ -72,6 +73,8 @@ GSN_PRINT_SIGNATURE(printFSREF);
 GSN_PRINT_SIGNATURE(printFSREF);
 GSN_PRINT_SIGNATURE(printFSREF);
 GSN_PRINT_SIGNATURE(printFSREF);
+GSN_PRINT_SIGNATURE(printFSREF);
+GSN_PRINT_SIGNATURE(printFSCONF);
 GSN_PRINT_SIGNATURE(printFSCONF);
 GSN_PRINT_SIGNATURE(printFSCONF);
 GSN_PRINT_SIGNATURE(printFSCONF);

--- 1.3/storage/ndb/include/kernel/signaldata/UtilSequence.hpp	2007-09-03 17:02:32 +00:00
+++ 1.4/storage/ndb/include/kernel/signaldata/UtilSequence.hpp	2007-09-03 17:02:32 +00:00
@@ -33,17 +33,19 @@ class UtilSequenceReq {
 
   friend bool printUTIL_SEQUENCE_REQ(FILE *, const Uint32 *, Uint32, Uint16);
 public:
-  STATIC_CONST( SignalLength = 3 );
+  STATIC_CONST( SignalLength = 4 );
   
   enum RequestType {
     NextVal = 1, // Return uniq value
     CurrVal = 2, // Read
-    Create  = 3  // Create a sequence
+    Create  = 3,  // Create a sequence
+    SetVal  = 4  // Set a new sequence
   };
 private:
   Uint32 senderData;  
   Uint32 sequenceId;  // Number of sequence variable
   Uint32 requestType;
+  Uint32 backupId;
 };
 
 class UtilSequenceConf {

--- 1.62/storage/ndb/include/mgmapi/mgmapi.h	2007-09-03 17:02:32 +00:00
+++ 1.63/storage/ndb/include/mgmapi/mgmapi.h	2007-09-03 17:02:32 +00:00
@@ -1050,13 +1050,15 @@ extern "C" {
    *                          2:  Wait for backup to be completed
    * @param   backup_id       Backup ID is returned from function.
    * @param   reply           Reply message.
+   * @param   input_backupId  user input backupId.
    * @return                  -1 on error.
    * @note                    backup_id will not be returned if
    *                          wait_completed == 0
    */
   int ndb_mgm_start_backup(NdbMgmHandle handle, int wait_completed,
 			   unsigned int* backup_id,
-			   struct ndb_mgm_reply* reply);
+			   struct ndb_mgm_reply* reply,
+			   unsigned int input_backupId = 0);
 
   /**
    * Abort backup

--- 1.16/storage/ndb/src/common/debugger/signaldata/SignalDataPrint.cpp	2007-09-03 17:02:32 +00:00
+++ 1.17/storage/ndb/src/common/debugger/signaldata/SignalDataPrint.cpp	2007-09-03 17:02:32 +00:00
@@ -37,16 +37,19 @@ SignalDataPrintFunctions[] = {
   { GSN_TUPKEYREF, printTUPKEYREF },
   { GSN_TUP_COMMITREQ, printTUPCOMMITREQ },
   { GSN_CONTINUEB, printCONTINUEB },
+  { GSN_FSSTATREQ, printFSSTATREQ },
   { GSN_FSOPENREQ, printFSOPENREQ },
   { GSN_FSCLOSEREQ, printFSCLOSEREQ },
   { GSN_FSREADREQ, printFSREADWRITEREQ },
   { GSN_FSWRITEREQ, printFSREADWRITEREQ },
   { GSN_FSCLOSEREF, printFSREF },
+  { GSN_FSSTATREF, printFSREF },
   { GSN_FSOPENREF, printFSREF },
   { GSN_FSWRITEREF, printFSREF },
   { GSN_FSREADREF, printFSREF },
   { GSN_FSSYNCREF, printFSREF },
   { GSN_FSCLOSECONF, printFSCONF },
+  { GSN_FSSTATCONF, printFSCONF },
   { GSN_FSOPENCONF, printFSCONF },
   { GSN_FSWRITECONF, printFSCONF },
   { GSN_FSREADCONF, printFSCONF },

--- 1.18/storage/ndb/src/common/debugger/signaldata/SignalNames.cpp	2007-09-03 17:02:32 +00:00
+++ 1.19/storage/ndb/src/common/debugger/signaldata/SignalNames.cpp	2007-09-03 17:02:32 +00:00
@@ -218,6 +218,9 @@ const GsnName SignalNames [] = {
   ,{ GSN_GCP_SAVEREF,            "GCP_SAVEREF" }
   ,{ GSN_GCP_SAVEREQ,            "GCP_SAVEREQ" }
   ,{ GSN_GCP_TCFINISHED,         "GCP_TCFINISHED" }
+  ,{ GSN_FSSTATREQ,              "FSSTATREQ" }
+  ,{ GSN_FSSTATREF,              "FSSTATREF" }
+  ,{ GSN_FSSTATCONF,             "FSSTATCONF" }
   ,{ GSN_GET_TABINFOREF,         "GET_TABINFOREF" }
   ,{ GSN_GET_TABINFOREQ,         "GET_TABINFOREQ" }
   ,{ GSN_GET_TABINFO_CONF,       "GET_TABINFO_CONF" }

--- 1.3/storage/ndb/src/common/debugger/signaldata/UtilSequence.cpp	2007-09-03 17:02:32 +00:00
+++ 1.4/storage/ndb/src/common/debugger/signaldata/UtilSequence.cpp	2007-09-03 17:02:32 +00:00
@@ -25,6 +25,8 @@ type2string(UtilSequenceReq::RequestType
     return "CurrVal";
   case UtilSequenceReq::Create:
     return "Create";
+  case UtilSequenceReq::SetVal:
+    return "SetVal";
   default:
     return "Unknown";
   }

--- 1.64/storage/ndb/src/kernel/blocks/backup/Backup.cpp	2007-09-03 17:02:32 +00:00
+++ 1.65/storage/ndb/src/kernel/blocks/backup/Backup.cpp	2007-09-03 17:02:32 +00:00
@@ -32,6 +32,7 @@
 #include <signaldata/ListTables.hpp>
 
 #include <signaldata/FsOpenReq.hpp>
+#include <signaldata/FsStatReq.hpp>
 #include <signaldata/FsAppendReq.hpp>
 #include <signaldata/FsCloseReq.hpp>
 #include <signaldata/FsConf.hpp>
@@ -1011,6 +1012,7 @@ Backup::execBACKUP_REQ(Signal* signal)
   const BlockReference senderRef = signal->senderBlockRef();
   const Uint32 dataLen32 = req->backupDataLen; // In 32 bit words
   const Uint32 flags = signal->getLength() > 2 ? req->flags : 2;
+  const Uint32 input_backupId = signal->getLength() > 3 ? req->inputBackupId : 0;
 
   if(getOwnNodeId() != getMasterNodeId()) {
     jam();
@@ -1055,7 +1057,10 @@ Backup::execBACKUP_REQ(Signal* signal)
   ptr.p->flags = flags;
   ptr.p->masterRef = reference();
   ptr.p->nodes = c_aliveNodes;
-  ptr.p->backupId = 0;
+  if(input_backupId > 0)
+    ptr.p->backupId = input_backupId;
+  else
+    ptr.p->backupId = 0;
   ptr.p->backupKey[0] = 0;
   ptr.p->backupKey[1] = 0;
   ptr.p->backupDataLen = 0;
@@ -1066,7 +1071,13 @@ Backup::execBACKUP_REQ(Signal* signal)
   ptr.p->masterData.gsn = GSN_UTIL_SEQUENCE_REQ;
   utilReq->senderData  = ptr.i;
   utilReq->sequenceId  = BACKUP_SEQUENCE;
-  utilReq->requestType = UtilSequenceReq::NextVal;
+  if(input_backupId > 0) {
+    utilReq->requestType = UtilSequenceReq::SetVal;
+    utilReq->backupId = input_backupId;
+  }
+  else { 
+    utilReq->requestType = UtilSequenceReq::NextVal;
+  }
   sendSignal(DBUTIL_REF, GSN_UTIL_SEQUENCE_REQ, 
 	     signal, UtilSequenceReq::SignalLength, JBB);
 }
@@ -1148,11 +1159,13 @@ Backup::execUTIL_SEQUENCE_CONF(Signal* s
   }//if
 
 
+  if(ptr.p->backupId <= 0 && conf->requestType != UtilSequenceReq::SetVal)
   {
     Uint64 backupId;
     memcpy(&backupId,conf->sequenceValue,8);
     ptr.p->backupId= (Uint32)backupId;
   }
+
   ptr.p->backupKey[0] = (getOwnNodeId() << 16) | (ptr.p->backupId & 0xFFFF);
   ptr.p->backupKey[1] = NdbTick_CurrentMillisecond();
 
@@ -2719,7 +2732,154 @@ Backup::execLIST_TABLES_CONF(Signal* sig
   /**
    * All tables fetched
    */
-  openFiles(signal, ptr);
+  getBackupFileStatus(signal, ptr);
+
+}
+
+void 
+Backup::getBackupFileStatus(Signal* signal, BackupRecordPtr ptr)
+{
+  jam();
+  
+  BackupFilePtr filePtr LINT_SET_PTR;
+
+  FsStatReq* req = (FsStatReq*)signal->getDataPtr();
+  req->userReference = reference();
+  //req->fileFlags =  FsStatReq::OM_READONLY;
+  FsStatReq::v2_setCount(req->fileNumber, 0xFFFFFFFF);
+  //req->auto_sync_size = c_defaults.m_disk_synch_size;
+  /**
+   * Ctl file
+   */
+  c_backupFilePool.getPtr(filePtr, ptr.p->ctlFilePtr);
+  filePtr.p->m_flags |= BackupFile::BF_CHECKING;
+
+  req->userPointer = filePtr.i;
+  FsStatReq::setVersion(req->fileNumber, 2);
+  FsStatReq::setSuffix(req->fileNumber, FsStatReq::S_CTL);
+  FsStatReq::v2_setSequence(req->fileNumber, ptr.p->backupId);
+  FsStatReq::v2_setNodeId(req->fileNumber, getOwnNodeId());
+  sendSignal(NDBFS_REF, GSN_FSSTATREQ, signal, FsStatReq::SignalLength, JBA);
+  /**
+   * Log file
+   */
+  c_backupFilePool.getPtr(filePtr, ptr.p->logFilePtr);
+  filePtr.p->m_flags |= BackupFile::BF_CHECKING;
+
+  req->userPointer = filePtr.i;
+  FsStatReq::setVersion(req->fileNumber, 2);
+  FsStatReq::setSuffix(req->fileNumber, FsStatReq::S_LOG);
+  FsStatReq::v2_setSequence(req->fileNumber, ptr.p->backupId);
+  FsStatReq::v2_setNodeId(req->fileNumber, getOwnNodeId());
+  sendSignal(NDBFS_REF, GSN_FSSTATREQ, signal, FsStatReq::SignalLength, JBA);
+  /**
+   * Data file
+   */
+  c_backupFilePool.getPtr(filePtr, ptr.p->dataFilePtr);
+  filePtr.p->m_flags |= BackupFile::BF_CHECKING;
+
+  req->userPointer = filePtr.i;
+  FsStatReq::setVersion(req->fileNumber, 2);
+  FsStatReq::setSuffix(req->fileNumber, FsStatReq::S_DATA);
+  FsStatReq::v2_setSequence(req->fileNumber, ptr.p->backupId);
+  FsStatReq::v2_setNodeId(req->fileNumber, getOwnNodeId());
+  FsStatReq::v2_setCount(req->fileNumber, 0);
+
+  sendSignal(NDBFS_REF, GSN_FSSTATREQ, signal, FsStatReq::SignalLength, JBA);
+
+}
+
+void
+Backup::execFSSTATREF(Signal* signal)
+{
+  jamEntry();
+
+  FsRef * ref = (FsRef *)signal->getDataPtr();
+
+  const Uint32 userPtr = ref->userPointer;
+
+  BackupFilePtr filePtr LINT_SET_PTR;
+  c_backupFilePool.getPtr(filePtr, userPtr);
+
+  BackupRecordPtr ptr LINT_SET_PTR;
+  c_backupPool.getPtr(ptr, filePtr.p->backupPtr);
+
+  ndbrequire(filePtr.p->m_flags & BackupFile::BF_CHECKING);
+  filePtr.p->m_flags &= ~(Uint32)BackupFile::BF_CHECKING;
+  filePtr.p->m_flags &= ~(Uint32)BackupFile::BF_EXIST;
+
+  getFilesStatReply(signal, ptr, filePtr);
+}
+
+void
+Backup::execFSSTATCONF(Signal* signal)
+{
+  jamEntry();
+
+  FsConf * conf = (FsConf *)signal->getDataPtr();
+
+  const Uint32 userPtr = conf->userPointer;
+
+  BackupFilePtr filePtr LINT_SET_PTR;
+  c_backupFilePool.getPtr(filePtr, userPtr);
+
+  BackupRecordPtr ptr LINT_SET_PTR;
+  c_backupPool.getPtr(ptr, filePtr.p->backupPtr);
+
+  ndbrequire(filePtr.p->m_flags & BackupFile::BF_CHECKING);
+  filePtr.p->m_flags &= ~(Uint32)BackupFile::BF_CHECKING;
+  filePtr.p->m_flags |= BackupFile::BF_EXIST;
+  
+  getFilesStatReply(signal, ptr, filePtr);
+}
+ 
+void
+Backup::getFilesStatReply(Signal* signal,
+                       BackupRecordPtr ptr, BackupFilePtr filePtr)
+{
+  jam();
+  bool exist= false;
+  /**
+   * Check if all files have recived FSSTAT reply
+   */
+  for(ptr.p->files.first(filePtr); filePtr.i!=RNIL;ptr.p->files.next(filePtr))
+  {
+    jam();
+    if(filePtr.p->m_flags & BackupFile::BF_CHECKING) {
+      jam();
+      return;
+    }//if
+  }
+  /**
+   * If file exist, will return REF
+   */
+  for(ptr.p->files.first(filePtr); filePtr.i!=RNIL;ptr.p->files.next(filePtr))
+  {
+    jam();
+    if(filePtr.p->m_flags & BackupFile::BF_EXIST) {
+      jam();
+      //should clearup all the backupFile's  m_flags
+      filePtr.p->m_flags &= ~(Uint32)BackupFile::BF_EXIST;
+      exist = true;
+    }//if
+  }
+
+  if (ERROR_INSERTED(10037)) {
+    jam();
+    defineBackupRef(signal, ptr, DefineBackupRef::FailedForBackupFilesAleadyExist);
+    return;
+  }
+
+  if(exist == true)
+  {
+    defineBackupRef(signal, ptr, DefineBackupRef::FailedForBackupFilesAleadyExist);
+    return;
+  }
+  else
+  /**
+   * All backup files don't already exist
+   */
+    openFiles(signal, ptr);
 }
 
 void

--- 1.27/storage/ndb/src/kernel/blocks/backup/Backup.hpp	2007-09-03 17:02:32 +00:00
+++ 1.28/storage/ndb/src/kernel/blocks/backup/Backup.hpp	2007-09-03 17:02:32 +00:00
@@ -110,6 +110,9 @@ protected:
   /**
    * FS signals
    */
+  void execFSSTATREF(Signal* signal);
+  void execFSSTATCONF(Signal* signal);
+
   void execFSOPENREF(Signal* signal);
   void execFSOPENCONF(Signal* signal);
 
@@ -351,6 +354,8 @@ public:
       ,BF_FILE_THREAD = 0x8
       ,BF_SCAN_THREAD = 0x10
       ,BF_LCP_META    = 0x20
+      ,BF_CHECKING    = 0x40
+      ,BF_EXIST       = 0x80
     };
     Uint32 m_flags;
     Uint32 m_pos;
@@ -581,6 +586,8 @@ public:
   void getFragmentInfo(Signal*, BackupRecordPtr, TablePtr, Uint32 fragNo);
   void getFragmentInfoDone(Signal*, BackupRecordPtr);
   
+  void getBackupFileStatus(Signal* signal, BackupRecordPtr ptr);
+  void getFilesStatReply(Signal*, BackupRecordPtr ptr, BackupFilePtr);
   void openFiles(Signal* signal, BackupRecordPtr ptr);
   void openFilesReply(Signal*, BackupRecordPtr ptr, BackupFilePtr);
   void closeFiles(Signal*, BackupRecordPtr ptr);

--- 1.26/storage/ndb/src/kernel/blocks/backup/BackupInit.cpp	2007-09-03 17:02:32 +00:00
+++ 1.27/storage/ndb/src/kernel/blocks/backup/BackupInit.cpp	2007-09-03 17:02:32 +00:00
@@ -67,6 +67,8 @@ Backup::Backup(Block_context& ctx) :
   addRecSignal(GSN_DI_FCOUNTCONF, &Backup::execDI_FCOUNTCONF);
   addRecSignal(GSN_DIGETPRIMCONF, &Backup::execDIGETPRIMCONF);
 
+  addRecSignal(GSN_FSSTATREF, &Backup::execFSSTATREF, true);
+  addRecSignal(GSN_FSSTATCONF, &Backup::execFSSTATCONF);
   addRecSignal(GSN_FSOPENREF, &Backup::execFSOPENREF, true);
   addRecSignal(GSN_FSOPENCONF, &Backup::execFSOPENCONF);
 

--- 1.18/storage/ndb/src/kernel/blocks/dbutil/DbUtil.cpp	2007-09-03 17:02:32 +00:00
+++ 1.19/storage/ndb/src/kernel/blocks/dbutil/DbUtil.cpp	2007-09-03 17:02:32 +00:00
@@ -171,7 +171,7 @@ DbUtil::execREAD_CONFIG_REQ(Signal* sign
 
   c_pagePool.setSize(10);
   c_preparePool.setSize(1);            // one parallel prepare at a time
-  c_preparedOperationPool.setSize(5);  // three hardcoded, two for test
+  c_preparedOperationPool.setSize(6);  // three hardcoded, one for setval, two for test
   c_operationPool.setSize(64);         // 64 parallel operations
   c_transactionPool.setSize(32);       // 16 parallel transactions
   c_attrMappingPool.setSize(100);
@@ -1496,6 +1496,35 @@ DbUtil::hardcodedPrepare() {
     ptr.p->tckey.requestInfo = requestInfo;
     ptr.p->tckey.tableSchemaVersion = 1;
   }
+
+  /**
+   * Prepare SetSequence (UPDATE)
+   */
+  {
+    PreparedOperationPtr ptr;
+    ndbrequire(c_preparedOperationPool.seizeId(ptr, 3));
+    ptr.p->keyLen = 1;
+    ptr.p->rsLen = 0;
+    ptr.p->tckeyLenInBytes = (TcKeyReq::StaticLength + ptr.p->keyLen + 5) * 4;
+    ptr.p->keyDataPos = TcKeyReq::StaticLength;
+    ptr.p->tckey.attrLen = 9;
+    ptr.p->tckey.tableId = 0;
+    Uint32 requestInfo = 0;
+    TcKeyReq::setAbortOption(requestInfo, TcKeyReq::CommitIfFailFree);
+    TcKeyReq::setOperationType(requestInfo, ZUPDATE);
+    TcKeyReq::setKeyLength(requestInfo, 1);
+    TcKeyReq::setAIInTcKeyReq(requestInfo, 5);
+    TcKeyReq::setInterpretedFlag(requestInfo, 1);
+    ptr.p->tckey.requestInfo = requestInfo;
+    ptr.p->tckey.tableSchemaVersion = 1;
+
+    Uint32 * attrInfo = &ptr.p->tckey.distrGroupHashValue;
+    attrInfo[0] = 0; // IntialReadSize
+    attrInfo[1] = 3; // InterpretedSize
+    attrInfo[2] = 0; // FinalUpdateSize
+    attrInfo[3] = 1; // FinalReadSize
+    attrInfo[4] = 0; // SubroutineSize
+  }
 }
 
 void
@@ -1516,6 +1545,10 @@ DbUtil::execUTIL_SEQUENCE_REQ(Signal* si
   case UtilSequenceReq::Create:
     prepOp = c_preparedOperationPool.getPtr(2); //c_CreateSequence
     break;
+  case UtilSequenceReq::SetVal:{
+    prepOp = c_preparedOperationPool.getPtr(3);
+    break;
+  }
   default:
     ndbrequire(false);
     prepOp = 0; // remove warning
@@ -1566,6 +1599,21 @@ DbUtil::execUTIL_SEQUENCE_REQ(Signal* si
     * it.data = 0;
   }
   
+  if(req->requestType == UtilSequenceReq::SetVal)
+  { // AttrInfo
+    ndbrequire(opPtr.p->attrInfo.seize(4));
+    AttrInfoBuffer::DataBufferIterator it;
+    opPtr.p->attrInfo.first(it);
+    * it.data = Interpreter::LoadConst16(7, req->backupId);
+    ndbrequire(opPtr.p->attrInfo.next(it));
+    * it.data = Interpreter::Write(1, 7);
+    ndbrequire(opPtr.p->attrInfo.next(it))
+    * it.data = Interpreter::ExitOK();
+
+    ndbrequire(opPtr.p->attrInfo.next(it));
+    AttributeHeader::init(it.data, 1, 0);
+  }
+ 
   runTransaction(signal, transPtr);
 }
 
@@ -1643,6 +1691,9 @@ DbUtil::reportSequence(Signal* signal, c
       ret->sequenceValue[1] = rsit.data[2];
       break;
     }
+    case UtilSequenceReq::SetVal:
+      ok = true;
+      break;
     case UtilSequenceReq::Create:
       ok = true;
       ret->sequenceValue[0] = 0;
@@ -1659,6 +1710,7 @@ DbUtil::reportSequence(Signal* signal, c
 
   switch(transP->sequence.requestType)
     {
+    case UtilSequenceReq::SetVal:
     case UtilSequenceReq::CurrVal:
     case UtilSequenceReq::NextVal:{
       if (transP->errorCode == 626)

--- 1.38/storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp	2007-09-03 17:02:32 +00:00
+++ 1.39/storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp	2007-09-03 17:02:32 +00:00
@@ -29,6 +29,7 @@
 #include <NdbThread.h>
 #include <signaldata/FsRef.hpp>
 #include <signaldata/FsOpenReq.hpp>
+#include <signaldata/FsStatReq.hpp>
 #include <signaldata/FsReadWriteReq.hpp>
 
 // use this to test broken pread code
@@ -181,6 +182,9 @@ AsyncFile::run()
     }//if
     m_current_request= request;
     switch (request->action) {
+    case Request:: status:
+      statusReq(request);
+      break;
     case Request:: open:
       openReq(request);
       break;
@@ -247,6 +251,16 @@ AsyncFile::run()
 static char g_odirect_readbuf[2*GLOBAL_PAGE_SIZE -1];
 #endif
 
+void AsyncFile::statusReq(Request* request)
+{
+  struct stat buf;
+  if ((stat(theFileName.c_str(), &buf) == -1))
+  {
+    request->error = errno;
+    return;
+  }
+}
+  
 void AsyncFile::openReq(Request* request)
 {  
   m_auto_sync_freq = 0;

--- 1.10/storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp	2007-09-03 17:02:32 +00:00
+++ 1.11/storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp	2007-09-03 17:02:32 +00:00
@@ -109,6 +109,7 @@ public:
   Request() {}
 
   enum Action {
+    status,
     open,
     close,
     closeRemove,
@@ -199,6 +200,7 @@ public:
   Request *m_current_request, *m_last_request;
 private:
   
+  void statusReq(Request *request);
   void openReq(Request *request);
   void readReq(Request *request);
   void readvReq(Request *request);

--- 1.12/storage/ndb/src/kernel/blocks/ndbfs/Filename.cpp	2007-09-03 17:02:32 +00:00
+++ 1.13/storage/ndb/src/kernel/blocks/ndbfs/Filename.cpp	2007-09-03 17:02:32 +00:00
@@ -23,6 +23,7 @@
 #include "DebuggerNames.hpp"
 
 #include <signaldata/FsOpenReq.hpp>
+#include <signaldata/FsStatReq.hpp>
 
 static const char* fileExtension[] = {
   ".Data",

--- 1.32/storage/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp	2007-09-03 17:02:32 +00:00
+++ 1.33/storage/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp	2007-09-03 17:02:32 +00:00
@@ -20,6 +20,7 @@
 #include "Filename.hpp"
 
 #include <signaldata/FsOpenReq.hpp>
+#include <signaldata/FsStatReq.hpp>
 #include <signaldata/FsCloseReq.hpp>
 #include <signaldata/FsReadWriteReq.hpp>
 #include <signaldata/FsAppendReq.hpp>
@@ -62,6 +63,7 @@ Ndbfs::Ndbfs(Block_context& ctx) :
   addRecSignal(GSN_READ_CONFIG_REQ, &Ndbfs::execREAD_CONFIG_REQ);
   addRecSignal(GSN_DUMP_STATE_ORD,  &Ndbfs::execDUMP_STATE_ORD);
   addRecSignal(GSN_STTOR,  &Ndbfs::execSTTOR);
+  addRecSignal(GSN_FSSTATREQ, &Ndbfs::execFSSTATREQ);
   addRecSignal(GSN_FSOPENREQ, &Ndbfs::execFSOPENREQ);
   addRecSignal(GSN_FSCLOSEREQ, &Ndbfs::execFSCLOSEREQ);
   addRecSignal(GSN_FSWRITEREQ, &Ndbfs::execFSWRITEREQ);
@@ -174,6 +176,42 @@ Ndbfs::forward( AsyncFile * file, Reques
   return 1;
 }
 
+void
+Ndbfs::execFSSTATREQ(Signal* signal)
+{
+  jamEntry();
+  const FsStatReq * const fsStatReq = (FsStatReq *)&signal->theData[0];
+  const BlockReference userRef = fsStatReq->userReference;
+  AsyncFile* file = getIdleFile();
+  ndbrequire(file != NULL);
+  Filename::NameSpec spec(theFileSystemPath, theBackupFilePath);
+
+  Uint32 userPointer = fsStatReq->userPointer;
+
+  ndbassert(file->m_page_ptr.isNull());
+  file->m_page_ptr.setNull();
+
+  if(signal->getNoOfSections() == 0){
+    jam();
+    file->theFileName.set(spec, userRef, fsStatReq->fileNumber);
+  } else {
+    jam();
+    SegmentedSectionPtr ptr;
+    signal->getSection(ptr, FsStatReq::FILENAME);
+    file->theFileName.set(spec, ptr, g_sectionSegmentPool);
+    releaseSections(signal);
+  }
+  file->reportTo(&theFromThreads);
+  
+  Request* request = theRequestPool->get();
+  request->action = Request::status;
+  request->error = 0;
+  request->set(userRef, userPointer, newId() );
+  request->file = file;
+  request->theTrace = signal->getTrace();
+  ndbrequire(forward(file, request));
+}
+
 void 
 Ndbfs::execFSOPENREQ(Signal* signal)
 {
@@ -715,6 +753,11 @@ Ndbfs::report(Request * request, Signal*
       fsRef->osErrorCode = request->error; 
     }
     switch (request->action) {
+    case Request:: status: {
+      jam();
+      sendSignal(ref, GSN_FSSTATREF, signal, FsRef::SignalLength, JBB);
+      break;
+    }
     case Request:: open: {
       jam();
       // Put the file back in idle files list
@@ -773,6 +816,10 @@ Ndbfs::report(Request * request, Signal*
     FsConf * const fsConf = (FsConf *)&signal->theData[0];
     fsConf->userPointer = request->theUserPointer;
     switch (request->action) {
+    case Request:: status: {
+      sendSignal(ref, GSN_FSSTATCONF, signal, 3, JBB);
+      break;
+    }
     case Request:: open: {
       jam();
       theOpenFiles.insert(request->file, request->theFilePointer);

--- 1.8/storage/ndb/src/kernel/blocks/ndbfs/Ndbfs.hpp	2007-09-03 17:02:32 +00:00
+++ 1.9/storage/ndb/src/kernel/blocks/ndbfs/Ndbfs.hpp	2007-09-03 17:02:32 +00:00
@@ -43,6 +43,7 @@ protected:
   // The signal processing functions
   void execREAD_CONFIG_REQ(Signal* signal);
   void execDUMP_STATE_ORD(Signal* signal);
+  void execFSSTATREQ(Signal* signal);
   void execFSOPENREQ(Signal* signal);
   void execFSCLOSEREQ(Signal* signal);
   void execFSWRITEREQ(Signal* signal);

--- 1.39/storage/ndb/src/kernel/vm/SimulatedBlock.cpp	2007-09-03 17:02:32 +00:00
+++ 1.40/storage/ndb/src/kernel/vm/SimulatedBlock.cpp	2007-09-03 17:02:32 +00:00
@@ -143,6 +143,7 @@ SimulatedBlock::installSimulatedBlockFun
   a[GSN_UTIL_LOCK_CONF]   = &SimulatedBlock::execUTIL_LOCK_CONF;
   a[GSN_UTIL_UNLOCK_REF]  = &SimulatedBlock::execUTIL_UNLOCK_REF;
   a[GSN_UTIL_UNLOCK_CONF] = &SimulatedBlock::execUTIL_UNLOCK_CONF;
+  a[GSN_FSSTATREF]    = &SimulatedBlock::execFSSTATREF;
   a[GSN_FSOPENREF]    = &SimulatedBlock::execFSOPENREF;
   a[GSN_FSCLOSEREF]   = &SimulatedBlock::execFSCLOSEREF;
   a[GSN_FSWRITEREF]   = &SimulatedBlock::execFSWRITEREF;
@@ -1828,6 +1829,12 @@ void
 SimulatedBlock::execFSCLOSEREF(Signal* signal) 
 {
   fsRefError(signal, __LINE__, "File system close failed");
+}
+
+void
+SimulatedBlock::execFSSTATREF(Signal* signal)
+{
+  fsRefError(signal, __LINE__, "File system get status failed");
 }
 
 void

--- 1.29/storage/ndb/src/kernel/vm/SimulatedBlock.hpp	2007-09-03 17:02:32 +00:00
+++ 1.30/storage/ndb/src/kernel/vm/SimulatedBlock.hpp	2007-09-03 17:02:32 +00:00
@@ -537,6 +537,7 @@ protected:
   void fsRefError(Signal* signal, Uint32 line, const char *msg);
   void execFSWRITEREF(Signal* signal);
   void execFSREADREF(Signal* signal);
+  void execFSSTATREF(Signal* signal);
   void execFSOPENREF(Signal* signal);
   void execFSCLOSEREF(Signal* signal);
   void execFSREMOVEREF(Signal* signal);

--- 1.87/storage/ndb/src/mgmapi/mgmapi.cpp	2007-09-03 17:02:32 +00:00
+++ 1.88/storage/ndb/src/mgmapi/mgmapi.cpp	2007-09-03 17:02:32 +00:00
@@ -1951,7 +1951,8 @@ extern "C"
 int 
 ndb_mgm_start_backup(NdbMgmHandle handle, int wait_completed,
 		     unsigned int* _backup_id,
-		     struct ndb_mgm_reply* /*reply*/) 
+		     struct ndb_mgm_reply*, /*reply*/
+		     unsigned int input_backupId) 
 {
   SET_ERROR(handle, NDB_MGM_NO_ERROR, "Executing: ndb_mgm_start_backup");
   const ParserRow<ParserDummy> start_backup_reply[] = {
@@ -1965,6 +1966,8 @@ ndb_mgm_start_backup(NdbMgmHandle handle
 
   Properties args;
   args.put("completed", wait_completed);
+  if(input_backupId > 0)
+    args.put("backupid", input_backupId);
   const Properties *reply;
   { // start backup can take some time, set timeout high
     Uint64 old_timeout= handle->read_timeout;

--- 1.89/storage/ndb/src/mgmclient/CommandInterpreter.cpp	2007-09-03 17:02:32 +00:00
+++ 1.90/storage/ndb/src/mgmclient/CommandInterpreter.cpp	2007-09-03 17:02:32 +00:00
@@ -259,7 +259,7 @@ static const char* helpText =
 "SHOW CONFIG                            Print configuration\n"
 "SHOW PARAMETERS                        Print configuration parameters\n"
 #endif
-"START BACKUP [NOWAIT | WAIT STARTED | WAIT COMPLETED]\n"
+"START BACKUP [N | NOWAIT | WAIT STARTED | WAIT COMPLETED]\n"
 "                                       Start backup (default WAIT COMPLETED)\n"
 "ABORT BACKUP <backup id>               Abort backup\n"
 "SHUTDOWN                               Shutdown all processes in cluster\n"
@@ -323,12 +323,15 @@ static const char* helpTextStartBackup =
 " NDB Cluster -- Management Client -- Help for START BACKUP command\n"
 "---------------------------------------------------------------------------\n"
 "START BACKUP  Start a cluster backup\n\n"
-"START BACKUP [NOWAIT | WAIT STARTED | WAIT COMPLETED]\n"
+"START BACKUP [N | NOWAIT | WAIT STARTED | WAIT COMPLETED]\n"
 "                   Start a backup for the cluster.\n"
 "                   Each backup gets an ID number that is reported to the\n"
 "                   user. This ID number can help you find the backup on the\n"
 "                   file system, or ABORT BACKUP if you wish to cancel a \n"
-"                   running backup.\n\n"
+"                   running backup.\n"
+"                   You can also start specified backup using START BACKUP N \n\n"
+"                   N \n"
+"                     Start a specified backup using N as bakcup ID number.\n" 
 "                   NOWAIT \n"
 "                     Start a cluster backup and return immediately.\n"
 "                     The management client will return control directly\n"
@@ -605,6 +608,7 @@ struct st_cmd_help {
   {"HELP", helpTextHelp},
   {"BACKUP", helpTextBackup},
   {"START BACKUP", helpTextStartBackup},
+  {"START BACKUP N", helpTextStartBackup},
   {"START BACKUP NOWAIT", helpTextStartBackup},
   {"START BACKUP WAIT STARTED", helpTextStartBackup},
   {"START BACKUP WAIT", helpTextStartBackup},
@@ -653,6 +657,28 @@ convert(const char* s, int& val) {
   return true;
 }
 
+static bool
+convertU(const char* s, unsigned int& val) {
+  
+  if (s == NULL)
+    return false;
+
+  if (strlen(s) == 0)
+    return false;
+
+  errno = 0;
+  char* p;
+  long v = strtol(s, &p, 10);
+  if (errno != 0)
+    return false;
+
+  if (p != &s[strlen(s)])
+    return false;
+  
+  val = v;
+  return true;
+}
+
 /*
  * Constructor
  */
@@ -2473,6 +2499,7 @@ CommandInterpreter::executeStartBackup(c
 {
   struct ndb_mgm_reply reply;
   unsigned int backupId;
+  unsigned int input_backupId = 0;
   int fd = -1;
   
   Vector<BaseString> args;
@@ -2488,22 +2515,84 @@ CommandInterpreter::executeStartBackup(c
 
   int result;
   int flags = 2;
+  // start backup nowait
   if (sz == 2 && args[1] == "NOWAIT")
   {
     flags = 0;
     result = ndb_mgm_start_backup(m_mgmsrv, 0, &backupId, &reply);
     goto END_BACKUP;
   }
+  // start backup n nowait
+  else if (sz == 3 && args[2] == "NOWAIT")
+  {
+    if (convertU(args[1].c_str(), input_backupId))
+    {
+      if (input_backupId > 0 && input_backupId < MAX_BACKUPS)
+      {
+        flags = 0;
+        result = ndb_mgm_start_backup(m_mgmsrv, 0, &backupId, &reply, input_backupId);
+        goto END_BACKUP;
+      }
+    }
+    invalid_command(parameters);
+    return -1;
+  }
+  //start backup ; start backup wait complete
   else if (sz == 1 || (sz == 3 && args[1] == "WAIT" && args[2] == "COMPLETED"))
   {
     flags = 2;
     ndbout_c("Waiting for completed, this may take several minutes");
   }
+  // start backup n; start backup n wait complete
+  else if ( sz == 2 || (sz == 4 && args[2] == "WAIT" && args[3] =="COMPLETED"))
+  {
+    if (convertU(args[1].c_str(), input_backupId))
+    {
+      if (input_backupId > 0 && input_backupId < MAX_BACKUPS)
+      {
+        flags = 2;
+        ndbout_c("Waiting for completed, this may take several minutes");
+      }
+      else
+      {
+        invalid_command(parameters);
+        return -1;
+      }
+    }
+    else
+    {
+      invalid_command(parameters);
+      return -1;
+    }
+  }
+  // start backup wait started
   else if (sz == 3 && args[1] == "WAIT" && args[2] == "STARTED")
   {
     ndbout_c("Waiting for started, this may take several minutes");
     flags = 1;
   }
+  //start backup n wait started
+  else if (sz == 4 && args[2] == "WAIT" && args[3] == "STARTED")
+  {
+    if (convertU(args[1].c_str(), input_backupId))
+    {
+      if (input_backupId > 0 && input_backupId < MAX_BACKUPS)
+      {
+        ndbout_c("Waiting for started, this may take several minutes");
+        flags = 1;
+      }
+      else
+      {
+        invalid_command(parameters);
+        return -1;
+      }
+    }
+    else
+    {
+      invalid_command(parameters);
+      return -1;
+    }
+  }
   else
   {
     invalid_command(parameters);
@@ -2524,7 +2613,10 @@ CommandInterpreter::executeStartBackup(c
       return fd;
     }
   }
-  result = ndb_mgm_start_backup(m_mgmsrv, flags, &backupId, &reply);
+  if (input_backupId > 0)
+    result = ndb_mgm_start_backup(m_mgmsrv, flags, &backupId, &reply, input_backupId);
+  else
+    result = ndb_mgm_start_backup(m_mgmsrv, flags, &backupId, &reply);
 
 END_BACKUP:
   if (result != 0) {

--- 1.122/storage/ndb/src/mgmsrv/MgmtSrvr.cpp	2007-09-03 17:02:32 +00:00
+++ 1.123/storage/ndb/src/mgmsrv/MgmtSrvr.cpp	2007-09-03 17:02:32 +00:00
@@ -2533,7 +2533,7 @@ MgmtSrvr::eventReport(const Uint32 * the
  ***************************************************************************/
 
 int
-MgmtSrvr::startBackup(Uint32& backupId, int waitCompleted)
+MgmtSrvr::startBackup(Uint32& backupId, int waitCompleted, Uint32 input_backupId)
 {
   SignalSender ss(theFacade);
   ss.lock(); // lock will be released on exit
@@ -2558,6 +2558,8 @@ MgmtSrvr::startBackup(Uint32& backupId, 
   req->backupDataLen = 0;
   assert(waitCompleted < 3);
   req->flags = waitCompleted & 0x3;
+  if(input_backupId > 0)
+    req->inputBackupId = input_backupId;
 
   BackupEvent event;
   int do_send = 1;

--- 1.54/storage/ndb/src/mgmsrv/MgmtSrvr.hpp	2007-09-03 17:02:32 +00:00
+++ 1.55/storage/ndb/src/mgmsrv/MgmtSrvr.hpp	2007-09-03 17:02:32 +00:00
@@ -342,7 +342,7 @@ public:
   /**
    * Backup functionallity
    */
-  int startBackup(Uint32& backupId, int waitCompleted= 2);
+  int startBackup(Uint32& backupId, int waitCompleted= 2, Uint32 input_backupId= 0);
   int abortBackup(Uint32 backupId);
   int performBackup(Uint32* backupId);
 

--- 1.87/storage/ndb/src/mgmsrv/Services.cpp	2007-09-03 17:02:33 +00:00
+++ 1.88/storage/ndb/src/mgmsrv/Services.cpp	2007-09-03 17:02:33 +00:00
@@ -189,6 +189,7 @@ ParserRow<MgmApiSession> commands[] = {
 
   MGM_CMD("start backup", &MgmApiSession::startBackup, ""),
     MGM_ARG("completed", Int, Optional ,"Wait until completed"),
+    MGM_ARG("backupid", Int, Optional ,"User input backup id"),
 
   MGM_CMD("abort backup", &MgmApiSession::abortBackup, ""),
     MGM_ARG("id", Int, Mandatory, "Backup id"),
@@ -661,12 +662,19 @@ MgmApiSession::startBackup(Parser<MgmApi
 			   Properties const &args) {
   DBUG_ENTER("MgmApiSession::startBackup");
   unsigned backupId;
+  unsigned input_backupId;
   Uint32 completed= 2;
   int result;
 
   args.get("completed", &completed);
 
-  result = m_mgmsrv.startBackup(backupId, completed);
+  if(args.contains("backupid"))
+  {
+    args.get("backupid", &input_backupId);
+    result = m_mgmsrv.startBackup(backupId, completed, input_backupId);
+  }
+  else
+    result = m_mgmsrv.startBackup(backupId, completed);
 
   m_output->println("start backup reply");
   if(result != 0)

--- 1.20/storage/ndb/test/include/NDBT_Test.hpp	2007-09-03 17:02:33 +00:00
+++ 1.21/storage/ndb/test/include/NDBT_Test.hpp	2007-09-03 17:02:33 +00:00
@@ -17,6 +17,7 @@
 #define NDBT_TEST_HPP
 
 #include <ndb_global.h>
+#include <kernel/ndb_limits.h>
 
 #include "NDBT_ReturnCodes.h"
 #include <Properties.hpp>

--- 1.17/storage/ndb/test/ndbapi/testBackup.cpp	2007-09-03 17:02:33 +00:00
+++ 1.18/storage/ndb/test/ndbapi/testBackup.cpp	2007-09-03 17:02:33 +00:00
@@ -137,6 +137,19 @@ int runBackupOne(NDBT_Context* ctx, NDBT
   return NDBT_OK;
 }
 
+int runBackupRandom(NDBT_Context* ctx, NDBT_Step* step){
+  NdbBackup backup(GETNDB(step)->getNodeId()+1);
+  unsigned backupId = rand() % (MAX_BACKUPS);
+
+  if (backup.start(backupId) == -1){
+    return NDBT_FAILED;
+  }
+  ndbout << "Started backup " << backupId << endl;
+  ctx->setProperty("BackupId", backupId);
+
+  return NDBT_OK;
+}
+
 int
 runBackupLoop(NDBT_Context* ctx, NDBT_Step* step){
   NdbBackup backup(GETNDB(step)->getNodeId()+1);
@@ -470,6 +483,20 @@ TESTCASE("BackupOne", 
 	 "5. Verify count and content of table\n"){
   INITIALIZER(runLoadTable);
   INITIALIZER(runBackupOne);
+  INITIALIZER(runDropTablesRestart);
+  INITIALIZER(runRestoreOne);
+  VERIFIER(runVerifyOne);
+  FINALIZER(runClearTable);
+}
+TESTCASE("BackupRandom", 
+	 "Test that backup n and restore works on one table \n"
+	 "1. Load table\n"
+	 "2. Backup\n"
+	 "3. Drop tables and restart \n"
+	 "4. Restore\n"
+	 "5. Verify count and content of table\n"){
+  INITIALIZER(runLoadTable);
+  INITIALIZER(runBackupRandom);
   INITIALIZER(runDropTablesRestart);
   INITIALIZER(runRestoreOne);
   VERIFIER(runVerifyOne);

--- 1.28/storage/ndb/test/src/NdbBackup.cpp	2007-09-03 17:02:33 +00:00
+++ 1.29/storage/ndb/test/src/NdbBackup.cpp	2007-09-03 17:02:33 +00:00
@@ -350,7 +350,8 @@ FailS_codes[] = {
   10025,
   10027,
   10033,
-  10035
+  10035,
+  10037
 };
 
 int

--- 1.86/storage/ndb/src/ndbapi/ndberror.c	2007-09-03 17:02:33 +00:00
+++ 1.87/storage/ndb/src/ndbapi/ndberror.c	2007-09-03 17:02:33 +00:00
@@ -461,6 +461,7 @@ ErrorBundle ErrorCodes[] = {
   { 1347, DMEC, AE, "Backup failed to allocate table memory (check configuration)" },
   { 1348, DMEC, AE, "Backup failed to allocate file record (check configuration)" },
   { 1349, DMEC, AE, "Backup failed to allocate attribute record (check configuration)" },
+  { 1350, DMEC, TR, "Backup failed: file already exists (use 'START BACKUP N')" },
   { 1329, DMEC, AE, "Backup during software upgrade not supported" },
 
   /**

--- 1.9/storage/ndb/src/common/debugger/signaldata/Makefile.am	2007-09-03 17:02:33 +00:00
+++ 1.10/storage/ndb/src/common/debugger/signaldata/Makefile.am	2007-09-03 17:02:33 +00:00
@@ -19,7 +19,7 @@ libsignaldataprint_la_SOURCES = \
           TcKeyReq.cpp TcKeyConf.cpp TcKeyRef.cpp \
 	  TcRollbackRep.cpp \
           TupKey.cpp TupCommit.cpp LqhKey.cpp \
-          FsOpenReq.cpp FsCloseReq.cpp FsRef.cpp FsConf.cpp FsReadWriteReq.cpp\
+          FsStatReq.cpp FsOpenReq.cpp FsCloseReq.cpp FsRef.cpp FsConf.cpp FsReadWriteReq.cpp\
           SignalDataPrint.cpp SignalNames.cpp \
           ContinueB.cpp DihContinueB.cpp NdbfsContinueB.cpp \
           CloseComReqConf.cpp PackedSignal.cpp PrepFailReqRef.cpp \
Thread
bk commit into 5.1 tree (lzhou:1.2491)lzhou3 Sep