int applyInstruction(const Instruction* instr, sqlite3* db) { switch(instr->iType) { case SQLITE_INSERT: return applyInsert(db, instr); case SQLITE_UPDATE: return applyUpdate(db, instr); case SQLITE_DELETE: return applyDelete(db, instr); default: return CHANGESET_CORRUPT; } }
// apply but do not close void MConfig::on_buttonApply_clicked() { if (!buttonApply->isEnabled()) { return; } int i = tabWidget->currentIndex(); switch (i) { case 1: setCursor(QCursor(Qt::WaitCursor)); applyRestore(); setCursor(QCursor(Qt::ArrowCursor)); buttonApply->setEnabled(false); break; case 2: applyDesktop(); buttonApply->setEnabled(false); break; case 3: setCursor(QCursor(Qt::WaitCursor)); applyGroup(); setCursor(QCursor(Qt::ArrowCursor)); buttonApply->setEnabled(false); break; case 4: setCursor(QCursor(Qt::WaitCursor)); applyMembership(); setCursor(QCursor(Qt::ArrowCursor)); break; default: setCursor(QCursor(Qt::WaitCursor)); if (addUserBox->isEnabled()) { applyAdd(); } else { applyDelete(); buttonApply->setEnabled(false); } setCursor(QCursor(Qt::ArrowCursor)); break; } }
bool WriteBatchExecutor::applyWriteItem(const string& ns, const WriteBatch::WriteItem& writeItem, BSONObjBuilder* results) { // Clear operation's LastError before starting. _le->reset(true); uint64_t itemTimeMicros = 0; bool opSuccess = true; // Each write operation executes in its own PageFaultRetryableSection. This means that // a single batch can throw multiple PageFaultException's, which is not the case for // other operations. PageFaultRetryableSection s; while (true) { try { // Execute the write item as a child operation of the current operation. CurOp childOp(_client, _client->curop()); // TODO Modify CurOp "wrapped" constructor to take an opcode, so calling .reset() // is unneeded childOp.reset(_client->getRemote(), getOpCode(writeItem.getWriteType())); childOp.ensureStarted(); OpDebug& opDebug = childOp.debug(); opDebug.ns = ns; { Client::WriteContext ctx(ns); switch(writeItem.getWriteType()) { case WriteBatch::WRITE_INSERT: opSuccess = applyInsert(ns, writeItem, &childOp); break; case WriteBatch::WRITE_UPDATE: opSuccess = applyUpdate(ns, writeItem, &childOp); break; case WriteBatch::WRITE_DELETE: opSuccess = applyDelete(ns, writeItem, &childOp); break; } } childOp.done(); itemTimeMicros = childOp.totalTimeMicros(); opDebug.executionTime = childOp.totalTimeMillis(); opDebug.recordStats(); // Log operation if running with at least "-v", or if exceeds slow threshold. if (logger::globalLogDomain()->shouldLog(logger::LogSeverity::Debug(1)) || opDebug.executionTime > cmdLine.slowMS + childOp.getExpectedLatencyMs()) { MONGO_TLOG(1) << opDebug.report(childOp) << endl; } // TODO Log operation if logLevel >= 3 and assertion thrown (as assembleResponse() // does). // Save operation to system.profile if shouldDBProfile(). if (childOp.shouldDBProfile(opDebug.executionTime)) { profile(*_client, getOpCode(writeItem.getWriteType()), childOp); } break; } catch (PageFaultException& e) { e.touch(); } } // Fill caller's builder with results of operation, using LastError. results->append("ok", opSuccess); _le->appendSelf(*results, false); results->append("micros", static_cast<long long>(itemTimeMicros)); return opSuccess; }