bool DataOp::updateRecord(QString record) { QString id, oldRecord; id = getId(record); //保存旧数据 oldRecord = selectRecord(id); if(oldRecord==""){ qDebug() << "更新失败,未找到该条数据"<< record; return 0; } //删除原记录 if(!deleteRecord(getId(record))){ return 0; } //添加新记录 if(!insertRecord(record)){ qDebug() << "更新失败,尝试恢复旧数据"; if(!insertRecord(oldRecord)){ qDebug() << "数据重大错误"; } return 0; }else{ return 1; } return 0; }
void run() { string ns = "unittests.rollback_drop_index"; const ServiceContext::UniqueOperationContext opCtxPtr = cc().makeOperationContext(); OperationContext& opCtx = *opCtxPtr; NamespaceString nss(ns); dropDatabase(&opCtx, nss); createCollection(&opCtx, nss); AutoGetDb autoDb(&opCtx, nss.db(), MODE_X); Collection* coll = autoDb.getDb()->getCollection(&opCtx, nss); IndexCatalog* catalog = coll->getIndexCatalog(); string idxName = "a"; BSONObj spec = BSON("ns" << ns << "key" << BSON("a" << 1) << "name" << idxName << "v" << static_cast<int>(kIndexVersion)); { WriteUnitOfWork uow(&opCtx); ASSERT_OK(catalog->createIndexOnEmptyCollection(&opCtx, spec)); insertRecord(&opCtx, nss, BSON("a" << 1)); insertRecord(&opCtx, nss, BSON("a" << 2)); insertRecord(&opCtx, nss, BSON("a" << 3)); uow.commit(); } ASSERT(indexReady(&opCtx, nss, idxName)); ASSERT_EQ(3u, getNumIndexEntries(&opCtx, nss, idxName)); // END SETUP / START TEST { WriteUnitOfWork uow(&opCtx); dropIndex(&opCtx, nss, idxName); ASSERT(!indexExists(&opCtx, nss, idxName)); if (!rollback) { uow.commit(); } } if (rollback) { ASSERT(indexExists(&opCtx, nss, idxName)); ASSERT(indexReady(&opCtx, nss, idxName)); ASSERT_EQ(3u, getNumIndexEntries(&opCtx, nss, idxName)); } else { ASSERT(!indexExists(&opCtx, nss, idxName)); } }
int insertNode(tokStr token, dirStr path, treeNode **root) { if( (*root) == NULL) { (*root) = (treeNode*)malloc(sizeof(treeNode)); (*root)->token = string_init(token); (*root)->left = NULL; (*root)->right = NULL; (*root)->pathRecords = NULL; } else { int cmpVar; cmpVar = strcmp(token, (*root)->token); if(cmpVar < 0) { insertNode(token, path, &((*root)->left)); return 0; } if(cmpVar > 0) { insertNode(token, path, &((*root)->right)); return 0; } } insertRecord(path, &((*root)->pathRecords)); return 0; }
int insertRecord(dirStr path, pathList **root) { if( (*root) == NULL) { (*root) = malloc(sizeof(pathList)); (*root)->path = string_init(path); (*root)->count = 1; (*root)->next = NULL; } else { int cmpPath = strcmp( path, (*root)->path ); if(cmpPath == 0) { (*root)->count += 1; } else { insertRecord(path, &((*root)->next) ); } } return 0; }
// ************************************************************ void testCreateTableAndInsert (void) { RM_TableData *table = (RM_TableData *) malloc(sizeof(RM_TableData)); TestRecord inserts[] = { {1, "aaaa", 3}, {2, "bbbb", 2}, {3, "cccc", 1}, {4, "dddd", 3}, {5, "eeee", 5}, {6, "ffff", 1}, {7, "gggg", 3}, {8, "hhhh", 3}, {9, "iiii", 2} }; int numInserts = 9, i; Record *r; RID *rids; Schema *schema; testName = "test creating a new table and inserting tuples"; schema = testSchema(); rids = (RID *) malloc(sizeof(RID) * numInserts); TEST_CHECK(initRecordManager(NULL)); //printf("\n Testing create table"); TEST_CHECK(createTable("test_table_r.txt",schema)); //printf("\n Testing open Table"); TEST_CHECK(openTable(table, "test_table_r.txt")); printf("\n Opened "); // insert rows into table for(i = 0; i < numInserts; i++) { printf("\n Inserting"); r = fromTestRecord(schema, inserts[i]); TEST_CHECK(insertRecord(table,r)); rids[i] = r->id; } TEST_CHECK(closeTable(table)); TEST_CHECK(openTable(table, "test_table_r.txt")); printf("\n Opened successsfully"); // randomly retrieve records from the table and compare to inserted ones for(i = 0; i < 1000; i++) { int pos = rand() % numInserts; RID rid = rids[pos]; printf("\n getting records"); TEST_CHECK(getRecord(table, rid, r)); ASSERT_EQUALS_RECORDS(fromTestRecord(schema, inserts[pos]), r, schema, "compare records"); } TEST_CHECK(closeTable(table)); TEST_CHECK(deleteTable("test_table_r.txt")); TEST_CHECK(shutdownRecordManager()); free(rids); free(table); TEST_DONE(); }
// 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; }
int runSQLite(int clientSelect) { clientNumber=clientSelect; sqlite3 *db = NULL; int rc; //打开指定的数据库文件 rc = sqlite3_open("./data/DataBase.db",&db); if(rc) { fprintf(stderr,"can't open database: %s\n",sqlite3_errmsg(db)); sqlite3_close(db); exit(1); } else printf("You have opened a sqlite3 database successfully!\n"); //创建表 createTable(db); //插入记录 insertRecord(db); //查询 //使用sqlite3_get_table实现查询 //inquire_nocb(db); printf("--------------------------------\n"); //使用回调函数实现查询 inquire_Usecb(db); //删除记录 //deleteRecord(db); //关闭数据库 sqlite3_close(db); return 0; }
BOOL PContainer::setupItems() { PMINIRECORDCORE prec; RECORDINSERT ri; if (!getProcesses()) // OProcStat::getProcesses() OThrowPM("OProcStat::getProcesses() failed", 0, OException::unrecoverable); if ((prec = allocRecords(1)) == NULL) return(FALSE); prec->cb = sizeof(MINIRECORDCORE); prec->flRecordAttr = CRA_EXPANDED; prec->pszIcon = "OS2KRNL"; prec->hptrIcon = hptr; memset(&ri, 0, sizeof(RECORDINSERT)); ri.cb = sizeof(RECORDINSERT); ri.pRecordOrder = (PRECORDCORE) CMA_END; ri.pRecordParent = (PRECORDCORE) NULL; ri.zOrder = (USHORT) CMA_TOP; ri.cRecordsInsert = 1; ri.fInvalidateRecord = FALSE; // insert them in one shot insertRecord(prec, &ri); return((insertChilds(prec, 0)) && // insert childs of kernel (insertChilds(prec, 1)) && (setCnrInfo(CMA_LINESPACING | CMA_CXTREEINDENT)) && (invalidateRecord())); }
/*! \fn MPeluqueria::agregarServicio( QVariant desc, QVariant precio, QVariant fecha, QVariant id_mascota ) */ bool MPeluqueria::agregarServicio( QVariant desc, QVariant precio, QVariant fecha, QVariant id_mascota ) { /* if( !mascota.isValid() ) { qDebug( "Inidce Mascota es invalido" ); return false; } QVariant id_mascota = relationModel( 1 )->data( mascota, 0 ); if( id_mascota.isValid() && id_mascota.toInt() <= 0 ) {return false;}*/ QSqlRecord registro = record(); registro.setValue( 1, id_mascota ); registro.setValue( 2, desc ); registro.setValue( 3, precio ); registro.setValue( 4, fecha ); for( int i = 0; i<registro.count(); i++ ) { qDebug( QString( "Campo: %1, generado? %2, null? %3, valor? |%4|" ).arg( registro.fieldName( i ) ).arg( registro.isGenerated( i ) ).arg( registro.isNull( i ) ).arg( registro.value( i ).toString() ).toLocal8Bit() ); } if( insertRecord( -1, registro ) ) { qDebug( "Registro de servicio agregado correctamente" ); return true; } else { qDebug( "Error al insertar registro de servicio de mascota" ); qDebug( QString( "Detalles: tipo: %1, errno: %2, descripcion: %3" ).arg( lastError().type() ).arg( lastError().number() ).arg( lastError().text() ).toLocal8Bit() ); return false; } }
StatusWith<RecordId> KVRecordStore::insertRecord(OperationContext* txn, const DocWriter* doc, bool enforceQuota) { Slice value(doc->documentSize()); doc->writeDocument(value.mutableData()); return insertRecord(txn, value.data(), value.size(), enforceQuota); }
bool DailymotionAccountModel::addAccount(const QString &userId, const QString &username, const QString &accessToken, const QString &refreshToken, const QString &scopes) { QSqlField userIdField("userId", QVariant::String); userIdField.setValue(userId); QSqlField usernameField("username", QVariant::String); usernameField.setValue(username); QSqlField accessTokenField("accessToken", QVariant::String); accessTokenField.setValue(accessToken); QSqlField refreshTokenField("refreshToken", QVariant::String); refreshTokenField.setValue(refreshToken); QSqlField scopesField("scopes", QVariant::String); scopesField.setValue(scopes); QSqlRecord record; record.append(userIdField); record.append(usernameField); record.append(accessTokenField); record.append(refreshTokenField); record.append(scopesField); if (insertRecord(-1, record)) { Dailymotion::instance()->setUserId(userId); const int count = rowCount(); emit dataChanged(index(0, 0), index(count - 1, columnCount() - 1)); emit countChanged(count); return true; } return false; }
StatusWith<RecordId> KVRecordStoreCapped::insertRecord( OperationContext* txn, const DocWriter* doc, bool enforceQuota ) { // We need to override every insertRecord overload, otherwise the compiler gets mad. Slice value(doc->documentSize()); doc->writeDocument(value.mutableData()); return insertRecord(txn, value.data(), value.size(), enforceQuota); }
void *insertRandRecThread(void *arg) { while(!exit_thread) { insertRecord(rand() % 10000); sleep(1); } }
static void setRecord(stKVDatabase *database, int64_t key, const void *value, int64_t sizeOfRecord) { if (containsRecord(database, key)) { updateRecord(database, key, value, sizeOfRecord); } else { insertRecord(database, key, value, sizeOfRecord); } }
StatusWith<DiskLoc> RocksRecordStore::insertRecord( OperationContext* txn, const DocWriter* doc, bool enforceQuota ) { const int len = doc->documentSize(); boost::scoped_array<char> buf( new char[len] ); doc->writeDocument( buf.get() ); return insertRecord( txn, buf.get(), len, enforceQuota ); }
int DatabaseManager::saveBook(PersistentObject *theBook){ // if(BookObjec) is the right table insertRecord(theBook->getIndexAttribut(0)->variable.toString(), theBook->getIndexAttribut(1)->variable.toString(), theBook->getIndexAttribut(2)->variable.toString(), theBook->getIndexAttribut(3)->variable.toString()); return 0; }
status_t DrmKernel_NvDrmPlugin_onSaveRights(int uniqueId, const struct NV_DrmRights_st *drmRights, const char *rightsPath, const char *contentId) { ALOGV("DrmKernel_NvDrmPlugin_onSaveRights - Entry"); ALOGV("uniqueId = %d", uniqueId); ALOGV("rightsPath = '%s'", rightsPath); ALOGV("contentId = '%s'", contentId); status_t retVal = NV_DRM_ERROR_UNKNOWN; SecureRecord record; uint8_t *dataptr = (uint8_t *)drmRights->data->data; record._key = contentId; dataptr += strlen(contentId) +1; ALOGV("DrmKernel_NvDrmPlugin_onSaveRights - index = %d", (dataptr - (uint8_t *)drmRights->data->data)); record._keyId = dataptr; dataptr += AES_BLOCK_SIZE; ALOGV("DrmKernel_NvDrmPlugin_onSaveRights - index = %d", (dataptr - (uint8_t *)drmRights->data->data)); record._contentKeySize = *dataptr << 8; dataptr++; ALOGV("DrmKernel_NvDrmPlugin_onSaveRights - index = %d", (dataptr - (uint8_t *)drmRights->data->data)); record._contentKeySize += *dataptr; dataptr++; ALOGV("DrmKernel_NvDrmPlugin_onSaveRights - index = %d", (dataptr - (uint8_t *)drmRights->data->data)); ALOGV("DrmKernel_NvDrmPlugin_onSaveRights - key size = %d", record._contentKeySize); record._contentKey = USTR(dataptr); dataptr += record._contentKeySize; ALOGV("DrmKernel_NvDrmPlugin_onSaveRights - index = %d", (dataptr - (uint8_t *)drmRights->data->data)); record._tag = USTR(dataptr); record._tagSize = (unsigned int)drmRights->data->length - (dataptr - (uint8_t *)drmRights->data->data); ALOGV("DrmKernel_NvDrmPlugin_onSaveRights - index = %d", (dataptr - (uint8_t *)drmRights->data->data)); ALOGV("DrmKernel_NvDrmPlugin_onSaveRights - tag size = %d", record._tagSize); ALOGV("record.key = %s", record._key); ALOGV("record.contentKeySize = %d", record._contentKeySize); ALOGV("record.tagSize = %d", record._tagSize); if (insertRecord(&mDatabaseConnection, &record)) { retVal = NV_NO_ERROR; ALOGV("DrmKernel_NvDrmPlugin_onSaveRights() - Rights saved"); } else ALOGE("DrmKernel_NvDrmPlugin_onSaveRights() - Unable to save rights"); ALOGV("DrmKernel_NvDrmPlugin_onSaveRights - Exit (%d)", retVal); return retVal; }
void BookmarkModel::insert(const QString& name, const QString& url) { if (contains(url)) return; QSqlRecord record = this->record(); record.setValue("name", name); record.setValue("url", url); insertRecord(-1, record); }
StatusWith<RecordId> TerarkDbRecordStore::insertRecord(OperationContext* txn, const DocWriter* doc, bool enforceQuota) { const int len = doc->documentSize(); std::unique_ptr<char[]> buf(new char[len]); doc->writeDocument(buf.get()); return insertRecord(txn, buf.get(), len, enforceQuota); }
//Ìî³äPBFriendAgreeReceive int cProcUserAgreeFriend::setPBFriendAgreeReceive(PBFriendAgreeReceive& u_PBFriendAgreeReceive,const string& u_strToken,\ const unsigned int& u_friendId) { unsigned int u_userId = 0; int u_result = 0; if (!getUserIdbyToken(u_strToken,u_userId)) { g_cMyGlog.errorlogRecord("procUserAddFriend getUserIdbyToken error:Token:%s\n",u_strToken.c_str()); return K_ACCOUNT_UNNORMAL; } if (!isUserExist(u_friendId)) { deleteRecord(u_userId,u_friendId); return K_FRIEND_IS_NOT_EXIST; } if (hasHistoryRecord(u_userId,u_friendId)) { deleteRecord(u_userId,u_friendId); return K_OPPOSIT_IS_FRIEND; } else { if (!insertRecord(u_userId,u_friendId) || !insertRecord(u_friendId,u_userId)) { u_result = -1; } else { deleteRecord(u_userId,u_friendId); u_PBFriendAgreeReceive.set_agreeresult(ADD_FRIEND_SUCCESS); PBWaitingFriend* u_PBWaitingFriend; u_PBWaitingFriend = u_PBFriendAgreeReceive.mutable_waitings(); g_cProcUserWaitingFriend.getUserWaitingFriend(*u_PBWaitingFriend,u_userId); PBAllFriend* u_PBAllFriend; u_PBAllFriend = u_PBFriendAgreeReceive.mutable_friends(); g_cProcUserGetAllFriend.getAllFriendByUserId(*u_PBAllFriend,u_userId); } } return u_result; }
RC testTombstone(void) { RM_TableData *table = (RM_TableData *)malloc(sizeof(RM_TableData)); TestRecord inserts[] = { { 1, "aaaa", 3 }, { 2, "bbbb", 2 }, { 3, "cccc", 1 }, { 4, "dddd", 3 }, { 5, "eeee", 5 }, { 6, "ffff", 1 }, { 7, "gggg", 3 }, { 8, "hhhh", 3 }, { 9, "iiii", 2 }, { 10, "jjjj", 5 }, }; int numInserts = 10, numUpdates = 3, numDeletes = 5, numFinal = 5, i; Record *r; RID *rids; Schema *schema; testName = "test creating a new table and insert,update,delete tuples"; schema = testSchema(); rids = (RID *)malloc(sizeof(RID) * numInserts); TEST_CHECK(initRecordManager(NULL)); TEST_CHECK(createTable("test_table_r", schema)); TEST_CHECK(openTable(table, "test_table_r")); // insert rows into table for (i = 0; i < numInserts; i++) { r = fromTestRecord(schema, inserts[i]); TEST_CHECK(insertRecord(table, r)); rids[i] = r->id; } TEST_CHECK(deleteRecord(table, rids[9])); RID id; id.page = rids[9].page; id.slot = rids[10].slot; int isTombstone = checkIfTombstoneEncountered(table, rids[9]); TEST_CHECK(closeTable(table)); TEST_CHECK(deleteTable("test_table_r")); TEST_CHECK(shutdownRecordManager()); free(table); if (isTombstone == 1) { return RC_OK; } else { return RC_NOT_A_TOMBSTONE; } }
BOOL MyContainer::setupItems() { pCnrRecord pcn; HPOINTER hptr; if (isEmpty()) return(TRUE); hptr = WinLoadPointer(HWND_DESKTOP, 0, SAMPLE_MAIN); pcn = allocRecords(numberOfElements()); if(pcn) { RECORDINSERT ri; ULONG counter = 1; pCnrRecord pcnFirst = pcn; pMyRecord record = getFirst(); while(record) { record->Position = counter; pcn->recordCore.cb = sizeof(RECORDCORE); pcn->recordCore.pszText = record->Name; pcn->recordCore.pszIcon = record->Name; pcn->recordCore.pszName = record->Name; pcn->recordCore.hptrIcon = hptr; pcn->Name = record->Name; pcn->Position = record->Position; pcn = (pCnrRecord) pcn->recordCore.preccNextRecord; record = getNext(); counter++; } memset(&ri, 0, sizeof(RECORDINSERT)); ri.cb = sizeof(RECORDINSERT); ri.pRecordOrder = (PRECORDCORE) CMA_END; ri.pRecordParent = (PRECORDCORE) NULL; ri.zOrder = (USHORT) CMA_TOP; ri.cRecordsInsert = numberOfElements(); ri.fInvalidateRecord = TRUE; // insert them in one shot if (insertRecord(pcnFirst, &ri)) { WinSendMsg(parent, WM_CNR_STATUS, MPFROMP("Completed."), NULL); return(TRUE); } } return(FALSE); }
void FilesCnr::insertFiles(PFILEFINDBUF3 pffb, ULONG cFiles) { PBYTE pbBuf = (PBYTE) pffb; pFileInfo pfiFirst, pfi; ULONG i; PFILEFINDBUF3 pffbFile; RECORDINSERT ri; if (!cFiles) return; pfi = allocRecords(cFiles); pfiFirst = pfi; for(i = 0; i < cFiles; i++) { pffbFile = (PFILEFINDBUF3) pbBuf; pFileItem item = new FileItem; item->fullName << scanDirectory; item->fullName + "\\" + pffbFile->achName; item->name << pffbFile->achName; pfi->rc.pszIcon = item->name.text; pfi->fileItem = item; pfi->rc.hptrIcon = file_ico.hptr; pfi->date.day = pffbFile->fdateLastWrite.day; pfi->date.month = pffbFile->fdateLastWrite.month; pfi->date.year = pffbFile->fdateLastWrite.year + 80; pfi->time.seconds = pffbFile->ftimeLastWrite.twosecs; pfi->time.minutes = pffbFile->ftimeLastWrite.minutes; pfi->time.hours = pffbFile->ftimeLastWrite.hours; pfi->cbFile = pffbFile->cbFile; FileList.add(item); pfi = (pFileInfo) pfi->rc.preccNextRecord; // Get the next container record pbBuf += pffbFile->oNextEntryOffset; // Point to the next file in the buffer } memset(&ri, 0, sizeof( RECORDINSERT)); ri.cb = sizeof(RECORDINSERT); ri.pRecordOrder = (PRECORDCORE) CMA_END; ri.pRecordParent = (PRECORDCORE) NULL; ri.zOrder = (USHORT) CMA_TOP; ri.cRecordsInsert = cFiles; ri.fInvalidateRecord = TRUE; insertRecord(pfiFirst, &ri); }
void CSMWorld::InfoCollection::load (const Info& record, bool base) { int index = searchId (record.mId); if (index==-1) { // new record Record<Info> record2; record2.mState = base ? RecordBase::State_BaseOnly : RecordBase::State_ModifiedOnly; (base ? record2.mBase : record2.mModified) = record; int index = -1; std::string topic = Misc::StringUtils::lowerCase (record2.get().mTopicId); if (!record2.get().mPrev.empty()) { index = getInfoIndex (record2.get().mPrev, topic); if (index!=-1) ++index; } if (index==-1 && !record2.get().mNext.empty()) { index = getInfoIndex (record2.get().mNext, topic); } if (index==-1) { Range range = getTopicRange (topic); index = std::distance (getRecords().begin(), range.second); } insertRecord (record2, index); } else { // old record Record<Info> record2 = getRecord (index); if (base) record2.mBase = record; else record2.setModified (record); setRecord (index, record2); } }
void run() { NamespaceString nss("unittests.rollback_truncate_collection"); const ServiceContext::UniqueOperationContext opCtxPtr = cc().makeOperationContext(); OperationContext& opCtx = *opCtxPtr; dropDatabase(&opCtx, nss); Lock::DBLock dbXLock(&opCtx, nss.db(), MODE_X); OldClientContext ctx(&opCtx, nss.ns()); BSONObj doc = BSON("_id" << "foo"); ASSERT(!collectionExists(&ctx, nss.ns())); { WriteUnitOfWork uow(&opCtx); ASSERT_OK(userCreateNS(&opCtx, ctx.db(), nss.ns(), BSONObj(), CollectionOptions::parseForCommand, defaultIndexes)); ASSERT(collectionExists(&ctx, nss.ns())); insertRecord(&opCtx, nss, doc); assertOnlyRecord(&opCtx, nss, doc); uow.commit(); } assertOnlyRecord(&opCtx, nss, doc); // END OF SETUP / START OF TEST { WriteUnitOfWork uow(&opCtx); ASSERT_OK(truncateCollection(&opCtx, nss)); ASSERT(collectionExists(&ctx, nss.ns())); assertEmpty(&opCtx, nss); if (!rollback) { uow.commit(); } } ASSERT(collectionExists(&ctx, nss.ns())); if (rollback) { assertOnlyRecord(&opCtx, nss, doc); } else { assertEmpty(&opCtx, nss); } }
void readGroup(reader_s &reader) { DENG_ASSERT(version >= 1); // Read the group header. int num = Reader_ReadUInt16(&reader); // Read the group records. Uri uri; for(int i = 0; i < num; ++i) { readArchivedUri(uri, version, reader); insertRecord(uri); } }
bool SoundCloudAccountModel::addAccount(const QString &userId, const QString &username, const QString &accessToken, const QString &refreshToken, const QString &scopes) { Logger::log(QString("SoundCloudAccountModel::addAccount(). User ID: %1, Username: %2, Access token: %3, Refresh token: %4, Scopes: %5").arg(userId).arg(username).arg(accessToken).arg(refreshToken).arg(scopes), Logger::LowVerbosity); QSqlField userIdField("userId", QVariant::String); userIdField.setValue(userId); QSqlField usernameField("username", QVariant::String); usernameField.setValue(username); QSqlField accessTokenField("accessToken", QVariant::String); accessTokenField.setValue(accessToken); QSqlField refreshTokenField("refreshToken", QVariant::String); refreshTokenField.setValue(refreshToken); QSqlField scopesField("scopes", QVariant::String); scopesField.setValue(scopes); QSqlRecord record; record.append(userIdField); record.append(usernameField); record.append(accessTokenField); record.append(refreshTokenField); record.append(scopesField); const int count = rowCount(); for (int i = 0; i < count; i++) { if (data(index(i, 0)) == userId) { if (setRecord(i, record)) { SoundCloud::setUserId(userId); return true; } return false; } } if (insertRecord(-1, record)) { SoundCloud::setUserId(userId); const int count = rowCount(); emit dataChanged(index(0, 0), index(count - 1, columnCount() - 1)); emit countChanged(count); return true; } return false; }
ASTNode* insertRecordDeclarations(ASTNode* AT, recordTable* record_table) { if(AT == NULL) return AT; AT->record_table = record_table; if(getNonTerminalfromStr("<typeDefinition>") != AT->nodeid) { int i; for (i = 0; i < AT->child_cnt; ++i) AT->children[i] = insertRecordDeclarations(AT->children[i], record_table); return AT; } insertRecord(AT->children[1]->tk.lexeme, record_table); AT->children[2] = insertRecordEntries(AT->children[2], AT->children[1]->tk.lexeme, record_table); return AT; }
bool FilmModel::addFilm(Film &f) { QSqlRecord r = record(); r.setValue("name", f.name); r.setValue("year", f.year); r.setValue("country", f.country); r.setValue("director", f.director); r.setValue("actors", f.actors); r.setValue("type", f.type); r.setValue("genre", f.genre); r.setValue("score", f.score); r.setValue("poster", ""); insertRecord(-1, r); bool resSubmit = submitAll(); return resSubmit; }
void run() { NamespaceString nss("unittests.rollback_create_drop_collection"); const ServiceContext::UniqueOperationContext opCtxPtr = cc().makeOperationContext(); OperationContext& opCtx = *opCtxPtr; dropDatabase(&opCtx, nss); Lock::DBLock dbXLock(&opCtx, nss.db(), MODE_X); OldClientContext ctx(&opCtx, nss.ns()); BSONObj doc = BSON("_id" << "example string"); ASSERT(!collectionExists(&ctx, nss.ns())); { WriteUnitOfWork uow(&opCtx); ASSERT_OK(userCreateNS(&opCtx, ctx.db(), nss.ns(), BSONObj(), CollectionOptions::parseForCommand, defaultIndexes)); ASSERT(collectionExists(&ctx, nss.ns())); insertRecord(&opCtx, nss, doc); assertOnlyRecord(&opCtx, nss, doc); BSONObjBuilder result; ASSERT_OK( dropCollection(&opCtx, nss, result, {}, DropCollectionSystemCollectionMode::kDisallowSystemCollectionDrops)); ASSERT(!collectionExists(&ctx, nss.ns())); if (!rollback) { uow.commit(); } } ASSERT(!collectionExists(&ctx, nss.ns())); }