From: Ole John Aske Date: October 28 2011 1:38pm Subject: bzr push into mysql-5.1-telco-7.0 branch (ole.john.aske:4627 to 4628) List-Archive: http://lists.mysql.com/commits/141645 Message-Id: <20111028133857.E7597233@fimafeng09.norway.sun.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 4628 Ole John Aske 2011-10-28 Fix for handling errors during execute and retrieve of SPJ results from a pushed lookup query: If we missed to catch an error returned by NdbTransaction::execute() or available through NdbQuery::getErrorCode() a later ::fetchNext() will succeed without returning an error code. It could also return an incorrect result consisting of a partial results set from those NdbOperation which did return something before the failure was received This fix will reuse the same error handling mechanism for a lookup which is already used by a scan query. This will put the query into a persistent 'failed' state where any further operations (except ::close()) on that query will return the error : "ERROR: 4816 A previous query operation failed, which you missed to catch." modified: storage/ndb/src/ndbapi/NdbQueryOperation.cpp 4627 jonas oreland 2011-10-28 ndb - forgot to add file added: storage/ndb/include/kernel/statedesc.hpp === modified file 'storage/ndb/src/ndbapi/NdbQueryOperation.cpp' --- a/storage/ndb/src/ndbapi/NdbQueryOperation.cpp 2011-10-22 09:38:48 +0000 +++ b/storage/ndb/src/ndbapi/NdbQueryOperation.cpp 2011-10-28 13:38:36 +0000 @@ -2464,6 +2464,7 @@ NdbQueryImpl::handleBatchComplete(NdbRoo << ", finalBatchFrags=" << m_finalBatchFrags << endl; } + assert(rootFrag.isFragBatchComplete()); /* May received fragment data after a SCANREF() (timeout?) * terminated the scan. We are about to close this query, @@ -2471,8 +2472,6 @@ NdbQueryImpl::handleBatchComplete(NdbRoo */ if (likely(m_errorReceived == 0)) { - assert(rootFrag.isFragBatchComplete()); - assert(m_pendingFrags > 0); // Check against underflow. assert(m_pendingFrags <= m_rootFragCount); // .... and overflow m_pendingFrags--; @@ -2489,6 +2488,16 @@ NdbQueryImpl::handleBatchComplete(NdbRoo rootFrag.setReceivedMore(); return true; } + else if (!getQueryDef().isScanQuery()) // A failed lookup query + { + /** + * A lookup query will retrieve the rows as part of ::execute(). + * -> Error must be visible through API before we return control + * to the application. + */ + setErrorCode(m_errorReceived); + return true; + } return false; } // NdbQueryImpl::handleBatchComplete @@ -4970,12 +4979,12 @@ NdbQueryOperationImpl::execTCKEYREF(cons if (&getRoot() == this || ref->errorCode != static_cast(Err_TupleNotFound)) { - getQuery().setErrorCode(ref->errorCode); if (aSignal->getLength() == TcKeyRef::SignalLength) { // Signal may contain additional error data getQuery().m_error.details = (char *)UintPtr(ref->errorData); } + getQuery().setFetchTerminated(ref->errorCode,false); } NdbRootFragment& rootFrag = getQuery().m_rootFrags[0]; No bundle (reason: useless for push emails).