int DBTransactionContext::execute(DBOperationSet *operations, int _execType, int _abortOption, int force) { int rval; int opListSize = operations->size; NdbTransaction::ExecType execType = static_cast<NdbTransaction::ExecType>(_execType); NdbOperation::AbortOption abortOption = static_cast<NdbOperation::AbortOption>(_abortOption); bool doClose = (execType != NdbTransaction::NoCommit); if(! ndbTransaction) { startTransaction(operations->getKeyOperation(0)); } operations->prepare(ndbTransaction); if(operations->hasBlobReadOperations()) { ndbTransaction->execute(NdbTransaction::NoCommit); DEBUG_PRINT("BLOB EXECUTE DONE"); } rval = ndbTransaction->execute(execType, abortOption, force); DEBUG_PRINT("EXECUTE sync : %s %d operation%s %s => return: %d error: %d", modes[execType], opListSize, (opListSize == 1 ? "" : "s"), (doClose ? " & close transaction" : ""), rval, ndbTransaction->getNdbError().code); if(doClose) { closeTransaction(); } return rval; }
/* Send data to a register of a GPIO chip, this is the main function that send data to the GPIO chip once is inited. Parameters reg: a legal 8bit MCP23Sxx register. data: 16 bit data to transfer. forceByte: not used till now, experimental. Maybe I will use in future. */ void gpio_MCP23SXX::_sendData(byte reg,uint16_t data,bool forceByte) { #if defined(SPI_LEGACY_METHOD) startTransaction(); writeByte_cont(_writeCmd); writeByte_cont(reg); if (_ports < 16 || (forceByte == true)){ uint8_t temp = (uint8_t)(data & 0xFF); writeByte_last(temp); } else { data = _reverseWordOrder(data); writeWord_last(data); } endTransaction(); #else _spi.startTransaction();//cs low _spi.writeByte_cont(_writeCmd); _spi.writeByte_cont(reg); if (_ports < 16 || forceByte){ uint8_t temp = (uint8_t)(data & 0xFF); _spi.writeByte_last(temp); } else { data = _reverseWordOrder(data); _spi.writeWord_last(data); } _spi.endTransaction(); #endif }
void Database::prunePath(std::list<fs::path> filePaths) { boost::mutex::scoped_lock lock(dbMutex); bool allOk = true; startTransaction(); for(std::list<fs::path>::iterator ite = filePaths.begin(); ite != filePaths.end(); ++ite){ const char* path = ite->c_str(); int pathSize = ite->string().size(); int response = 0; sqlite3_bind_text(pruneDeleteImageStmt, 1, path, pathSize, SQLITE_TRANSIENT); sqlite3_bind_text(pruneDeleteBadFileStmt, 1, path, pathSize, SQLITE_TRANSIENT); response = sqlite3_step(pruneDeleteImageStmt); if(SQLITE_DONE != response) {allOk = false;} response = sqlite3_step(pruneDeleteBadFileStmt); if(SQLITE_DONE != response) {allOk = false;} sqlite3_reset(pruneDeleteImageStmt); sqlite3_reset(pruneDeleteBadFileStmt); } commitTransaction(); if (!allOk) { LOG4CPLUS_WARN(logger, "Failed to delete some file paths"); } }
/** * This function provides the initialize method for the Transaction class. * * @param self A reference to the new Transaction class instance. * @param connections Either a reference to a single Connection object or to * an array of Connection objects that the transaction * will apply to. * */ static VALUE transactionInitialize(VALUE self, VALUE connections) { TransactionHandle *transaction = NULL; VALUE array = Qnil; /* Determine if an array has been passed as a parameter. */ if(TYPE(connections) == T_ARRAY) { array = connections; } else if(TYPE(connections) == T_DATA && RDATA(connections)->dfree == (RUBY_DATA_FUNC)connectionFree) { array = rb_ary_new(); rb_ary_push(array, connections); } else { rb_fireruby_raise(NULL, "Invalid connection parameter(s) for transaction."); } /* Store the database details. */ rb_iv_set(self, "@connections", array); /* Fetch the data structure and start the transaction. */ Data_Get_Struct(self, TransactionHandle, transaction); startTransaction(transaction, array, 0, NULL); rb_tx_started(self, array); return(self); }
// Call Market Watch Frame 1 void CMarketWatchDB::DoMarketWatchFrame1(const TMarketWatchFrame1Input *pIn, TMarketWatchFrame1Output *pOut) { #ifdef DEBUG pthread_t pid = pthread_self(); cout << pid << " <<< MWF1" << endl; cout << pid << " - Market Watch Frame 1 (input)" << endl << pid << " -- acct_id: " << pIn->acct_id << endl << pid << " -- cust_id: " << pIn->c_id << endl << pid << " -- ending_co_id: " << pIn->ending_co_id << endl << pid << " -- industry_name: " << pIn->industry_name << " (5% used)" << endl << pid << " -- starting_co_id: " << pIn->starting_co_id << " (used only when industry_name is used)" << endl; #endif // DEBUG #ifdef DB_PGSQL startTransaction(); // Isolation level required by Clause 7.4.1.3 setReadCommitted(); #endif execute(pIn, pOut); commitTransaction(); #ifdef DEBUG cout << pid << " - Market Watch Frame 1 (output)" << endl << pid << " -- pct_change: " << pOut->pct_change << endl; cout << pid << " >>> MWF1" << endl; #endif // DEBUG }
void LLCurrencyUIManager::Impl::updateCurrencyInfo() { mSiteCurrencyEstimated = false; mSiteCurrencyEstimatedCost = 0; mBought = false; mCurrencyChanged = false; if (mUserCurrencyBuy == 0) { mSiteCurrencyEstimated = true; return; } LLXMLRPCValue keywordArgs = LLXMLRPCValue::createStruct(); keywordArgs.appendString("agentId", gAgent.getID().asString()); keywordArgs.appendString( "secureSessionId", gAgent.getSecureSessionID().asString()); keywordArgs.appendInt("currencyBuy", mUserCurrencyBuy); LLXMLRPCValue params = LLXMLRPCValue::createArray(); params.append(keywordArgs); startTransaction(TransactionCurrency, "getCurrencyQuote", params); }
// Call Trade Order Frame 1 void CTradeOrderDB::DoTradeOrderFrame1(const TTradeOrderFrame1Input *pIn, TTradeOrderFrame1Output *pOut) { #ifdef DEBUG m_coutLock.lock(); cout << "<<< TOF1" << endl; cout << "- Trade Order Frame 1 (input)" << endl << "-- acct_id: " << pIn->acct_id << endl; m_coutLock.unlock(); #endif // DEBUG startTransaction(); // Isolation level required by Clause 7.4.1.3 setRepeatableRead(); execute(pIn, pOut); #ifdef DEBUG m_coutLock.lock(); cout << "- Trade Order Frame 1 (output)" << endl << "-- acct_name: " << pOut->acct_name << endl << "-- broker_name: " << pOut->broker_name << endl << "-- cust_f_name: " << pOut->cust_f_name << endl << "-- cust_id: " << pOut->cust_id << endl << "-- cust_l_name: " << pOut->cust_l_name << endl << "-- cust_tier: " << pOut->cust_tier << endl << "-- tax_id: " << pOut->tax_id << endl << "-- tax_status: " << pOut->tax_status << endl; cout << ">>> TOF1" << endl; m_coutLock.unlock(); #endif // DEBUG }
void start_T1(Ndb * pNDB, ThreadData * td, int async){ DEBUG2("T1(%.*s): - Starting", SUBSCRIBER_NUMBER_LENGTH, td->transactionData.number); NdbConnection * pCON = 0; while((pCON = startTransaction(pNDB, td)) == 0){ CHECK_ALLOWED_ERROR("T1: startTransaction", td, pNDB->getNdbError()); NdbSleep_MilliSleep(10); } NdbOperation *MyOp = pCON->getNdbOperation(SUBSCRIBER_TABLE); if (MyOp != NULL) { MyOp->updateTuple(); MyOp->equal(IND_SUBSCRIBER_NUMBER, td->transactionData.number); MyOp->setValue(IND_SUBSCRIBER_LOCATION, (char *)&td->transactionData.location); MyOp->setValue(IND_SUBSCRIBER_CHANGED_BY, td->transactionData.changed_by); MyOp->setValue(IND_SUBSCRIBER_CHANGED_TIME, td->transactionData.changed_time); if (async == 1) { pCON->executeAsynchPrepare( Commit , T1_Callback, td); } else { int result = pCON->execute(Commit); T1_Callback(result, pCON, (void*)td); return; }//if } else { CHECK_NULL(MyOp, "T1: getNdbOperation", td, pCON->getNdbError()); }//if }
void LLCurrencyUIManager::Impl::updateCurrencyInfo() { clearEstimate(); mBought = false; mCurrencyChanged = false; if (mUserCurrencyBuy == 0) { mLocalCurrencyEstimated = true; return; } LLXMLRPCValue keywordArgs = LLXMLRPCValue::createStruct(); keywordArgs.appendString("agentId", gAgent.getID().asString()); keywordArgs.appendString( "secureSessionId", gAgent.getSecureSessionID().asString()); keywordArgs.appendInt("currencyBuy", mUserCurrencyBuy); keywordArgs.appendString("viewerChannel", gSavedSettings.getString("VersionChannelName")); keywordArgs.appendInt("viewerMajorVersion", LLVersionInfo::getMajor()); keywordArgs.appendInt("viewerMinorVersion", LLVersionInfo::getMinor()); keywordArgs.appendInt("viewerPatchVersion", LLVersionInfo::getPatch()); keywordArgs.appendInt("viewerBuildVersion", LLVersionInfo::getBuild()); LLXMLRPCValue params = LLXMLRPCValue::createArray(); params.append(keywordArgs); startTransaction(TransactionCurrency, "getCurrencyQuote", params); }
// TODO: see if we can make this one command static void bulkSetRecords(stKVDatabase *database, stList *records) { startTransaction(database); stTry { for(int32_t i=0; i<stList_length(records); i++) { stKVDatabaseBulkRequest *request = stList_get(records, i); switch(request->type) { case UPDATE: updateRecord(database, request->key, request->value, request->size); break; case INSERT: insertRecord(database, request->key, request->value, request->size); break; case SET: setRecord(database, request->key, request->value, request->size); break; } } commitTransaction(database); }stCatch(ex) { abortTransaction(database); stThrowNewCause( ex, ST_KV_DATABASE_EXCEPTION_ID, "MySQL bulk set records failed"); }stTryEnd; }
void LLCurrencyUIManager::Impl::startCurrencyBuy(const std::string& password) { LLXMLRPCValue keywordArgs = LLXMLRPCValue::createStruct(); keywordArgs.appendString("agentId", gAgent.getID().asString()); keywordArgs.appendString( "secureSessionId", gAgent.getSecureSessionID().asString()); keywordArgs.appendInt("currencyBuy", mUserCurrencyBuy); if (mUSDCurrencyEstimated) { keywordArgs.appendInt("estimatedCost", mUSDCurrencyEstimatedCost); } if (mLocalCurrencyEstimated) { keywordArgs.appendString("estimatedLocalCost", mLocalCurrencyEstimatedCost); } keywordArgs.appendString("confirm", mSiteConfirm); if (!password.empty()) { keywordArgs.appendString("password", password); } keywordArgs.appendString("viewerChannel", gSavedSettings.getString("VersionChannelName")); keywordArgs.appendInt("viewerMajorVersion", LLVersionInfo::getMajor()); keywordArgs.appendInt("viewerMinorVersion", LLVersionInfo::getMinor()); keywordArgs.appendInt("viewerPatchVersion", LLVersionInfo::getPatch()); keywordArgs.appendInt("viewerBuildVersion", LLVersionInfo::getBuild()); LLXMLRPCValue params = LLXMLRPCValue::createArray(); params.append(keywordArgs); startTransaction(TransactionBuy, "buyCurrency", params); clearEstimate(); mCurrencyChanged = false; }
// Call Data Maintenance Frame 1 void CDataMaintenanceDB::DoDataMaintenanceFrame1( const TDataMaintenanceFrame1Input *pIn) { #ifdef DEBUG pthread_t pid = pthread_self(); cout << pid << " <<< DMF1" << endl; cout << pid << " - Data Maintenance Frame 1 (input)" << endl << pid << " -- c_id: " << pIn->c_id << endl << pid << " -- co_id: " << pIn->co_id << endl << pid << " -- day_of_month: " << pIn->day_of_month << endl << pid << " -- symbol: " << pIn->symbol << endl << pid << " -- table_name: " << pIn->table_name << endl << pid << " -- tx_id name: " << pIn->tx_id << endl << pid << " -- vol_incr: " << pIn->vol_incr << endl; #endif // DEBUG #ifdef DB_PGSQL startTransaction(); // Isolation level required by Clause 7.4.1.3 setReadCommitted(); #endif execute(pIn); commitTransaction(); #ifdef DEBUG cout << pid << " - Data Maintenance Frame 1 (output)" << endl; cout << pid << " >>> DMF1" << endl; #endif // DEBUG }
// Call Broker Volume Frame 1 void CBrokerVolumeDB::DoBrokerVolumeFrame1(const TBrokerVolumeFrame1Input *pIn, TBrokerVolumeFrame1Output *pOut) { #ifdef DEBUG pthread_t pid = pthread_self(); int i; cout << pid << " <<< BVF1" << endl; cout << pid << " - Broker Volume Frame 1 (input)" << endl; for (i = 0; i < max_broker_list_len; i++) cout << pid << " -- broker_list[" << i << "]: " << pIn->broker_list[i] << endl; cout << pid << " -- sector name: " << pIn->sector_name << endl; #endif // DEBUG #ifdef DB_PGSQL startTransaction(); // Isolation level required by Clause 7.4.1.3 setReadCommitted(); #endif execute(pIn, pOut); commitTransaction(); #ifdef DEBUG cout << pid << " - Broker Volume Frame 1 (output)" << endl << pid << " -- list_len: " << pOut->list_len << endl; for (i = 0; i < pOut->list_len; i ++) { cout << pid << " -- broker_name[" << i << "]: " << pOut->broker_name[i] << endl << pid << " -- volume[" << i << "]: " << pOut->volume[i] << endl; } cout << pid << " >>> BVF1" << endl; #endif // DEBUG }
int DBTransactionContext::prepareAndExecuteScan(ScanOperation *scan) { if(! ndbTransaction) { startTransaction(NULL); } scan->prepareScan(ndbTransaction); return ndbTransaction->execute(NdbTransaction::NoCommit, NdbOperation::AO_IgnoreError, 1); }
/** * Transaction 2 - T2 * * Read from Subscriber: * * Input: * SubscriberNumber * * Output: * Location * Changed by * Changed Timestamp * Name */ void start_T2(Ndb * pNDB, ThreadData * td, int async) { DEBUG3("T2(%.*s, %d): - Starting", SUBSCRIBER_NUMBER_LENGTH, td->transactionData.number, td->transactionData.location); NdbConnection * pCON = 0; while((pCON = startTransaction(pNDB, td)) == 0) { CHECK_ALLOWED_ERROR("T2-1: startTransaction", td, pNDB->getNdbError()); NdbSleep_MilliSleep(10); } if (td->ndbRecordSharedData) { char* rowPtr= (char*) &td->transactionData; const NdbRecord* record= td->ndbRecordSharedData-> subscriberTableNdbRecord; Uint32 m=0; unsigned char* mask= (unsigned char*) &m; SET_MASK(mask, IND_SUBSCRIBER_LOCATION); SET_MASK(mask, IND_SUBSCRIBER_CHANGED_BY); SET_MASK(mask, IND_SUBSCRIBER_CHANGED_TIME); SET_MASK(mask, IND_SUBSCRIBER_NAME); const NdbOperation* MyOp= pCON->readTuple(record, rowPtr, record, rowPtr, NdbOperation::LM_Read, mask); CHECK_NULL((void*) MyOp, "T2: readTuple", td, pCON->getNdbError()); } else { NdbOperation *MyOp= pCON->getNdbOperation(SUBSCRIBER_TABLE); CHECK_NULL(MyOp, "T2: getNdbOperation", td, pCON->getNdbError()); MyOp->readTuple(); MyOp->equal(IND_SUBSCRIBER_NUMBER, td->transactionData.number); MyOp->getValue(IND_SUBSCRIBER_LOCATION, (char *)&td->transactionData.location); MyOp->getValue(IND_SUBSCRIBER_CHANGED_BY, td->transactionData.changed_by); MyOp->getValue(IND_SUBSCRIBER_CHANGED_TIME, td->transactionData.changed_time); MyOp->getValue(IND_SUBSCRIBER_NAME, td->transactionData.name); } if (async == 1) { pCON->executeAsynchPrepare( Commit , T2_Callback, td); } else { int result = pCON->execute(Commit); T2_Callback(result, pCON, (void*)td); return; }//if }
bool DBTransactionContext::tryImmediateStartTransaction(KeyOperation * op) { token = parent->registerIntentToOpen(); if(token == -1) { startTransaction(op); return true; } return false; }
// Call Customer Position Frame 1 void CCustomerPositionDB::DoCustomerPositionFrame1( const TCustomerPositionFrame1Input *pIn, TCustomerPositionFrame1Output *pOut) { #ifdef DEBUG m_coutLock.lock(); cout << "<<< CPF1" << endl; cout << "*** " << osCall.str() << endl; cout << "- Customer Position Frame 1 (input)" << endl << "-- cust_id: " << pIn->cust_id << endl << "-- tax_id: " << pIn->tax_id << endl; m_coutLock.unlock(); #endif // DEBUG startTransaction(); // Isolation level required by Clause 7.4.1.3 setReadCommitted(); execute(pIn, pOut); #ifdef DEBUG m_coutLock.lock(); cout << "- Customer Position Frame 1 (output)" << endl << "-- cust_id: " << pOut->cust_id << endl << "-- acct_len: " << pOut->acct_len << endl; for (int i = 0; i < pOut->acct_len; i++) { cout << "-- acct_id[" << i << "]: " << pOut->acct_id[i] << endl << "-- cash_bal[" << i << "]: " << pOut->cash_bal[i] << endl << "-- asset_total[" << i << "]: " << pOut->asset_total[i] << endl; } cout << "-- c_st_id: " << pOut->c_st_id << endl << "-- c_l_name: " << pOut->c_l_name << endl << "-- c_f_name: " << pOut->c_f_name << endl << "-- c_m_name: " << pOut->c_m_name << endl << "-- c_gndr: " << pOut->c_gndr << endl << "-- c_tier: " << pOut->c_tier << endl << "-- c_dob: " << pOut->c_dob.year << "-" << pOut->c_dob.month << "-" << pOut->c_dob.day << " " << pOut->c_dob.hour << ":" << pOut->c_dob.minute << ":" << pOut->c_dob.second << endl << "-- c_ad_id: " << pOut->c_ad_id << endl << "-- c_ctry_1: " << pOut->c_ctry_1 << endl << "-- c_area_1: " << pOut->c_area_1 << endl << "-- c_local_1: " << pOut->c_local_1 << endl << "-- c_ext_1: " << pOut->c_ext_1 << endl << "-- c_ctry_2: " << pOut->c_ctry_2 << endl << "-- c_area_2: " << pOut->c_area_2 << endl << "-- c_local_2: " << pOut->c_local_2 << endl << "-- c_ext_2: " << pOut->c_ext_2 << endl << "-- c_ctry_3: " << pOut->c_ctry_3 << endl << "-- c_area_3: " << pOut->c_area_3 << endl << "-- c_local_3: " << pOut->c_local_3 << endl << "-- c_ext_3: " << pOut->c_ext_3 << endl << "-- c_email_1: " << pOut->c_email_1 << endl << "-- c_email_2: " << pOut->c_email_2 << endl; cout << ">>> CPF1" << endl; m_coutLock.unlock(); #endif // DEBUG }
void SyncJournalDb::commitInternal(const QString& context, bool startTrans ) { qDebug() << "Transaction Start " << context; commitTransaction(); if( startTrans ) { startTransaction(); } }
void LLFloaterBuyLandUI::runWebSitePrep(const std::string& password) { if (!mCanBuy) { return; } BOOL remove_contribution = getChild<LLUICtrl>("remove_contribution")->getValue().asBoolean(); mParcelBuyInfo = LLViewerParcelMgr::getInstance()->setupParcelBuy(gAgent.getID(), gAgent.getSessionID(), gAgent.getGroupID(), mIsForGroup, mIsClaim, remove_contribution); if (mParcelBuyInfo && !mSiteMembershipUpgrade && !mSiteLandUseUpgrade && mCurrency.getAmount() == 0 && mSiteConfirm != "password") { sendBuyLand(); return; } std::string newLevel = "noChange"; if (mSiteMembershipUpgrade) { LLComboBox* levels = getChild<LLComboBox>( "account_level"); if (levels) { mUserPlanChoice = levels->getCurrentIndex(); newLevel = mSiteMembershipPlanIDs[mUserPlanChoice]; } } LLXMLRPCValue keywordArgs = LLXMLRPCValue::createStruct(); keywordArgs.appendString("agentId", gAgent.getID().asString()); keywordArgs.appendString( "secureSessionId", gAgent.getSecureSessionID().asString()); keywordArgs.appendString("language", LLUI::getLanguage()); keywordArgs.appendString("levelId", newLevel); keywordArgs.appendInt("billableArea", mIsForGroup ? 0 : mParcelBillableArea); keywordArgs.appendInt("currencyBuy", mCurrency.getAmount()); keywordArgs.appendInt("estimatedCost", mCurrency.getUSDEstimate()); keywordArgs.appendString("estimatedLocalCost", mCurrency.getLocalEstimate()); keywordArgs.appendString("confirm", mSiteConfirm); if (!password.empty()) { keywordArgs.appendString("password", password); } LLXMLRPCValue params = LLXMLRPCValue::createArray(); params.append(keywordArgs); startTransaction(TransactionBuy, params); }
int TransactionImpl::prepareAndExecuteQuery(QueryOperation *query) { if(! ndbTransaction) { startTransaction(NULL); } if(! query->createNdbQuery(ndbTransaction)) { DEBUG_PRINT("%d %s", query->getNdbError().code, query->getNdbError().message); return -1; } return ndbTransaction->execute(NdbTransaction::NoCommit, NdbOperation::AO_IgnoreError, 1); }
uint8_t SHT::readStatus() { startTransaction(); sendByte(CMD_READ_STAT); uint16_t status = readWord(); return (uint8_t)(status >> 8); }
extern "C" void* NdbThreadFuncUpdate(void* pArg) { myRandom48Init((long int)NdbTick_CurrentMillisecond()); unsigned nSucc = 0; unsigned nFail = 0; Ndb* pNdb = NULL ; pNdb = new Ndb("TEST_DB"); VerifyMethodInt(pNdb, init()); VerifyMethodInt(pNdb, waitUntilReady()); while(NdbMutex_Trylock(g_pNdbMutex)) { Uint32 nWarehouse = myRandom48(g_nWarehouseCount); NdbConnection* pNdbConnection = NULL ; VerifyMethodPtr(pNdbConnection, pNdb, startTransaction()); CHK_TR(pNdbConnection) ; // epaulsa NdbOperation* pNdbOperationW = NULL ; VerifyMethodPtr(pNdbOperationW, pNdbConnection, getNdbOperation(c_szWarehouse)); VerifyMethodInt(pNdbOperationW, interpretedUpdateTuple()); VerifyMethodInt(pNdbOperationW, equal(c_szWarehouseNumber, nWarehouse)); VerifyMethodInt(pNdbOperationW, incValue(c_szWarehouseCount, Uint32(1))); Uint32 nWarehouseSum = 0; for(Uint32 nDistrict=0; nDistrict<g_nDistrictPerWarehouse; ++nDistrict) { NdbOperation* pNdbOperationD = NULL ; VerifyMethodPtr(pNdbOperationD, pNdbConnection, getNdbOperation(c_szDistrict)); VerifyMethodInt(pNdbOperationD, interpretedUpdateTuple()); VerifyMethodInt(pNdbOperationD, equal(c_szDistrictWarehouseNumber, nWarehouse)); VerifyMethodInt(pNdbOperationD, equal(c_szDistrictNumber, nDistrict)); VerifyMethodInt(pNdbOperationD, incValue(c_szDistrictCount, Uint32(1))); Uint32 nDistrictSum = myRandom48(100); nWarehouseSum += nDistrictSum; VerifyMethodInt(pNdbOperationD, setValue(c_szDistrictSum, nDistrictSum)); } VerifyMethodInt(pNdbOperationW, setValue(c_szWarehouseSum, nWarehouseSum)); int iExec = pNdbConnection->execute(Commit); int iError = pNdbConnection->getNdbError().code; if(iExec<0 && iError!=0 && iError!=266 && iError!=626) { ReportMethodInt(iExec, pNdbConnection, "pNdbConnection", "execute(Commit)", __FILE__, __LINE__); } if(iExec==0) { ++nSucc; } else { ++nFail; } VerifyMethodVoid(pNdb, closeTransaction(pNdbConnection)); } ndbout << "update: " << nSucc << " succeeded, " << nFail << " failed " << endl; NdbMutex_Unlock(g_pNdbMutex); delete pNdb; pNdb = NULL ; return NULL; }
// Call Trade Status Frame 1 void CTradeStatusDB::DoTradeStatusFrame1(const TTradeStatusFrame1Input *pIn, TTradeStatusFrame1Output *pOut) { #ifdef DEBUG pthread_t pid = pthread_self(); cout << pid << " <<< TSF1" << endl; cout << pid << " - Trade Status Frame 1 (input)" << endl << pid << " -- acct_id: " << pIn->acct_id << endl; #endif // DEBUG startTransaction(); #ifdef DB_PGSQL // Isolation level required by Clause 7.4.1.3 setReadCommitted(); #endif execute(pIn, pOut); commitTransaction(); #ifdef DEBUG cout << pid << " - Trade Status Frame 1 (output)" << endl << pid << " -- cust_l_name: " << pOut->cust_l_name << endl << pid << " -- cust_f_name: " << pOut->cust_f_name << endl << pid << " -- broker_name: " << pOut->broker_name << endl; for (int i = 0; i < max_trade_status_len; i++) { cout << pid << " -- charge[" << i << "]: " << pOut->charge[i] << endl << pid << " -- exec_name[" << i << "]: " << pOut->exec_name[i] << endl << pid << " -- ex_name[" << i << "]: " << pOut->ex_name[i] << endl << pid << " -- s_name[" << i << "]: " << pOut->s_name[i] << endl << pid << " -- status_name[" << i << "]: " << pOut->status_name[i] << endl << pid << " -- symbol[" << i << "]: " << pOut->symbol[i] << endl << pid << " -- trade_dts[" << i << "]: " << pOut->trade_dts[i].year << "-" << pOut->trade_dts[i].month << "-" << pOut->trade_dts[i].day << " " << pOut->trade_dts[i].hour << ":" << pOut->trade_dts[i].minute << ":" << pOut->trade_dts[i].second << endl << pid << " -- trade_id[" << i << "]: " << pOut->trade_id[i] << endl << pid << " -- trade_qty[" << i << "]: " << pOut->trade_qty[i] << endl << pid << " -- type_name[" << i << "]: " << pOut->type_name[i] << endl; } cout << pid << " >>> TSF1" << endl; #endif // DEBUG }
//--------------------------------- LOW LEVEL SPI ROUTINES -------------------------------------------------------- // Send a byte to a chip register... void gpio_MCP23SXX::_GPIOwriteByte(byte reg, byte data) { #if defined(SPI_LEGACY_METHOD) startTransaction(); writeByte_cont(_writeCmd); writeByte_cont(reg); writeByte_last(data); endTransaction(); #else _spi.startTransaction(); _spi.writeByte_cont(_writeCmd); _spi.writeByte_cont(reg); _spi.writeByte_last(data); _spi.endTransaction(); #endif }
//TODO: make one command static void bulkRemoveRecords(stKVDatabase *database, stList *records) { startTransaction(database); stTry { for(int32_t i=0; i<stList_length(records); i++) { stInt64Tuple *j = stList_get(records, i); removeRecord(database, stInt64Tuple_getPosition(j, 0)); } commitTransaction(database); }stCatch(ex) { abortTransaction(database); stThrowNewCause( ex, ST_KV_DATABASE_EXCEPTION_ID, "MySQL bulk remove records failed"); }stTryEnd; }
/** * This function creates a new Transaction object for a connection. This method * provides the create class method for the Transaction class and allows for the * specification of transaction parameters. * * @param unused Like it says, not used. * @param connections A reference to the array of Connection objects that the * transaction will be associated with. * @param parameters A reference to an array containing the parameters to be * used in creating the transaction. * * @return A reference to the newly created Transaction object. * */ static VALUE createTransaction(VALUE unused, VALUE connections, VALUE parameters) { VALUE instance = Qnil, list = Qnil; TransactionHandle *transaction = ALLOC(TransactionHandle); if(transaction == NULL) { rb_raise(rb_eNoMemError, "Memory allocation failure allocating a transaction."); } transaction->handle = 0; if(TYPE(connections) != T_ARRAY) { list = rb_ary_new(); rb_ary_push(list, connections); } else { list = connections; } if(TYPE(parameters) != T_ARRAY) { rb_fireruby_raise(NULL, "Invalid transaction parameter set specified."); } if(transaction != NULL) { VALUE value = rb_funcall(parameters, rb_intern("size"), 0); long size = 0, index; char *buffer = NULL; size = TYPE(value) == T_FIXNUM ? FIX2INT(value) : NUM2INT(value); if((buffer = ALLOC_N(char, size)) != NULL) { for(index = 0; index < size; index++) { VALUE entry = rb_ary_entry(parameters, index); int number = 0; number = TYPE(entry) == T_FIXNUM ? FIX2INT(entry) : NUM2INT(entry); buffer[index] = number; } startTransaction(transaction, list, size, buffer); free(buffer); instance = Data_Wrap_Struct(cTransaction, NULL, transactionFree, transaction); rb_iv_set(instance, "@connections", list); rb_tx_started(instance, connections); } else {
void LLFloaterBuyLandUI::updateWebSiteInfo() { S32 askBillableArea = mIsForGroup ? 0 : mParcelBillableArea; S32 askCurrencyBuy = mCurrency.getAmount(); if (mTransaction && mTransactionType == TransactionPreflight && mPreflightAskBillableArea == askBillableArea && mPreflightAskCurrencyBuy == askCurrencyBuy) { return; } mPreflightAskBillableArea = askBillableArea; mPreflightAskCurrencyBuy = askCurrencyBuy; #if 0 // enable this code if you want the details to blank while we're talking // to the web site... it's kind of jarring mSiteValid = false; mSiteMembershipUpgrade = false; mSiteMembershipAction = "(waiting)"; mSiteMembershipPlanIDs.clear(); mSiteMembershipPlanNames.clear(); mSiteLandUseUpgrade = false; mSiteLandUseAction = "(waiting)"; mSiteCurrencyEstimated = false; mSiteCurrencyEstimatedCost = 0; #endif LLXMLRPCValue keywordArgs = LLXMLRPCValue::createStruct(); keywordArgs.appendString("agentId", gAgent.getID().asString()); keywordArgs.appendString( "secureSessionId", gAgent.getSecureSessionID().asString()); keywordArgs.appendString("language", LLUI::getLanguage()); keywordArgs.appendInt("billableArea", mPreflightAskBillableArea); keywordArgs.appendInt("currencyBuy", mPreflightAskCurrencyBuy); LLXMLRPCValue params = LLXMLRPCValue::createArray(); params.append(keywordArgs); startTransaction(TransactionPreflight, params); }
/* Return register content from bank A & B of a 16 bit GPIO chip, combined in a 16 bit data. An 8 Bit chip will return always bank A. Parameters reg: a legal 8bit MCP23Sxx register. */ uint16_t gpio_MCP23SXX::gpioReadRegisterBoth(byte reg) { if (_ports < 16){ return gpioReadRegister(reg); } else { uint16_t result = 0; #if defined(SPI_LEGACY_METHOD) startTransaction(); writeByte_cont(_readCmd); writeByte_cont(reg); #if defined(SPI_HAS_TRANSACTION) setSpiSettings(SPISettings(10000000, MSBFIRST, SPI_MODE0)); result = readWord_cont(); setSpiSettings(SPISettings(_maxGpioSPIspeed, MSBFIRST, SPI_MODE0)); #else result = readWord_cont(); #endif disableCS(); endTransaction(); #else _spi.startTransaction(); _spi.writeByte_cont(_readCmd); _spi.writeByte_cont(reg); #if (defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__)) _spi.waitTransmitComplete(); #endif #if defined(SPI_HAS_TRANSACTION) _spi.setSpiSettings(SPISettings(10000000, MSBFIRST, SPI_MODE0)); result = _spi.readWord_cont(false);//command mode _spi.setSpiSettings(SPISettings(_maxGpioSPIspeed, MSBFIRST, SPI_MODE0)); #else result = _spi.readWord_cont(false);//command mode #endif #if (defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__)) _spi.writeByte_last(0xFF);//NOP? #else _spi.disableCS(); #endif _spi.endTransaction(); #endif return result; } }
bool DatabaseManager::insertBanners(QList<QMap<QString, QString> > banners, int seriesId) { qDebug() << "insertBanners() "; bool ret = false; startTransaction(); auto length = banners.size(); for (int i = 0; i < length; ++i) { auto banner = banners.at(i); int id = banner["id"].toInt(); QString bannerPath = banner["BannerPath"]; QString bannerType = banner["BannerType"]; QString bannerType2 = banner["BannerType2"]; QString language = banner["Language"]; int season = banner["Season"].toInt(); if (m_db.isOpen()) { QSqlQuery query(m_db); query.prepare("INSERT OR REPLACE INTO Banner (id, seriesID, bannerPath, bannerType, bannerType2, language, season) " "VALUES (:id, :seriesId, :bannerPath, :bannerType, :bannerType2, :language, :season)"); query.bindValue(":id", id); query.bindValue(":seriesId", seriesId); query.bindValue(":bannerPath", bannerPath); query.bindValue(":bannerType", bannerType); query.bindValue(":bannerType2", bannerType2); query.bindValue(":language", language); query.bindValue(":season", season); ret = query.exec(); } // process pending events to not freeze the app qApp->processEvents(QEventLoop::ExcludeUserInputEvents); } commit(); return ret; }
static stList *bulkGetRecordsRange(stKVDatabase *database, int64_t firstKey, int64_t numRecords) { stList* results = stList_construct3(numRecords, (void(*)(void *))stKVDatabaseBulkResult_destruct); startTransaction(database); stTry { for (int32_t i = 0; i < numRecords; ++i) { int64_t key = firstKey + i; int64_t recordSize; void* record = getRecord2(database, key, &recordSize); stKVDatabaseBulkResult* result = stKVDatabaseBulkResult_construct(record, recordSize); stList_set(results, i, result); } commitTransaction(database); }stCatch(ex) { abortTransaction(database); stThrowNewCause(ex, ST_KV_DATABASE_EXCEPTION_ID, "tokyo cabinet bulk get records failed"); }stTryEnd; return results; }