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