Commit 53f58167 authored by unknown's avatar unknown

A few minor cleanups for recent AbortOption behaviour change.


storage/ndb/include/ndbapi/NdbOperation.hpp:
  Add some comments describing the new AbortOption handling.
storage/ndb/ndbapi-examples/ndbapi_simple_index/ndbapi_simple_index.cpp:
  Fix example to work with new AbortOption handling.
storage/ndb/src/ndbapi/NdbOperationDefine.cpp:
  Add forgotten method implementations.
parent d1c317f3
...@@ -98,7 +98,20 @@ public: ...@@ -98,7 +98,20 @@ public:
}; };
/** /**
* How should transaction be handled if operation fails * How should transaction be handled if operation fails.
*
* If AO_IgnoreError, a failure in one operation will not abort the
* transaction, and NdbTransaction::execute() will return 0 (success). Use
* NdbOperation::getNdbError() to check for errors from individual
* operations.
*
* If AbortOnError, a failure in one operation will abort the transaction
* and cause NdbTransaction::execute() to return -1.
*
* Abort option can be set on execute(), or in the individual operation.
* Setting AO_IgnoreError or AbortOnError in execute() overrides the settings
* on individual operations. Setting DefaultAbortOption in execute() (the
* default) causes individual operation settings to be used.
* *
* For READ, default is AO_IgnoreError * For READ, default is AO_IgnoreError
* DML, default is AbortOnError * DML, default is AbortOnError
...@@ -1019,10 +1032,8 @@ protected: ...@@ -1019,10 +1032,8 @@ protected:
NdbBlob* theBlobList; NdbBlob* theBlobList;
/* /*
* Abort option per operation, used by blobs. Default -1. If set, * Abort option per operation, used by blobs.
* overrides abort option on connection level. If set to IgnoreError, * See also comments on enum AbortOption.
* does not cause execute() to return failure. This is different from
* IgnoreError on connection level.
*/ */
Int8 m_abortOption; Int8 m_abortOption;
......
...@@ -19,6 +19,17 @@ ...@@ -19,6 +19,17 @@
// Correct output from this program is: // Correct output from this program is:
// //
// ATTR1 ATTR2 // ATTR1 ATTR2
// 0 0
// 1 1
// 2 2
// 3 3
// 4 4
// 5 5
// 6 6
// 7 7
// 8 8
// 9 9
// ATTR1 ATTR2
// 0 10 // 0 10
// 1 1 // 1 1
// 2 12 // 2 12
...@@ -166,7 +177,8 @@ int main(int argc, char** argv) ...@@ -166,7 +177,8 @@ int main(int argc, char** argv)
NdbRecAttr *myRecAttr= myIndexOperation->getValue("ATTR1", NULL); NdbRecAttr *myRecAttr= myIndexOperation->getValue("ATTR1", NULL);
if (myRecAttr == NULL) APIERROR(myTransaction->getNdbError()); if (myRecAttr == NULL) APIERROR(myTransaction->getNdbError());
if(myTransaction->execute( NdbTransaction::Commit ) != -1) if(myTransaction->execute( NdbTransaction::Commit,
NdbOperation::AbortOnError ) != -1)
printf(" %2d %2d\n", myRecAttr->u_32_value(), i); printf(" %2d %2d\n", myRecAttr->u_32_value(), i);
myNdb->closeTransaction(myTransaction); myNdb->closeTransaction(myTransaction);
...@@ -232,7 +244,8 @@ int main(int argc, char** argv) ...@@ -232,7 +244,8 @@ int main(int argc, char** argv)
NdbRecAttr *myRecAttr= myOperation->getValue("ATTR2", NULL); NdbRecAttr *myRecAttr= myOperation->getValue("ATTR2", NULL);
if (myRecAttr == NULL) APIERROR(myTransaction->getNdbError()); if (myRecAttr == NULL) APIERROR(myTransaction->getNdbError());
if(myTransaction->execute( NdbTransaction::Commit ) == -1) if(myTransaction->execute( NdbTransaction::Commit,
NdbOperation::AbortOnError ) == -1)
if (i == 3) { if (i == 3) {
std::cout << "Detected that deleted tuple doesn't exist!\n"; std::cout << "Detected that deleted tuple doesn't exist!\n";
} else { } else {
......
...@@ -715,6 +715,22 @@ NdbOperation::insertATTRINFOloop(register const Uint32* aDataPtr, ...@@ -715,6 +715,22 @@ NdbOperation::insertATTRINFOloop(register const Uint32* aDataPtr,
}//NdbOperation::insertATTRINFOloop() }//NdbOperation::insertATTRINFOloop()
NdbOperation::AbortOption
NdbOperation::getAbortOption() const
{
return (AbortOption)m_abortOption;
}
int
NdbOperation::setAbortOption(AbortOption ao)
{
switch(ao)
{
case AO_IgnoreError:
case AbortOnError:
m_abortOption= ao;
return 0;
default:
return -1;
}
}
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