Commit 1e8380df authored by joreland@mysql.com's avatar joreland@mysql.com

Merge mysql.com:/home/jonas/src/mysql-4.1

into  mysql.com:/home/jonas/src/mysql-5.0
parents 22a0df05 bb73ba09
...@@ -128,7 +128,8 @@ public: ...@@ -128,7 +128,8 @@ public:
RecordTooBig = 738, RecordTooBig = 738,
InvalidPrimaryKeySize = 739, InvalidPrimaryKeySize = 739,
NullablePrimaryKey = 740, NullablePrimaryKey = 740,
UnsupportedChange = 741 UnsupportedChange = 741,
BackupInProgress = 762
}; };
private: private:
......
...@@ -215,6 +215,7 @@ public: ...@@ -215,6 +215,7 @@ public:
StateBuilding = 2, StateBuilding = 2,
StateDropping = 3, StateDropping = 3,
StateOnline = 4, StateOnline = 4,
StateBackup = 5,
StateBroken = 9 StateBroken = 9
}; };
......
...@@ -57,7 +57,8 @@ public: ...@@ -57,7 +57,8 @@ public:
NoSuchTable = 709, NoSuchTable = 709,
InvalidTableVersion = 241, InvalidTableVersion = 241,
DropInProgress = 283, DropInProgress = 283,
NoDropTableRecordAvailable = 1229 NoDropTableRecordAvailable = 1229,
BackupInProgress = 761
}; };
}; };
......
...@@ -117,6 +117,7 @@ public: ...@@ -117,6 +117,7 @@ public:
StateBuilding = 2, ///< Building, not yet usable StateBuilding = 2, ///< Building, not yet usable
StateDropping = 3, ///< Offlining or dropping, not usable StateDropping = 3, ///< Offlining or dropping, not usable
StateOnline = 4, ///< Online, usable StateOnline = 4, ///< Online, usable
StateBackup = 5, ///< Online, being backuped, usable
StateBroken = 9 ///< Broken, should be dropped and re-created StateBroken = 9 ///< Broken, should be dropped and re-created
}; };
......
...@@ -921,7 +921,6 @@ Backup::execUTIL_SEQUENCE_REF(Signal* signal) ...@@ -921,7 +921,6 @@ Backup::execUTIL_SEQUENCE_REF(Signal* signal)
jamEntry(); jamEntry();
UtilSequenceRef * utilRef = (UtilSequenceRef*)signal->getDataPtr(); UtilSequenceRef * utilRef = (UtilSequenceRef*)signal->getDataPtr();
ptr.i = utilRef->senderData; ptr.i = utilRef->senderData;
ndbrequire(ptr.i == RNIL);
c_backupPool.getPtr(ptr); c_backupPool.getPtr(ptr);
ndbrequire(ptr.p->masterData.gsn == GSN_UTIL_SEQUENCE_REQ); ndbrequire(ptr.p->masterData.gsn == GSN_UTIL_SEQUENCE_REQ);
sendBackupRef(signal, ptr, BackupRef::SequenceFailure); sendBackupRef(signal, ptr, BackupRef::SequenceFailure);
...@@ -2418,10 +2417,16 @@ Backup::execLIST_TABLES_CONF(Signal* signal) ...@@ -2418,10 +2417,16 @@ Backup::execLIST_TABLES_CONF(Signal* signal)
jam(); jam();
Uint32 tableId = ListTablesConf::getTableId(conf->tableData[i]); Uint32 tableId = ListTablesConf::getTableId(conf->tableData[i]);
Uint32 tableType = ListTablesConf::getTableType(conf->tableData[i]); Uint32 tableType = ListTablesConf::getTableType(conf->tableData[i]);
Uint32 state= ListTablesConf::getTableState(conf->tableData[i]);
if (!DictTabInfo::isTable(tableType) && !DictTabInfo::isIndex(tableType)){ if (!DictTabInfo::isTable(tableType) && !DictTabInfo::isIndex(tableType)){
jam(); jam();
continue; continue;
}//if }//if
if (state != DictTabInfo::StateOnline)
{
jam();
continue;
}//if
TablePtr tabPtr; TablePtr tabPtr;
ptr.p->tables.seize(tabPtr); ptr.p->tables.seize(tabPtr);
if(tabPtr.i == RNIL) { if(tabPtr.i == RNIL) {
...@@ -2791,9 +2796,18 @@ Backup::execGET_TABINFO_CONF(Signal* signal) ...@@ -2791,9 +2796,18 @@ Backup::execGET_TABINFO_CONF(Signal* signal)
TablePtr tmp = tabPtr; TablePtr tmp = tabPtr;
ptr.p->tables.next(tabPtr); ptr.p->tables.next(tabPtr);
if(DictTabInfo::isIndex(tmp.p->tableType)){ if(DictTabInfo::isIndex(tmp.p->tableType))
{
jam();
ptr.p->tables.release(tmp); ptr.p->tables.release(tmp);
} }
else
{
jam();
signal->theData[0] = tmp.p->tableId;
signal->theData[1] = 1; // lock
EXECUTE_DIRECT(DBDICT, GSN_BACKUP_FRAGMENT_REQ, signal, 2);
}
if(tabPtr.i == RNIL) { if(tabPtr.i == RNIL) {
jam(); jam();
...@@ -3575,7 +3589,7 @@ Backup::backupFragmentRef(Signal * signal, BackupFilePtr filePtr) ...@@ -3575,7 +3589,7 @@ Backup::backupFragmentRef(Signal * signal, BackupFilePtr filePtr)
ref->backupId = ptr.p->backupId; ref->backupId = ptr.p->backupId;
ref->backupPtr = ptr.i; ref->backupPtr = ptr.i;
ref->nodeId = getOwnNodeId(); ref->nodeId = getOwnNodeId();
ref->errorCode = ptr.p->errorCode; ref->errorCode = filePtr.p->errorCode;
sendSignal(ptr.p->masterRef, GSN_BACKUP_FRAGMENT_REF, signal, sendSignal(ptr.p->masterRef, GSN_BACKUP_FRAGMENT_REF, signal,
BackupFragmentRef::SignalLength, JBB); BackupFragmentRef::SignalLength, JBB);
} }
...@@ -3836,6 +3850,8 @@ Backup::execTRIG_ATTRINFO(Signal* signal) { ...@@ -3836,6 +3850,8 @@ Backup::execTRIG_ATTRINFO(Signal* signal) {
!buf.getWritePtr(&dst, trigPtr.p->maxRecordSize)) !buf.getWritePtr(&dst, trigPtr.p->maxRecordSize))
{ {
jam(); jam();
Uint32 save[TrigAttrInfo::StaticLength];
memcpy(save, signal->getDataPtr(), 4*TrigAttrInfo::StaticLength);
BackupRecordPtr ptr; BackupRecordPtr ptr;
c_backupPool.getPtr(ptr, trigPtr.p->backupPtr); c_backupPool.getPtr(ptr, trigPtr.p->backupPtr);
trigPtr.p->errorCode = AbortBackupOrd::LogBufferFull; trigPtr.p->errorCode = AbortBackupOrd::LogBufferFull;
...@@ -3846,6 +3862,8 @@ Backup::execTRIG_ATTRINFO(Signal* signal) { ...@@ -3846,6 +3862,8 @@ Backup::execTRIG_ATTRINFO(Signal* signal) {
ord->senderData= ptr.i; ord->senderData= ptr.i;
sendSignal(ptr.p->masterRef, GSN_ABORT_BACKUP_ORD, signal, sendSignal(ptr.p->masterRef, GSN_ABORT_BACKUP_ORD, signal,
AbortBackupOrd::SignalLength, JBB); AbortBackupOrd::SignalLength, JBB);
memcpy(signal->getDataPtrSend(), save, 4*TrigAttrInfo::StaticLength);
return; return;
}//if }//if
...@@ -3996,6 +4014,17 @@ Backup::execSTOP_BACKUP_REQ(Signal* signal) ...@@ -3996,6 +4014,17 @@ Backup::execSTOP_BACKUP_REQ(Signal* signal)
filePtr.p->operation.dataBuffer.updateWritePtr(gcpSz); filePtr.p->operation.dataBuffer.updateWritePtr(gcpSz);
} }
{
TablePtr tabPtr;
for(ptr.p->tables.first(tabPtr); tabPtr.i != RNIL;
ptr.p->tables.next(tabPtr))
{
signal->theData[0] = tabPtr.p->tableId;
signal->theData[1] = 0; // unlock
EXECUTE_DIRECT(DBDICT, GSN_BACKUP_FRAGMENT_REQ, signal, 2);
}
}
closeFiles(signal, ptr); closeFiles(signal, ptr);
} }
...@@ -4338,6 +4367,11 @@ Backup::cleanup(Signal* signal, BackupRecordPtr ptr) ...@@ -4338,6 +4367,11 @@ Backup::cleanup(Signal* signal, BackupRecordPtr ptr)
}//if }//if
tabPtr.p->triggerIds[j] = ILLEGAL_TRIGGER_ID; tabPtr.p->triggerIds[j] = ILLEGAL_TRIGGER_ID;
}//for }//for
{
signal->theData[0] = tabPtr.p->tableId;
signal->theData[1] = 0; // unlock
EXECUTE_DIRECT(DBDICT, GSN_BACKUP_FRAGMENT_REQ, signal, 2);
}
}//for }//for
BackupFilePtr filePtr; BackupFilePtr filePtr;
...@@ -4352,9 +4386,6 @@ Backup::cleanup(Signal* signal, BackupRecordPtr ptr) ...@@ -4352,9 +4386,6 @@ Backup::cleanup(Signal* signal, BackupRecordPtr ptr)
}//for }//for
ptr.p->files.release(); ptr.p->files.release();
ptr.p->tables.release();
ptr.p->triggers.release();
ptr.p->tables.release(); ptr.p->tables.release();
ptr.p->triggers.release(); ptr.p->triggers.release();
ptr.p->pages.release(); ptr.p->pages.release();
......
...@@ -4845,7 +4845,24 @@ Uint32 Dbacc::executeNextOperation(Signal* signal) ...@@ -4845,7 +4845,24 @@ Uint32 Dbacc::executeNextOperation(Signal* signal)
sendSignal(operationRecPtr.p->userblockref, GSN_ACCKEYREF, signal, 2, JBB); sendSignal(operationRecPtr.p->userblockref, GSN_ACCKEYREF, signal, 2, JBB);
return operationRecPtr.p->elementIsDisappeared; return operationRecPtr.p->elementIsDisappeared;
}//if }//if
}//if }
else if(operationRecPtr.p->operation == ZWRITE)
{
jam();
operationRecPtr.p->operation = ZINSERT;
if (operationRecPtr.p->prevParallelQue != RNIL) {
OperationrecPtr prevOpPtr;
jam();
prevOpPtr.i = operationRecPtr.p->prevParallelQue;
ptrCheckGuard(prevOpPtr, coprecsize, operationrec);
if (prevOpPtr.p->operation != ZDELETE)
{
jam();
operationRecPtr.p->operation = ZUPDATE;
}
}
}
if (operationRecPtr.p->operation == ZSCAN_OP && if (operationRecPtr.p->operation == ZSCAN_OP &&
! operationRecPtr.p->isAccLockReq) { ! operationRecPtr.p->isAccLockReq) {
jam(); jam();
......
This diff is collapsed.
...@@ -150,8 +150,6 @@ public: ...@@ -150,8 +150,6 @@ public:
/** Pointer to last attribute in table */ /** Pointer to last attribute in table */
Uint32 lastAttribute; Uint32 lastAttribute;
/* Temporary record used during add/drop table */
Uint32 myConnect;
#ifdef HAVE_TABLE_REORG #ifdef HAVE_TABLE_REORG
/* Second table used by this table (for table reorg) */ /* Second table used by this table (for table reorg) */
Uint32 secondTable; Uint32 secondTable;
...@@ -175,7 +173,8 @@ public: ...@@ -175,7 +173,8 @@ public:
CHECKED = 3, CHECKED = 3,
DEFINED = 4, DEFINED = 4,
PREPARE_DROPPING = 5, PREPARE_DROPPING = 5,
DROPPING = 6 DROPPING = 6,
BACKUP_ONGOING = 7
}; };
TabState tabState; TabState tabState;
...@@ -511,6 +510,8 @@ private: ...@@ -511,6 +510,8 @@ private:
void execBUILDINDXCONF(Signal* signal); void execBUILDINDXCONF(Signal* signal);
void execBUILDINDXREF(Signal* signal); void execBUILDINDXREF(Signal* signal);
void execBACKUP_FRAGMENT_REQ(Signal*);
// Util signals used by Event code // Util signals used by Event code
void execUTIL_PREPARE_CONF(Signal* signal); void execUTIL_PREPARE_CONF(Signal* signal);
void execUTIL_PREPARE_REF (Signal* signal); void execUTIL_PREPARE_REF (Signal* signal);
...@@ -926,6 +927,8 @@ private: ...@@ -926,6 +927,8 @@ private:
Uint32 m_errorCode; Uint32 m_errorCode;
void setErrorCode(Uint32 c){ if(m_errorCode == 0) m_errorCode = c;} void setErrorCode(Uint32 c){ if(m_errorCode == 0) m_errorCode = c;}
MutexHandle2<BACKUP_DEFINE_MUTEX> m_define_backup_mutex;
/** /**
* When sending stuff around * When sending stuff around
*/ */
...@@ -1942,6 +1945,7 @@ private: ...@@ -1942,6 +1945,7 @@ private:
bool getIsFailed(Uint32 nodeId) const; bool getIsFailed(Uint32 nodeId) const;
void dropTable_backup_mutex_locked(Signal* signal, Uint32, Uint32);
void dropTableRef(Signal * signal, DropTableReq *, DropTableRef::ErrorCode); void dropTableRef(Signal * signal, DropTableReq *, DropTableRef::ErrorCode);
void printTables(); // For debugging only void printTables(); // For debugging only
int handleAlterTab(AlterTabReq * req, int handleAlterTab(AlterTabReq * req,
...@@ -1952,6 +1956,7 @@ private: ...@@ -1952,6 +1956,7 @@ private:
Uint32 changeMask, Uint32 changeMask,
Uint32 tableId, Uint32 tableId,
CreateTableRecord * regAlterTabPtr); CreateTableRecord * regAlterTabPtr);
void alterTable_backup_mutex_locked(Signal* signal, Uint32, Uint32);
void alterTableRef(Signal * signal, void alterTableRef(Signal * signal,
AlterTableReq *, AlterTableRef::ErrorCode, AlterTableReq *, AlterTableRef::ErrorCode,
ParseDictTabInfoRecord* parseRecord = NULL); ParseDictTabInfoRecord* parseRecord = NULL);
......
...@@ -230,7 +230,9 @@ AsyncFile::run() ...@@ -230,7 +230,9 @@ AsyncFile::run()
}//switch }//switch
m_last_request= request; m_last_request= request;
m_current_request= 0; m_current_request= 0;
theReportTo->writeChannel(request);
// No need to signal as ndbfs only uses tryRead
theReportTo->writeChannelNoSignal(request);
}//while }//while
}//AsyncFile::run() }//AsyncFile::run()
......
...@@ -84,7 +84,8 @@ public: ...@@ -84,7 +84,8 @@ public:
MemoryChannel( int size= 256); MemoryChannel( int size= 256);
virtual ~MemoryChannel( ); virtual ~MemoryChannel( );
virtual void writeChannel( T *t); void writeChannel( T *t);
void writeChannelNoSignal( T *t);
T* readChannel(); T* readChannel();
T* tryReadChannel(); T* tryReadChannel();
...@@ -139,6 +140,15 @@ template <class T> void MemoryChannel<T>::writeChannel( T *t) ...@@ -139,6 +140,15 @@ template <class T> void MemoryChannel<T>::writeChannel( T *t)
NdbCondition_Signal(theConditionPtr); NdbCondition_Signal(theConditionPtr);
} }
template <class T> void MemoryChannel<T>::writeChannelNoSignal( T *t)
{
NdbMutex_Lock(theMutexPtr);
if(full(theWriteIndex, theReadIndex) || theChannel == NULL) abort();
theChannel[theWriteIndex]= t;
++theWriteIndex;
NdbMutex_Unlock(theMutexPtr);
}
template <class T> T* MemoryChannel<T>::readChannel() template <class T> T* MemoryChannel<T>::readChannel()
{ {
...@@ -161,8 +171,6 @@ template <class T> T* MemoryChannel<T>::tryReadChannel() ...@@ -161,8 +171,6 @@ template <class T> T* MemoryChannel<T>::tryReadChannel()
{ {
T* tmp= 0; T* tmp= 0;
NdbMutex_Lock(theMutexPtr); NdbMutex_Lock(theMutexPtr);
NdbCondition_WaitTimeout(theConditionPtr,
theMutexPtr, 0);
if ( !empty(theWriteIndex, theReadIndex) ) if ( !empty(theWriteIndex, theReadIndex) )
{ {
tmp= theChannel[theReadIndex]; tmp= theChannel[theReadIndex];
......
...@@ -1244,6 +1244,7 @@ objectStateMapping[] = { ...@@ -1244,6 +1244,7 @@ objectStateMapping[] = {
{ DictTabInfo::StateBuilding, NdbDictionary::Object::StateBuilding }, { DictTabInfo::StateBuilding, NdbDictionary::Object::StateBuilding },
{ DictTabInfo::StateDropping, NdbDictionary::Object::StateDropping }, { DictTabInfo::StateDropping, NdbDictionary::Object::StateDropping },
{ DictTabInfo::StateOnline, NdbDictionary::Object::StateOnline }, { DictTabInfo::StateOnline, NdbDictionary::Object::StateOnline },
{ DictTabInfo::StateBackup, NdbDictionary::Object::StateBackup },
{ DictTabInfo::StateBroken, NdbDictionary::Object::StateBroken }, { DictTabInfo::StateBroken, NdbDictionary::Object::StateBroken },
{ -1, -1 } { -1, -1 }
}; };
......
...@@ -344,6 +344,8 @@ ErrorBundle ErrorCodes[] = { ...@@ -344,6 +344,8 @@ ErrorBundle ErrorCodes[] = {
{ 743, SE, "Unsupported character set in table or index" }, { 743, SE, "Unsupported character set in table or index" },
{ 744, SE, "Character string is invalid for given character set" }, { 744, SE, "Character string is invalid for given character set" },
{ 745, SE, "Distribution key not supported for char attribute (use binary attribute)" }, { 745, SE, "Distribution key not supported for char attribute (use binary attribute)" },
{ 761, SE, "Unable to drop table as backup is in progress" },
{ 762, SE, "Unable to alter table as backup is in progress" },
{ 241, SE, "Invalid schema object version" }, { 241, SE, "Invalid schema object version" },
{ 283, SE, "Table is being dropped" }, { 283, SE, "Table is being dropped" },
{ 284, SE, "Table not defined in transaction coordinator" }, { 284, SE, "Table not defined in transaction coordinator" },
......
...@@ -41,6 +41,11 @@ public: ...@@ -41,6 +41,11 @@ public:
int numRecords = 1, int numRecords = 1,
int updatesValue = 0); int updatesValue = 0);
int pkWriteRecord(Ndb*,
int recordNo,
int numRecords = 1,
int updatesValue = 0);
int pkReadRecord(Ndb*, int pkReadRecord(Ndb*,
int recordNo, int recordNo,
int numRecords = 1, int numRecords = 1,
...@@ -97,6 +102,10 @@ public: ...@@ -97,6 +102,10 @@ public:
NdbIndexScanOperation* pIndexScanOp; NdbIndexScanOperation* pIndexScanOp;
NDBT_ResultRow& get_row(Uint32 idx) { return *rows[idx];} NDBT_ResultRow& get_row(Uint32 idx) { return *rows[idx];}
int execute_async(Ndb*, ExecType, AbortOption = AbortOnError);
int wait_async(Ndb*, int timeout = -1);
protected: protected:
void allocRows(int rows); void allocRows(int rows);
void deallocRows(); void deallocRows();
...@@ -109,6 +118,11 @@ protected: ...@@ -109,6 +118,11 @@ protected:
struct RsPair { NdbScanOperation* m_result_set; int records; }; struct RsPair { NdbScanOperation* m_result_set; int records; };
Vector<RsPair> m_result_sets; Vector<RsPair> m_result_sets;
Vector<RsPair> m_executed_result_sets; Vector<RsPair> m_executed_result_sets;
int m_async_reply;
int m_async_return;
friend void HugoOperations_async_callback(int, NdbConnection*, void*);
void callback(int res, NdbConnection*);
}; };
#endif #endif
...@@ -138,6 +138,61 @@ int runBackupOne(NDBT_Context* ctx, NDBT_Step* step){ ...@@ -138,6 +138,61 @@ int runBackupOne(NDBT_Context* ctx, NDBT_Step* step){
return NDBT_OK; return NDBT_OK;
} }
int
runBackupLoop(NDBT_Context* ctx, NDBT_Step* step){
NdbBackup backup(GETNDB(step)->getNodeId()+1);
unsigned backupId = 0;
int loops = ctx->getNumLoops();
while(!ctx->isTestStopped() && loops--)
{
if (backup.start(backupId) == -1)
{
sleep(1);
loops++;
}
else
{
sleep(3);
}
}
ctx->stopTest();
return NDBT_OK;
}
int
runDDL(NDBT_Context* ctx, NDBT_Step* step){
Ndb* pNdb= GETNDB(step);
NdbDictionary::Dictionary* pDict = pNdb->getDictionary();
const int tables = NDBT_Tables::getNumTables();
while(!ctx->isTestStopped())
{
const int tab_no = rand() % (tables);
NdbDictionary::Table tab = *NDBT_Tables::getTable(tab_no);
BaseString name= tab.getName();
name.appfmt("-%d", step->getStepNo());
tab.setName(name.c_str());
if(pDict->createTable(tab) == 0)
{
HugoTransactions hugoTrans(* pDict->getTable(name.c_str()));
if (hugoTrans.loadTable(pNdb, 10000) != 0){
return NDBT_FAILED;
}
while(pDict->dropTable(tab.getName()) != 0 &&
pDict->getNdbError().code != 4009)
g_err << pDict->getNdbError() << endl;
sleep(1);
}
}
return NDBT_OK;
}
int runRestartInitial(NDBT_Context* ctx, NDBT_Step* step){ int runRestartInitial(NDBT_Context* ctx, NDBT_Step* step){
NdbRestarter restarter; NdbRestarter restarter;
...@@ -417,6 +472,15 @@ TESTCASE("BackupOne", ...@@ -417,6 +472,15 @@ TESTCASE("BackupOne",
VERIFIER(runVerifyOne); VERIFIER(runVerifyOne);
FINALIZER(runClearTable); FINALIZER(runClearTable);
} }
TESTCASE("BackupDDL",
"Test that backup and restore works on with DDL ongoing\n"
"1. Backups and DDL (create,drop,table.index)"){
INITIALIZER(runLoadTable);
STEP(runBackupLoop);
STEP(runDDL);
STEP(runDDL);
FINALIZER(runClearTable);
}
TESTCASE("BackupBank", TESTCASE("BackupBank",
"Test that backup and restore works during transaction load\n" "Test that backup and restore works during transaction load\n"
" by backing up the bank" " by backing up the bank"
......
...@@ -1037,6 +1037,8 @@ int runCheckGetNdbErrorOperation(NDBT_Context* ctx, NDBT_Step* step){ ...@@ -1037,6 +1037,8 @@ int runCheckGetNdbErrorOperation(NDBT_Context* ctx, NDBT_Step* step){
return result; return result;
} }
#define C2(x) { int _x= (x); if(_x == 0) return NDBT_FAILED; }
int runBug_11133(NDBT_Context* ctx, NDBT_Step* step){ int runBug_11133(NDBT_Context* ctx, NDBT_Step* step){
int result = NDBT_OK; int result = NDBT_OK;
const NdbDictionary::Table* pTab = ctx->getTab(); const NdbDictionary::Table* pTab = ctx->getTab();
...@@ -1044,227 +1046,75 @@ int runBug_11133(NDBT_Context* ctx, NDBT_Step* step){ ...@@ -1044,227 +1046,75 @@ int runBug_11133(NDBT_Context* ctx, NDBT_Step* step){
HugoOperations hugoOps(*pTab); HugoOperations hugoOps(*pTab);
Ndb* pNdb = GETNDB(step); Ndb* pNdb = GETNDB(step);
Uint32 lm;
NdbConnection* pCon = pNdb->startTransaction();
if (pCon == NULL){
pNdb->closeTransaction(pCon);
return NDBT_FAILED;
}
NdbOperation* pOp = pCon->getNdbOperation(pTab->getName());
if (pOp == NULL){
ERR(pCon->getNdbError());
pNdb->closeTransaction(pCon);
return NDBT_FAILED;
}
if (pOp->readTuple(NdbOperation::LM_Exclusive) != 0){
pNdb->closeTransaction(pCon);
ERR(pOp->getNdbError());
return NDBT_FAILED;
}
for(int a = 0; a<pTab->getNoOfColumns(); a++){
if (pTab->getColumn(a)->getPrimaryKey() == true){
if(hugoOps.equalForAttr(pOp, a, 1) != 0){
ERR(pCon->getNdbError());
pNdb->closeTransaction(pCon);
return NDBT_FAILED;
}
}
}
for(int a = 0; a<pTab->getNoOfColumns(); a++){
if (pTab->getColumn(a)->getPrimaryKey() != true){
if (pOp->getValue(pTab->getColumn(a)->getName()) == NULL) {
ERR(pCon->getNdbError());
pNdb->closeTransaction(pCon);
return NDBT_FAILED;
}
}
}
int check = pCon->execute(NoCommit);
if (check == 0){
ndbout << "execute worked" << endl;
} else {
ERR(pCon->getNdbError());
result = NDBT_FAILED;
}
pOp = pCon->getNdbOperation(pTab->getName());
if (pOp == NULL){
ERR(pCon->getNdbError());
pNdb->closeTransaction(pCon);
return NDBT_FAILED;
}
if (pOp->deleteTuple() != 0){
pNdb->closeTransaction(pCon);
ERR(pOp->getNdbError());
return NDBT_FAILED;
}
for(int a = 0; a<pTab->getNoOfColumns(); a++){
if (pTab->getColumn(a)->getPrimaryKey() == true){
if(hugoOps.equalForAttr(pOp, a, 1) != 0){
ERR(pCon->getNdbError());
pNdb->closeTransaction(pCon);
return NDBT_FAILED;
}
}
}
check = pCon->execute(NoCommit);
if (check == 0){
ndbout << "execute worked" << endl;
} else {
ERR(pCon->getNdbError());
result = NDBT_FAILED;
}
pOp = pCon->getNdbOperation(pTab->getName());
if (pOp == NULL){
ERR(pCon->getNdbError());
pNdb->closeTransaction(pCon);
return NDBT_FAILED;
}
if (pOp->writeTuple() != 0){ C2(hugoOps.startTransaction(pNdb) == 0);
pNdb->closeTransaction(pCon); C2(hugoOps.pkInsertRecord(pNdb, 0, 1) == 0);
ERR(pOp->getNdbError()); C2(hugoOps.execute_NoCommit(pNdb) == 0);
return NDBT_FAILED; C2(hugoOps.pkDeleteRecord(pNdb, 0, 1) == 0);
} C2(hugoOps.execute_NoCommit(pNdb) == 0);
C2(hugoOps.pkWriteRecord(pNdb, 0, 1) == 0);
for(int a = 0; a<pTab->getNoOfColumns(); a++){ C2(hugoOps.execute_NoCommit(pNdb) == 0);
if (pTab->getColumn(a)->getPrimaryKey() == true){ C2(hugoOps.pkWriteRecord(pNdb, 0, 1) == 0);
if(hugoOps.equalForAttr(pOp, a, 1) != 0){ C2(hugoOps.execute_NoCommit(pNdb) == 0);
ERR(pCon->getNdbError()); C2(hugoOps.pkDeleteRecord(pNdb, 0, 1) == 0);
pNdb->closeTransaction(pCon); C2(hugoOps.execute_Commit(pNdb) == 0);
return NDBT_FAILED; C2(hugoOps.closeTransaction(pNdb) == 0);
}
} C2(hugoOps.startTransaction(pNdb) == 0);
} C2(hugoOps.pkInsertRecord(pNdb, 0, 1) == 0);
C2(hugoOps.execute_NoCommit(pNdb) == 0);
for(int a = 0; a<pTab->getNoOfColumns(); a++){ C2(hugoOps.pkWriteRecord(pNdb, 0, 1) == 0);
if (pTab->getColumn(a)->getPrimaryKey() != true){ C2(hugoOps.execute_NoCommit(pNdb) == 0);
if(hugoOps.setValueForAttr(pOp, a, 1, 1) != 0) C2(hugoOps.pkWriteRecord(pNdb, 0, 1) == 0);
{ C2(hugoOps.execute_NoCommit(pNdb) == 0);
ERR(pCon->getNdbError()); C2(hugoOps.pkDeleteRecord(pNdb, 0, 1) == 0);
pNdb->closeTransaction(pCon); C2(hugoOps.execute_Commit(pNdb) == 0);
return NDBT_FAILED; C2(hugoOps.closeTransaction(pNdb) == 0);
}
} C2(hugoOps.startTransaction(pNdb) == 0);
} C2(hugoOps.pkInsertRecord(pNdb, 0, 1) == 0);
C2(hugoOps.execute_Commit(pNdb) == 0);
check = pCon->execute(NoCommit); C2(hugoOps.closeTransaction(pNdb) == 0);
if (check == 0){
ndbout << "execute worked" << endl; C2(hugoOps.startTransaction(pNdb) == 0);
} else { C2(hugoOps.pkReadRecord(pNdb, 0, 1, NdbOperation::LM_Exclusive) == 0);
ERR(pCon->getNdbError()); C2(hugoOps.execute_NoCommit(pNdb) == 0);
result = NDBT_FAILED; C2(hugoOps.pkDeleteRecord(pNdb, 0, 1) == 0);
} C2(hugoOps.execute_NoCommit(pNdb) == 0);
C2(hugoOps.pkWriteRecord(pNdb, 0, 1) == 0);
pOp = pCon->getNdbOperation(pTab->getName()); C2(hugoOps.execute_NoCommit(pNdb) == 0);
if (pOp == NULL){ C2(hugoOps.pkWriteRecord(pNdb, 0, 1) == 0);
ERR(pCon->getNdbError()); C2(hugoOps.execute_NoCommit(pNdb) == 0);
pNdb->closeTransaction(pCon); C2(hugoOps.pkDeleteRecord(pNdb, 0, 1) == 0);
return NDBT_FAILED; C2(hugoOps.execute_Commit(pNdb) == 0);
} C2(hugoOps.closeTransaction(pNdb) == 0);
if (pOp->writeTuple() != 0){ Ndb ndb2("TEST_DB");
pNdb->closeTransaction(pCon); C2(ndb2.init() == 0);
ERR(pOp->getNdbError()); C2(ndb2.waitUntilReady() == 0);
return NDBT_FAILED; HugoOperations hugoOps2(*pTab);
}
C2(hugoOps.startTransaction(pNdb) == 0);
for(int a = 0; a<pTab->getNoOfColumns(); a++){ C2(hugoOps.pkInsertRecord(pNdb, 0, 1) == 0);
if (pTab->getColumn(a)->getPrimaryKey() == true){ C2(hugoOps.execute_NoCommit(pNdb) == 0);
if(hugoOps.equalForAttr(pOp, a, 1) != 0){ C2(hugoOps2.startTransaction(&ndb2) == 0);
ERR(pCon->getNdbError()); C2(hugoOps2.pkWriteRecord(&ndb2, 0, 1) == 0);
pNdb->closeTransaction(pCon); C2(hugoOps2.execute_async(&ndb2, NoCommit) == 0);
return NDBT_FAILED; C2(hugoOps.execute_Commit(pNdb) == 0);
} C2(hugoOps2.wait_async(&ndb2) == 0);
} C2(hugoOps.closeTransaction(pNdb) == 0);
} C2(hugoOps2.closeTransaction(&ndb2) == 0);
for(int a = 0; a<pTab->getNoOfColumns(); a++){ C2(hugoOps.startTransaction(pNdb) == 0);
if (pTab->getColumn(a)->getPrimaryKey() != true){ C2(hugoOps.pkDeleteRecord(pNdb, 0, 1) == 0);
if(hugoOps.setValueForAttr(pOp, a, 1, 1) != 0) C2(hugoOps.execute_NoCommit(pNdb) == 0);
{ C2(hugoOps2.startTransaction(&ndb2) == 0);
ERR(pCon->getNdbError()); C2(hugoOps2.pkWriteRecord(&ndb2, 0, 1) == 0);
pNdb->closeTransaction(pCon); C2(hugoOps2.execute_async(&ndb2, NoCommit) == 0);
return NDBT_FAILED; C2(hugoOps.execute_Commit(pNdb) == 0);
} C2(hugoOps2.wait_async(&ndb2) == 0);
} C2(hugoOps.closeTransaction(pNdb) == 0);
} C2(hugoOps2.closeTransaction(&ndb2) == 0);
check = pCon->execute(NoCommit);
if (check == 0){
ndbout << "execute worked" << endl;
} else {
ERR(pCon->getNdbError());
result = NDBT_FAILED;
}
check = pCon->execute(Rollback);
if (check == 0){
ndbout << "execute worked" << endl;
} else {
ERR(pCon->getNdbError());
result = NDBT_FAILED;
}
pCon->close();
pCon = pNdb->startTransaction();
if (pCon == NULL){
pNdb->closeTransaction(pCon);
return NDBT_FAILED;
}
pOp = pCon->getNdbOperation(pTab->getName());
if (pOp == NULL){
ERR(pCon->getNdbError());
pNdb->closeTransaction(pCon);
return NDBT_FAILED;
}
if (pOp->writeTuple() != 0){
pNdb->closeTransaction(pCon);
ERR(pOp->getNdbError());
return NDBT_FAILED;
}
for(int a = 0; a<pTab->getNoOfColumns(); a++){
if (pTab->getColumn(a)->getPrimaryKey() == true){
if(hugoOps.equalForAttr(pOp, a, 1) != 0){
ERR(pCon->getNdbError());
pNdb->closeTransaction(pCon);
return NDBT_FAILED;
}
}
}
for(int a = 0; a<pTab->getNoOfColumns(); a++){
if (pTab->getColumn(a)->getPrimaryKey() != true){
if(hugoOps.setValueForAttr(pOp, a, 1, 1) != 0)
{
ERR(pCon->getNdbError());
pNdb->closeTransaction(pCon);
return NDBT_FAILED;
}
}
}
check = pCon->execute(Commit);
if (check == 0){
ndbout << "execute worked" << endl;
} else {
ERR(pCon->getNdbError());
result = NDBT_FAILED;
}
return result; return result;
} }
...@@ -1442,7 +1292,6 @@ TESTCASE("ReadWithoutGetValue", ...@@ -1442,7 +1292,6 @@ TESTCASE("ReadWithoutGetValue",
} }
TESTCASE("Bug_11133", TESTCASE("Bug_11133",
"Test ReadEx-Delete-Write\n"){ "Test ReadEx-Delete-Write\n"){
INITIALIZER(runLoadTable);
INITIALIZER(runBug_11133); INITIALIZER(runBug_11133);
FINALIZER(runClearTable); FINALIZER(runClearTable);
} }
......
...@@ -54,6 +54,10 @@ max-time: 600 ...@@ -54,6 +54,10 @@ max-time: 600
cmd: atrt-testBackup cmd: atrt-testBackup
args: -n BackupOne T1 T6 T3 I3 args: -n BackupOne T1 T6 T3 I3
max-time: 600
cmd: atrt-testBackup
args: -n BackupDDL T1
# BASIC FUNCTIONALITY # BASIC FUNCTIONALITY
max-time: 500 max-time: 500
cmd: testBasic cmd: testBasic
......
...@@ -84,7 +84,7 @@ fi ...@@ -84,7 +84,7 @@ fi
for i in $vars for i in $vars
do do
t=`echo echo \\$$i` t=`echo echo \\$$i`
if [ -z `eval $t` ] if [ -z "`eval $t`" ]
then then
echo "Invalid config: $conf, variable $i is not set" echo "Invalid config: $conf, variable $i is not set"
exit exit
...@@ -301,8 +301,8 @@ choose_conf(){ ...@@ -301,8 +301,8 @@ choose_conf(){
echo "$test_dir/conf-$1.txt" echo "$test_dir/conf-$1.txt"
else else
echo "Unable to find conf file looked for" 1>&2 echo "Unable to find conf file looked for" 1>&2
echo "$testdir/conf-$1-$HOST.txt and" 1>&2 echo "$test_dir/conf-$1-$HOST.txt and" 1>&2
echo "$testdir/conf-$1.txt" 1>&2 echo "$test_dir/conf-$1.txt" 1>&2
exit exit
fi fi
} }
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include <HugoOperations.hpp> #include <HugoOperations.hpp>
int HugoOperations::startTransaction(Ndb* pNdb){ int HugoOperations::startTransaction(Ndb* pNdb){
if (pTrans != NULL){ if (pTrans != NULL){
...@@ -226,6 +225,48 @@ int HugoOperations::pkInsertRecord(Ndb* pNdb, ...@@ -226,6 +225,48 @@ int HugoOperations::pkInsertRecord(Ndb* pNdb,
return NDBT_OK; return NDBT_OK;
} }
int HugoOperations::pkWriteRecord(Ndb* pNdb,
int recordNo,
int numRecords,
int updatesValue){
int a, check;
for(int r=0; r < numRecords; r++){
NdbOperation* pOp = pTrans->getNdbOperation(tab.getName());
if (pOp == NULL) {
ERR(pTrans->getNdbError());
return NDBT_FAILED;
}
check = pOp->writeTuple();
if( check == -1 ) {
ERR(pTrans->getNdbError());
return NDBT_FAILED;
}
// Define primary keys
for(a = 0; a<tab.getNoOfColumns(); a++){
if (tab.getColumn(a)->getPrimaryKey() == true){
if(equalForAttr(pOp, a, r+recordNo) != 0){
ERR(pTrans->getNdbError());
return NDBT_FAILED;
}
}
}
// Define attributes to update
for(a = 0; a<tab.getNoOfColumns(); a++){
if (tab.getColumn(a)->getPrimaryKey() == false){
if(setValueForAttr(pOp, a, recordNo+r, updatesValue ) != 0){
ERR(pTrans->getNdbError());
return NDBT_FAILED;
}
}
}
}
return NDBT_OK;
}
int HugoOperations::pkDeleteRecord(Ndb* pNdb, int HugoOperations::pkDeleteRecord(Ndb* pNdb,
int recordNo, int recordNo,
int numRecords){ int numRecords){
...@@ -367,16 +408,57 @@ int HugoOperations::execute_Rollback(Ndb* pNdb){ ...@@ -367,16 +408,57 @@ int HugoOperations::execute_Rollback(Ndb* pNdb){
return NDBT_OK; return NDBT_OK;
} }
HugoOperations::HugoOperations(const NdbDictionary::Table& _tab, void
const NdbDictionary::Index* idx): HugoOperations_async_callback(int res, NdbConnection* pCon, void* ho)
UtilTransactions(_tab, idx), {
((HugoOperations*)ho)->callback(res, pCon);
}
void
HugoOperations::callback(int res, NdbConnection* pCon)
{
assert(pCon == pTrans);
m_async_reply= 1;
m_async_return= res;
}
int
HugoOperations::execute_async(Ndb* pNdb, ExecType et, AbortOption eao){
m_async_reply= 0;
pTrans->executeAsynchPrepare(et,
HugoOperations_async_callback,
this,
eao);
pNdb->sendPreparedTransactions();
return NDBT_OK;
}
int
HugoOperations::wait_async(Ndb* pNdb, int timeout)
{
pNdb->pollNdb(1000);
if(m_async_reply)
{
return m_async_return;
}
ndbout_c("wait returned nothing...");
return -1;
}
HugoOperations::HugoOperations(const NdbDictionary::Table& _tab):
UtilTransactions(_tab),
calc(_tab) calc(_tab)
{ {
} }
HugoOperations::~HugoOperations(){ HugoOperations::~HugoOperations(){
deallocRows(); deallocRows();
if (pTrans != NULL){ if (pTrans != NULL)
{
pTrans->close(); pTrans->close();
pTrans = NULL; pTrans = NULL;
} }
......
...@@ -35,7 +35,7 @@ static struct my_option my_long_options[] = ...@@ -35,7 +35,7 @@ static struct my_option my_long_options[] =
static void usage() static void usage()
{ {
char desc[] = char desc[] =
"<indexname>+\n"\ "[<table> <index>]+\n"\
"This program will drop index(es) in Ndb\n"; "This program will drop index(es) in Ndb\n";
ndb_std_print_version(); ndb_std_print_version();
my_print_help(my_long_options); my_print_help(my_long_options);
...@@ -76,10 +76,10 @@ int main(int argc, char** argv){ ...@@ -76,10 +76,10 @@ int main(int argc, char** argv){
} }
int res = 0; int res = 0;
for(int i = 0; i<argc; i++){ for(int i = 0; i+1<argc; i += 2){
ndbout << "Dropping index " << argv[i] << "..."; ndbout << "Dropping index " << argv[i] << "/" << argv[i+1] << "...";
int tmp; int tmp;
if((tmp = MyNdb.getDictionary()->dropIndex(argv[i], 0)) != 0){ if((tmp = MyNdb.getDictionary()->dropIndex(argv[i+1], argv[i])) != 0){
ndbout << endl << MyNdb.getDictionary()->getNdbError() << endl; ndbout << endl << MyNdb.getDictionary()->getNdbError() << endl;
res = tmp; res = tmp;
} else { } else {
......
...@@ -131,6 +131,9 @@ list(const char * tabname, ...@@ -131,6 +131,9 @@ list(const char * tabname,
case NdbDictionary::Object::StateOnline: case NdbDictionary::Object::StateOnline:
strcpy(state, "Online"); strcpy(state, "Online");
break; break;
case NdbDictionary::Object::StateBackup:
strcpy(state, "Backup");
break;
case NdbDictionary::Object::StateBroken: case NdbDictionary::Object::StateBroken:
strcpy(state, "Broken"); strcpy(state, "Broken");
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment