Commit 0e29e5e7 authored by unknown's avatar unknown

moved AbortOption and ExecType inside NdbTransaction

and provided some backwards compat functions

parent 5499b0c5
...@@ -309,8 +309,8 @@ private: ...@@ -309,8 +309,8 @@ private:
int invokeActiveHook(); int invokeActiveHook();
// blob handle maintenance // blob handle maintenance
int atPrepare(NdbTransaction* aCon, NdbOperation* anOp, const NdbColumnImpl* aColumn); int atPrepare(NdbTransaction* aCon, NdbOperation* anOp, const NdbColumnImpl* aColumn);
int preExecute(ExecType anExecType, bool& batch); int preExecute(NdbTransaction::ExecType anExecType, bool& batch);
int postExecute(ExecType anExecType); int postExecute(NdbTransaction::ExecType anExecType);
int preCommit(); int preCommit();
int atNextResult(); int atNextResult();
// errors // errors
......
...@@ -59,10 +59,17 @@ public: ...@@ -59,10 +59,17 @@ public:
*/ */
enum LockMode { enum LockMode {
LM_Read = 0, LM_Read ///< Read with shared lock
LM_Exclusive = 1,
LM_CommittedRead = 2,
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
= 0
#endif
,LM_Exclusive ///< Read with exclusive lock
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
= 1
#endif
,LM_CommittedRead ///< Ignore locks, read last committed value
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
= 2,
LM_Dirty = 2 LM_Dirty = 2
#endif #endif
}; };
......
...@@ -42,34 +42,22 @@ class NdbBlob; ...@@ -42,34 +42,22 @@ class NdbBlob;
typedef void (* NdbAsynchCallback)(int, NdbTransaction*, void*); typedef void (* NdbAsynchCallback)(int, NdbTransaction*, void*);
#endif #endif
/** #ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
* Commit type of transaction
*/
enum AbortOption { enum AbortOption {
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL CommitIfFailFree= 0,
CommitIfFailFree = 0, TryCommit= 0,
CommitAsMuchAsPossible = 2, ///< Commit transaction with as many AbortOnError= 0,
TryCommit = 0, ///< <i>Missing explanation</i> CommitAsMuchAsPossible= 2,
#endif AO_IgnoreError= 2
AbortOnError = 0, ///< Abort transaction on failed operation
AO_IgnoreError = 2 ///< Transaction continues on failed operation
}; };
typedef AbortOption CommitType;
/**
* Execution type of transaction
*/
enum ExecType { enum ExecType {
NoExecTypeDef = -1, ///< Erroneous type (Used for debugging only) NoExecTypeDef = -1,
Prepare, ///< <i>Missing explanation</i> Prepare,
NoCommit, ///< Execute the transaction as far as it has NoCommit,
///< been defined, but do not yet commit it Commit,
Commit, ///< Execute and try to commit the transaction Rollback
Rollback ///< Rollback transaction
}; };
#endif
/** /**
* @class NdbTransaction * @class NdbTransaction
...@@ -99,17 +87,17 @@ enum ExecType { ...@@ -99,17 +87,17 @@ enum ExecType {
* before calling execute(). * before calling execute().
* *
* A call to execute() uses one out of three types of execution: * A call to execute() uses one out of three types of execution:
* -# ExecType::NoCommit Executes operations without committing them. * -# NdbTransaction::NoCommit Executes operations without committing them.
* -# ExecType::Commit Executes remaining operation and commits the * -# NdbTransaction::Commit Executes remaining operation and commits the
* complete transaction * complete transaction
* -# ExecType::Rollback Rollbacks the entire transaction. * -# NdbTransaction::Rollback Rollbacks the entire transaction.
* *
* execute() is equipped with an extra error handling parameter. * execute() is equipped with an extra error handling parameter.
* There are two alternatives: * There are two alternatives:
* -# AbortOption::AbortOnError (default). * -# NdbTransaction::AbortOnError (default).
* The transaction is aborted if there are any error during the * The transaction is aborted if there are any error during the
* execution * execution
* -# AbortOption::IgnoreError * -# NdbTransaction::AO_IgnoreError
* Continue execution of transaction even if operation fails * Continue execution of transaction even if operation fails
* *
*/ */
...@@ -141,6 +129,7 @@ enum ExecType { ...@@ -141,6 +129,7 @@ enum ExecType {
* primary key since it came along from the scanned tuple. * primary key since it came along from the scanned tuple.
* *
*/ */
class NdbTransaction class NdbTransaction
{ {
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
...@@ -154,6 +143,44 @@ class NdbTransaction ...@@ -154,6 +143,44 @@ class NdbTransaction
public: public:
/**
* Commit type of transaction
*/
enum AbortOption {
AbortOnError= ///< Abort transaction on failed operation
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
::AbortOnError
#endif
,AO_IgnoreError= ///< Transaction continues on failed operation
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
::AO_IgnoreError
#endif
};
/**
* Execution type of transaction
*/
enum ExecType {
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
NoExecTypeDef=
::NoExecTypeDef, ///< Erroneous type (Used for debugging only)
Prepare= ::Prepare, ///< <i>Missing explanation</i>
#endif
NoCommit= ///< Execute the transaction as far as it has
///< been defined, but do not yet commit it
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
::NoCommit
#endif
,Commit= ///< Execute and try to commit the transaction
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
::Commit
#endif
,Rollback ///< Rollback transaction
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
= ::Rollback
#endif
};
/** /**
* Get an NdbOperation for a table. * Get an NdbOperation for a table.
* Note that the operation has to be defined before it is executed. * Note that the operation has to be defined before it is executed.
...@@ -284,6 +311,12 @@ public: ...@@ -284,6 +311,12 @@ public:
int execute(ExecType execType, int execute(ExecType execType,
AbortOption abortOption = AbortOnError, AbortOption abortOption = AbortOnError,
int force = 0 ); int force = 0 );
#ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
int execute(::ExecType execType,
::AbortOption abortOption = ::AbortOnError,
int force = 0 )
{ return execute ((ExecType)execType,(AbortOption)abortOption,force); }
#endif
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
// to be documented later // to be documented later
...@@ -314,6 +347,14 @@ public: ...@@ -314,6 +347,14 @@ public:
NdbAsynchCallback callback, NdbAsynchCallback callback,
void* anyObject, void* anyObject,
AbortOption abortOption = AbortOnError); AbortOption abortOption = AbortOnError);
#ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
void executeAsynchPrepare(::ExecType execType,
NdbAsynchCallback callback,
void* anyObject,
::AbortOption abortOption = ::AbortOnError)
{ executeAsynchPrepare((ExecType)execType, callback, anyObject,
(AbortOption)abortOption); }
#endif
/** /**
* Prepare and send an asynchronous transaction. * Prepare and send an asynchronous transaction.
...@@ -332,6 +373,14 @@ public: ...@@ -332,6 +373,14 @@ public:
NdbAsynchCallback aCallback, NdbAsynchCallback aCallback,
void* anyObject, void* anyObject,
AbortOption abortOption = AbortOnError); AbortOption abortOption = AbortOnError);
#ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
void executeAsynch(::ExecType aTypeOfExec,
NdbAsynchCallback aCallback,
void* anyObject,
::AbortOption abortOption= ::AbortOnError)
{ executeAsynch((ExecType)aTypeOfExec, aCallback, anyObject,
(AbortOption)abortOption); }
#endif
#endif #endif
/** /**
* Refresh * Refresh
......
...@@ -875,7 +875,7 @@ NdbBlob::readParts(char* buf, Uint32 part, Uint32 count) ...@@ -875,7 +875,7 @@ NdbBlob::readParts(char* buf, Uint32 part, Uint32 count)
setErrorCode(tOp); setErrorCode(tOp);
return -1; return -1;
} }
tOp->m_abortOption = AbortOnError; tOp->m_abortOption = NdbTransaction::AbortOnError;
buf += thePartSize; buf += thePartSize;
n++; n++;
thePendingBlobOps |= (1 << NdbOperation::ReadRequest); thePendingBlobOps |= (1 << NdbOperation::ReadRequest);
...@@ -898,7 +898,7 @@ NdbBlob::insertParts(const char* buf, Uint32 part, Uint32 count) ...@@ -898,7 +898,7 @@ NdbBlob::insertParts(const char* buf, Uint32 part, Uint32 count)
setErrorCode(tOp); setErrorCode(tOp);
return -1; return -1;
} }
tOp->m_abortOption = AbortOnError; tOp->m_abortOption = NdbTransaction::AbortOnError;
buf += thePartSize; buf += thePartSize;
n++; n++;
thePendingBlobOps |= (1 << NdbOperation::InsertRequest); thePendingBlobOps |= (1 << NdbOperation::InsertRequest);
...@@ -921,7 +921,7 @@ NdbBlob::updateParts(const char* buf, Uint32 part, Uint32 count) ...@@ -921,7 +921,7 @@ NdbBlob::updateParts(const char* buf, Uint32 part, Uint32 count)
setErrorCode(tOp); setErrorCode(tOp);
return -1; return -1;
} }
tOp->m_abortOption = AbortOnError; tOp->m_abortOption = NdbTransaction::AbortOnError;
buf += thePartSize; buf += thePartSize;
n++; n++;
thePendingBlobOps |= (1 << NdbOperation::UpdateRequest); thePendingBlobOps |= (1 << NdbOperation::UpdateRequest);
...@@ -943,7 +943,7 @@ NdbBlob::deleteParts(Uint32 part, Uint32 count) ...@@ -943,7 +943,7 @@ NdbBlob::deleteParts(Uint32 part, Uint32 count)
setErrorCode(tOp); setErrorCode(tOp);
return -1; return -1;
} }
tOp->m_abortOption = AbortOnError; tOp->m_abortOption = NdbTransaction::AbortOnError;
n++; n++;
thePendingBlobOps |= (1 << NdbOperation::DeleteRequest); thePendingBlobOps |= (1 << NdbOperation::DeleteRequest);
theNdbCon->thePendingBlobOps |= (1 << NdbOperation::DeleteRequest); theNdbCon->thePendingBlobOps |= (1 << NdbOperation::DeleteRequest);
...@@ -976,11 +976,11 @@ NdbBlob::deletePartsUnknown(Uint32 part) ...@@ -976,11 +976,11 @@ NdbBlob::deletePartsUnknown(Uint32 part)
setErrorCode(tOp); setErrorCode(tOp);
return -1; return -1;
} }
tOp->m_abortOption = AO_IgnoreError; tOp->m_abortOption= NdbTransaction::AO_IgnoreError;
n++; n++;
} }
DBG("deletePartsUnknown: executeNoBlobs [in] bat=" << bat); DBG("deletePartsUnknown: executeNoBlobs [in] bat=" << bat);
if (theNdbCon->executeNoBlobs(NoCommit) == -1) if (theNdbCon->executeNoBlobs(NdbTransaction::NoCommit) == -1)
return -1; return -1;
DBG("deletePartsUnknown: executeNoBlobs [out]"); DBG("deletePartsUnknown: executeNoBlobs [out]");
n = 0; n = 0;
...@@ -1012,7 +1012,7 @@ NdbBlob::executePendingBlobReads() ...@@ -1012,7 +1012,7 @@ NdbBlob::executePendingBlobReads()
Uint8 flags = (1 << NdbOperation::ReadRequest); Uint8 flags = (1 << NdbOperation::ReadRequest);
if (thePendingBlobOps & flags) { if (thePendingBlobOps & flags) {
DBG("executePendingBlobReads: executeNoBlobs [in]"); DBG("executePendingBlobReads: executeNoBlobs [in]");
if (theNdbCon->executeNoBlobs(NoCommit) == -1) if (theNdbCon->executeNoBlobs(NdbTransaction::NoCommit) == -1)
return -1; return -1;
DBG("executePendingBlobReads: executeNoBlobs [out]"); DBG("executePendingBlobReads: executeNoBlobs [out]");
thePendingBlobOps = 0; thePendingBlobOps = 0;
...@@ -1027,7 +1027,7 @@ NdbBlob::executePendingBlobWrites() ...@@ -1027,7 +1027,7 @@ NdbBlob::executePendingBlobWrites()
Uint8 flags = 0xFF & ~(1 << NdbOperation::ReadRequest); Uint8 flags = 0xFF & ~(1 << NdbOperation::ReadRequest);
if (thePendingBlobOps & flags) { if (thePendingBlobOps & flags) {
DBG("executePendingBlobWrites: executeNoBlobs [in]"); DBG("executePendingBlobWrites: executeNoBlobs [in]");
if (theNdbCon->executeNoBlobs(NoCommit) == -1) if (theNdbCon->executeNoBlobs(NdbTransaction::NoCommit) == -1)
return -1; return -1;
DBG("executePendingBlobWrites: executeNoBlobs [out]"); DBG("executePendingBlobWrites: executeNoBlobs [out]");
thePendingBlobOps = 0; thePendingBlobOps = 0;
...@@ -1175,7 +1175,7 @@ NdbBlob::atPrepare(NdbTransaction* aCon, NdbOperation* anOp, const NdbColumnImpl ...@@ -1175,7 +1175,7 @@ NdbBlob::atPrepare(NdbTransaction* aCon, NdbOperation* anOp, const NdbColumnImpl
* back after postExecute. * back after postExecute.
*/ */
int int
NdbBlob::preExecute(ExecType anExecType, bool& batch) NdbBlob::preExecute(NdbTransaction::ExecType anExecType, bool& batch)
{ {
DBG("preExecute [in]"); DBG("preExecute [in]");
if (theState == Invalid) if (theState == Invalid)
...@@ -1224,7 +1224,7 @@ NdbBlob::preExecute(ExecType anExecType, bool& batch) ...@@ -1224,7 +1224,7 @@ NdbBlob::preExecute(ExecType anExecType, bool& batch)
return -1; return -1;
} }
if (isWriteOp()) { if (isWriteOp()) {
tOp->m_abortOption = AO_IgnoreError; tOp->m_abortOption = NdbTransaction::AO_IgnoreError;
} }
theHeadInlineReadOp = tOp; theHeadInlineReadOp = tOp;
// execute immediately // execute immediately
...@@ -1270,7 +1270,7 @@ NdbBlob::preExecute(ExecType anExecType, bool& batch) ...@@ -1270,7 +1270,7 @@ NdbBlob::preExecute(ExecType anExecType, bool& batch)
return -1; return -1;
} }
if (isWriteOp()) { if (isWriteOp()) {
tOp->m_abortOption = AO_IgnoreError; tOp->m_abortOption = NdbTransaction::AO_IgnoreError;
} }
theHeadInlineReadOp = tOp; theHeadInlineReadOp = tOp;
// execute immediately // execute immediately
...@@ -1316,18 +1316,18 @@ NdbBlob::preExecute(ExecType anExecType, bool& batch) ...@@ -1316,18 +1316,18 @@ NdbBlob::preExecute(ExecType anExecType, bool& batch)
* any remaining prepared operations. * any remaining prepared operations.
*/ */
int int
NdbBlob::postExecute(ExecType anExecType) NdbBlob::postExecute(NdbTransaction::ExecType anExecType)
{ {
DBG("postExecute [in] type=" << anExecType); DBG("postExecute [in] type=" << anExecType);
if (theState == Invalid) if (theState == Invalid)
return -1; return -1;
if (theState == Active) { if (theState == Active) {
setState(anExecType == NoCommit ? Active : Closed); setState(anExecType == NdbTransaction::NoCommit ? Active : Closed);
DBG("postExecute [skip]"); DBG("postExecute [skip]");
return 0; return 0;
} }
assert(theState == Prepared); assert(theState == Prepared);
setState(anExecType == NoCommit ? Active : Closed); setState(anExecType == NdbTransaction::NoCommit ? Active : Closed);
assert(isKeyOp()); assert(isKeyOp());
if (isIndexOp()) { if (isIndexOp()) {
NdbBlob* tFirstBlob = theNdbOp->theBlobList; NdbBlob* tFirstBlob = theNdbOp->theBlobList;
...@@ -1343,14 +1343,15 @@ NdbBlob::postExecute(ExecType anExecType) ...@@ -1343,14 +1343,15 @@ NdbBlob::postExecute(ExecType anExecType)
return -1; return -1;
if (theGetFlag) { if (theGetFlag) {
assert(theGetSetBytes == 0 || theGetBuf != 0); assert(theGetSetBytes == 0 || theGetBuf != 0);
assert(theGetSetBytes <= theInlineSize || anExecType == NoCommit); assert(theGetSetBytes <= theInlineSize ||
anExecType == NdbTransaction::NoCommit);
Uint32 bytes = theGetSetBytes; Uint32 bytes = theGetSetBytes;
if (readDataPrivate(theGetBuf, bytes) == -1) if (readDataPrivate(theGetBuf, bytes) == -1)
return -1; return -1;
} }
} }
if (isUpdateOp()) { if (isUpdateOp()) {
assert(anExecType == NoCommit); assert(anExecType == NdbTransaction::NoCommit);
getHeadFromRecAttr(); getHeadFromRecAttr();
if (theSetFlag) { if (theSetFlag) {
// setValue overwrites everything // setValue overwrites everything
...@@ -1367,7 +1368,7 @@ NdbBlob::postExecute(ExecType anExecType) ...@@ -1367,7 +1368,7 @@ NdbBlob::postExecute(ExecType anExecType)
} }
} }
if (isWriteOp() && isTableOp()) { if (isWriteOp() && isTableOp()) {
assert(anExecType == NoCommit); assert(anExecType == NdbTransaction::NoCommit);
if (theHeadInlineReadOp->theError.code == 0) { if (theHeadInlineReadOp->theError.code == 0) {
int tNullFlag = theNullFlag; int tNullFlag = theNullFlag;
Uint64 tLength = theLength; Uint64 tLength = theLength;
...@@ -1418,18 +1419,18 @@ NdbBlob::postExecute(ExecType anExecType) ...@@ -1418,18 +1419,18 @@ NdbBlob::postExecute(ExecType anExecType)
} }
} }
if (isDeleteOp()) { if (isDeleteOp()) {
assert(anExecType == NoCommit); assert(anExecType == NdbTransaction::NoCommit);
getHeadFromRecAttr(); getHeadFromRecAttr();
if (deleteParts(0, getPartCount()) == -1) if (deleteParts(0, getPartCount()) == -1)
return -1; return -1;
} }
setState(anExecType == NoCommit ? Active : Closed); setState(anExecType == NdbTransaction::NoCommit ? Active : Closed);
// activation callback // activation callback
if (theActiveHook != NULL) { if (theActiveHook != NULL) {
if (invokeActiveHook() == -1) if (invokeActiveHook() == -1)
return -1; return -1;
} }
if (anExecType == NoCommit && theHeadInlineUpdateFlag) { if (anExecType == NdbTransaction::NoCommit && theHeadInlineUpdateFlag) {
NdbOperation* tOp = theNdbCon->getNdbOperation(theTable); NdbOperation* tOp = theNdbCon->getNdbOperation(theTable);
if (tOp == NULL || if (tOp == NULL ||
tOp->updateTuple() == -1 || tOp->updateTuple() == -1 ||
...@@ -1438,7 +1439,7 @@ NdbBlob::postExecute(ExecType anExecType) ...@@ -1438,7 +1439,7 @@ NdbBlob::postExecute(ExecType anExecType)
setErrorCode(NdbBlobImpl::ErrAbort); setErrorCode(NdbBlobImpl::ErrAbort);
return -1; return -1;
} }
tOp->m_abortOption = AbortOnError; tOp->m_abortOption = NdbTransaction::AbortOnError;
DBG("added op to update head+inline"); DBG("added op to update head+inline");
} }
DBG("postExecute [out]"); DBG("postExecute [out]");
...@@ -1468,7 +1469,7 @@ NdbBlob::preCommit() ...@@ -1468,7 +1469,7 @@ NdbBlob::preCommit()
setErrorCode(NdbBlobImpl::ErrAbort); setErrorCode(NdbBlobImpl::ErrAbort);
return -1; return -1;
} }
tOp->m_abortOption = AbortOnError; tOp->m_abortOption = NdbTransaction::AbortOnError;
DBG("added op to update head+inline"); DBG("added op to update head+inline");
} }
} }
......
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