// PD_TRACE_DECLARE_FUNCTION( SDB__QGMPLDELETE__EXEC, "_qgmPlDelete::_execute" ) INT32 _qgmPlDelete::_execute( _pmdEDUCB *eduCB ) { PD_TRACE_ENTRY( SDB__QGMPLDELETE__EXEC ) ; INT32 rc = SDB_OK ; _SDB_KRCB *krcb = pmdGetKRCB() ; SDB_ROLE role = krcb->getDBRole() ; CHAR *msg = NULL ; if ( SDB_ROLE_COORD == role ) { INT32 bufSize = 0 ; MsgOpReply dummyReply ; rtnCoordDelete del ; rc = msgBuildDeleteMsg( &msg, &bufSize, _collection.toString().c_str(), 0, 0, _condition.isEmpty()? NULL : &_condition ) ; if ( SDB_OK != rc ) { goto error ; } rc = del.execute( msg, *((SINT32 *)msg), eduCB, dummyReply, NULL ) ; } else { SDB_DPSCB *dpsCB = krcb->getDPSCB() ; if ( dpsCB && eduCB->isFromLocal() && !dpsCB->isLogLocal() ) { dpsCB = NULL ; } SDB_DMSCB *dmsCB = krcb->getDMSCB() ; BSONObj empty ; rc = rtnDelete( _collection.toString().c_str(), _condition, empty, 0, eduCB, dmsCB, dpsCB ) ; } if ( SDB_OK != rc ) { goto error ; } done: if ( NULL != msg ) { SDB_OSS_FREE( msg ) ; msg = NULL ; } PD_TRACE_EXITRC( SDB__QGMPLDELETE__EXEC, rc ) ; return rc ; error: goto done ; }
INT32 _pmdDataProcessor::_onDelReqMsg( MsgHeader * msg, SDB_DPSCB *dpsCB ) { INT32 rc = SDB_OK ; INT32 flags = 0 ; CHAR *pCollectionName = NULL ; CHAR *pDeletorBuffer = NULL ; CHAR *pHintBuffer = NULL ; rc = msgExtractDelete ( (CHAR *)msg , &flags, &pCollectionName, &pDeletorBuffer, &pHintBuffer ) ; PD_RC_CHECK( rc, PDERROR, "Session[%s] extract delete msg failed, rc: %d", getSession()->sessionName(), rc ) ; try { BSONObj deletor ( pDeletorBuffer ) ; BSONObj hint ( pHintBuffer ) ; MON_SAVE_OP_DETAIL( eduCB()->getMonAppCB(), msg->opCode, "CL:%s, Deletor:%s, Hint:%s", pCollectionName, deletor.toString().c_str(), hint.toString().c_str() ) ; PD_LOG ( PDDEBUG, "Session[%s] Delete: deletor: %s\nhint: %s", getSession()->sessionName(), deletor.toString().c_str(), hint.toString().c_str() ) ; rc = rtnDelete( pCollectionName, deletor, hint, flags, eduCB(), _pDMSCB, dpsCB ) ; } catch ( std::exception &e ) { PD_LOG ( PDERROR, "Session[%s] Failed to create deletor for " "DELETE: %s", getSession()->sessionName(), e.what () ) ; rc = SDB_INVALIDARG ; goto error ; } done: return rc ; error: goto done ; }
// PD_TRACE_DECLARE_FUNCTION( SDB__QGMPLDELETE__EXEC, "_qgmPlDelete::_execute" ) INT32 _qgmPlDelete::_execute( _pmdEDUCB *eduCB ) { PD_TRACE_ENTRY( SDB__QGMPLDELETE__EXEC ) ; INT32 rc = SDB_OK ; _SDB_KRCB *krcb = pmdGetKRCB() ; SDB_ROLE role = krcb->getDBRole() ; CHAR *msg = NULL ; INT32 bufSize = 0 ; if ( SDB_ROLE_COORD == role ) { CoordCB *pCoord = krcb->getCoordCB() ; INT64 contextID = -1 ; rtnContextBuf buff ; coordDeleteOperator opr ; rc = msgBuildDeleteMsg( &msg, &bufSize, _collection.toString().c_str(), 0, 0, _condition.isEmpty() ? NULL : &_condition, NULL, eduCB ) ; if ( rc ) { PD_LOG( PDERROR, "Build delete message failed, rc: %d", rc ) ; goto error ; } rc = opr.init( pCoord->getResource(), eduCB ) ; if ( rc ) { PD_LOG( PDERROR, "Init operator[%s] failed, rc: %d", opr.getName(), rc ) ; goto error ; } rc = opr.execute( (MsgHeader*)msg, eduCB, contextID, &buff ) ; } else { SDB_DPSCB *dpsCB = krcb->getDPSCB() ; if ( dpsCB && eduCB->isFromLocal() && !dpsCB->isLogLocal() ) { dpsCB = NULL ; } SDB_DMSCB *dmsCB = krcb->getDMSCB() ; BSONObj empty ; rc = rtnDelete( _collection.toString().c_str(), _condition, empty, 0, eduCB, dmsCB, dpsCB ) ; } if ( rc ) { goto error ; } done: if ( NULL != msg ) { msgReleaseBuffer( msg, eduCB ) ; } PD_TRACE_EXITRC( SDB__QGMPLDELETE__EXEC, rc ) ; return rc ; error: goto done ; }