コード例 #1
0
ファイル: BANDB.C プロジェクト: LiXT7891/courses
void BANDB::openDB(char* dbName, char* logName) {
	// Start buffer and log managers
	bm->start(dbName);
	lm->start(logName);
	// Now the log manager has done all txnTable rebuilding and
	// all redo work, so we can rollback incomplete Txns
	for (int i = 0; i < 255; i++) {
		TxnRecord rec = lm->txnTable.records[i];
		if (rec.transID != 0) {
			// For all the transactions
			if (rec.state == 3) {
				// If it is committed but not ended, write the end record
				lm->writeEndRecord(rec.transID);
			}
			else if (rec.state != 5) {
				// Otherwise, if it is not an ended Txn, its a looser
				rollbackWork(rec.transID);
				lm->writeEndRecord(rec.transID);
			}
		}
	}
	// Harden All Pages
	bm->pageOut(0);
	bm->pageOut(1);
}
コード例 #2
0
ファイル: BANDB.C プロジェクト: LiXT7891/courses
void BANDB::createDB(char* dbName, char* logName) {
	// Create db and log files, start buffer and log managers
	fm->create(dbName);
	fm->create(logName);
	bm->start(dbName);
	lm->start(logName);
}