1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-14 00:22:38 +03:00

Modify the OS layer so that I/O routines are called through a virtual function

table.  The os_test.c module has been replaced by test6.c.  The crash tests
are busted now and need to be fixed. (CVS 2785)

FossilOrigin-Name: 1f69aec285dd8e26bd739d5e44bb50fe03a9682a
This commit is contained in:
drh
2005-11-26 00:25:00 +00:00
parent aa2289f89c
commit 9c06c95309
18 changed files with 774 additions and 272 deletions

View File

@@ -273,7 +273,7 @@ static void resolveP2Values(Vdbe *p, int *pMaxFuncArgs, int *pMaxStack){
/* If we never rollback a statement transaction, then statement
** transactions are not needed. So change every OP_Statement
** opcode into an OP_Noop. This avoid a call to sqlite3OsOpenExclusive()
** opcode into an OP_Noop. This avoid a call to sqlite3Io.xOpenExclusive()
** which can be expensive on some platforms.
*/
if( hasStatementBegin && !doesStatementRollback ){
@@ -755,7 +755,7 @@ void sqlite3VdbeMakeReady(
#ifdef SQLITE_DEBUG
if( (p->db->flags & SQLITE_VdbeListing)!=0
|| sqlite3OsFileExists("vdbe_explain")
|| sqlite3Io.xFileExists("vdbe_explain")
){
int i;
printf("VDBE Program Listing:\n");
@@ -764,7 +764,7 @@ void sqlite3VdbeMakeReady(
sqlite3VdbePrintOp(stdout, i, &p->aOp[i]);
}
}
if( sqlite3OsFileExists("vdbe_trace") ){
if( sqlite3Io.xFileExists("vdbe_trace") ){
p->trace = stdout;
}
#endif
@@ -978,11 +978,11 @@ static int vdbeCommit(sqlite3 *db){
if( !zMaster ){
return SQLITE_NOMEM;
}
}while( sqlite3OsFileExists(zMaster) );
}while( sqlite3Io.xFileExists(zMaster) );
/* Open the master journal. */
memset(&master, 0, sizeof(master));
rc = sqlite3OsOpenExclusive(zMaster, &master, 0);
rc = sqlite3Io.xOpenExclusive(zMaster, &master, 0);
if( rc!=SQLITE_OK ){
sqliteFree(zMaster);
return rc;
@@ -1003,10 +1003,10 @@ static int vdbeCommit(sqlite3 *db){
if( !needSync && !sqlite3BtreeSyncDisabled(pBt) ){
needSync = 1;
}
rc = sqlite3OsWrite(&master, zFile, strlen(zFile)+1);
rc = sqlite3Io.xWrite(&master, zFile, strlen(zFile)+1);
if( rc!=SQLITE_OK ){
sqlite3OsClose(&master);
sqlite3OsDelete(zMaster);
sqlite3Io.xClose(&master);
sqlite3Io.xDelete(zMaster);
sqliteFree(zMaster);
return rc;
}
@@ -1018,11 +1018,11 @@ static int vdbeCommit(sqlite3 *db){
** the master journal file is store in so that it gets synced too.
*/
zMainFile = sqlite3BtreeGetDirname(db->aDb[0].pBt);
rc = sqlite3OsOpenDirectory(zMainFile, &master);
rc = sqlite3Io.xOpenDirectory(zMainFile, &master);
if( rc!=SQLITE_OK ||
(needSync && (rc=sqlite3OsSync(&master,0))!=SQLITE_OK) ){
sqlite3OsClose(&master);
sqlite3OsDelete(zMaster);
(needSync && (rc=sqlite3Io.xSync(&master,0))!=SQLITE_OK) ){
sqlite3Io.xClose(&master);
sqlite3Io.xDelete(zMaster);
sqliteFree(zMaster);
return rc;
}
@@ -1042,23 +1042,23 @@ static int vdbeCommit(sqlite3 *db){
if( pBt && sqlite3BtreeIsInTrans(pBt) ){
rc = sqlite3BtreeSync(pBt, zMaster);
if( rc!=SQLITE_OK ){
sqlite3OsClose(&master);
sqlite3Io.xClose(&master);
sqliteFree(zMaster);
return rc;
}
}
}
sqlite3OsClose(&master);
sqlite3Io.xClose(&master);
/* Delete the master journal file. This commits the transaction. After
** doing this the directory is synced again before any individual
** transaction files are deleted.
*/
rc = sqlite3OsDelete(zMaster);
rc = sqlite3Io.xDelete(zMaster);
assert( rc==SQLITE_OK );
sqliteFree(zMaster);
zMaster = 0;
rc = sqlite3OsSyncDirectory(zMainFile);
rc = sqlite3Io.xSyncDirectory(zMainFile);
if( rc!=SQLITE_OK ){
/* This is not good. The master journal file has been deleted, but
** the directory sync failed. There is no completely safe course of