diff --git a/manifest b/manifest index dba6635dd7..b965ba5329 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\slegacy\sjournal\sformats.\s(CVS\s1549) -D 2004-06-09T19:03:55 +C Turn\son\sthe\satomic\smultifile\scommit\slogic.\s\sIt\sdoes\snot\swork\sright\syet,\sbut\nit\shas\sat\sleast\sstopped\sfailing\sasserts.\s(CVS\s1550) +D 2004-06-09T20:03:09 F Makefile.in ab7b0d5118e2da97bac66be8684a1034e3500f5a F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd @@ -25,7 +25,7 @@ F sqlite.def fc4f5734786fe4743cfe2aa98eb2da4b089edb5f F sqlite.pc.in 30552343140c53304c2a658c080fbe810cd09ca2 F src/attach.c 93b8ecec4a8d7b4e9f2479e2327d90c9d01765e8 F src/auth.c 5c2f0bea4729c98c2be3b69d6b466fc51448fe79 -F src/btree.c 7526d697cad3fbf731a9238d047337581d19b43b +F src/btree.c 281af87aa117de024f5b6c2728a2339cba9ef584 F src/btree.h 589427ac13bb544d298cd99726e2572a6fe4bdaa F src/build.c 4ea78aba171f02b96254dd7a312e4266d3693bfe F src/date.c 8e6fa3173386fb29fdef012ee08a853c1e9908b2 @@ -37,7 +37,7 @@ F src/hash.c 440c2f8cb373ee1b4e13a0988489c7cd95d55b6f F src/hash.h 762d95f1e567664d1eafc1687de755626be962fb F src/insert.c 4268d9e3959cc845ea243fb4ec7507269404dad9 F src/legacy.c ad23746f15f67e34577621b1875f639c94839e1f -F src/main.c 8a7725b40fbe645883b2162aee782ad1063435b4 +F src/main.c 3df17ac486ff1772af8b537cf0bbd0aabba6e863 F src/md5.c 4302e84ae516c616bb079c4e6d038c0addb33481 F src/os.h 23c69c5084e71b5fe199ff1c4e35a4aded0f1380 F src/os_common.h 6393ac67a3a7b4aea19ff17529980ecf77eb2348 @@ -47,7 +47,7 @@ F src/os_unix.c 1d6f3d1a87d4aa0e4490bcc47b3f0ff9b2e37e7a F src/os_unix.h 1cd6133cf66dea704b8646b70b2dfdcbdd9b3738 F src/os_win.c 6b8f9fcc683bb888e07fc485372803baa68faadb F src/os_win.h 004eec47b1780fcaf07420ddc2072294b698d48c -F src/pager.c 5c37b973e827d7a9a45070498356e67ee720f960 +F src/pager.c f93d104b61278246fb06859227ac5fd87e6a67f0 F src/pager.h ca8f293e1d623a7c628a1c5e0c6cf43d5bbb80bf F src/parse.y 097438674976355a10cf177bd97326c548820b86 F src/pragma.c 3251628662963f30a95133b19d59e4bc08226c76 @@ -56,7 +56,7 @@ F src/random.c eff68e3f257e05e81eae6c4d50a51eb88beb4ff3 F src/select.c 1f8355e702f109f6771f82a9bfe7aac4c82cbaf2 F src/shell.c ca519519dcbbc582f6d88f7d0e7583b857fd3469 F src/sqlite.h.in 6ad05abc7fd72da74691e1eb45f0eff4117eba4e -F src/sqliteInt.h c0a328c7567cdeebe14d7a4668f22946e281ebc9 +F src/sqliteInt.h f384e81fa635b6323aa6297011d9dc2d976868fb F src/table.c af14284fa36c8d41f6829e3f2819dce07d3e2de2 F src/tclsqlite.c f5c5116720baefb7de5d6acf18baedf1e42756cc F src/test1.c f78d6ac0675bc5db48dac9c5379c965bdadb9113 @@ -70,11 +70,11 @@ F src/update.c 259f06e7b22c684b2d3dda54a18185892d6e9573 F src/utf.c c2c8e445bfea724f3502609d6389fe66651f02ab F src/util.c e8629f04d920ae968fced709dc7a3a2c62b65ac4 F src/vacuum.c b921eb778842592e1fb48a9d4cef7e861103878f -F src/vdbe.c fec13be8b6f03158bfb3069c7bd6182eb3ef4fca +F src/vdbe.c 5896c7462adcb0a62255f4172d5809dc1b220949 F src/vdbe.h 46f74444a213129bc4b5ce40124dd8ed613b0cde F src/vdbeInt.h ab592f23ed5a1913f9a506bd7b76c5e39377942a F src/vdbeapi.c 4ac95766b0515538037a7aec172ed26142f97cf9 -F src/vdbeaux.c 5efecdafe745a90e7c5173403d0065bdd38395a7 +F src/vdbeaux.c 6412cbc491a51950eb6910647656929ea6aaeccc F src/vdbemem.c 04502b81039f9a2b1c9a096e894eecf6d4877508 F src/where.c 32578882a245f8ac3303c5cea4664cd51fc73891 F test/all.test 569a92a8ee88f5300c057cc4a8f50fbbc69a3242 @@ -132,7 +132,7 @@ F test/misuse.test 1095f26d1aed406c65e1d2eba651c4bb7c38cbff F test/notnull.test 7a08117a71e74b0321aaa937dbeb41a09d6eb1d0 F test/null.test c14d0f4739f21e929b8115b72bf0c765b6bb1721 F test/pager.test 548968643d91c1c43a3a3eb1a232e9ca87b4069e -F test/pager2.test 7ff175a28484fd324df9315dfe35f6fb159910ec +F test/pager2.test 55469c7c1c1a54d6b32d7b3cc99001e90101a1ce F test/pragma.test 1b6792d4af550ca4973096d77fc278dd6c32c4dd F test/printf.test 46b3d07d59d871d0831b4a657f6dfcafe0574850 F test/progress.test 7542a6ac7894a1b7730c1f9a27f3f8b9388a4d25 x @@ -218,7 +218,7 @@ F www/support.tcl 1801397edd271cc39a2aadd54e701184b5181248 F www/tclsqlite.tcl 19191cf2a1010eaeff74c51d83fd5f5a4d899075 F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9 F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4 -P dc0763455bbf54c1d8728e16033709caedd6e1c6 -R b4b9380769fdca06ed613331f57399e7 +P a12bef4a0877fb1dca531509a1186e092727b6d8 +R 701fea12013c3300eecc0127ba6ceafd U drh -Z 21a5c28788a000b1f8a2eec2e4e3d0e6 +Z 742136040c4805983d993b10276e9a39 diff --git a/manifest.uuid b/manifest.uuid index 948d08cb7b..512ae0f9fd 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a12bef4a0877fb1dca531509a1186e092727b6d8 \ No newline at end of file +3674b25edc37145b2b1275dd20580015ace66aa7 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index aed38e0aba..faa39705e8 100644 --- a/src/btree.c +++ b/src/btree.c @@ -9,7 +9,7 @@ ** May you share freely, never taking more than you give. ** ************************************************************************* -** $Id: btree.c,v 1.162 2004/06/09 17:37:23 drh Exp $ +** $Id: btree.c,v 1.163 2004/06/09 20:03:09 drh Exp $ ** ** This file implements a external (disk-based) database using BTrees. ** For a detailed discussion of BTrees, refer to @@ -1250,7 +1250,7 @@ int sqlite3BtreeBeginTrans(Btree *pBt, int wrflag, int nMaster){ } if( rc==SQLITE_OK && wrflag ){ - rc = sqlite3pager_begin(pBt->pPage1->aData, 0); + rc = sqlite3pager_begin(pBt->pPage1->aData, nMaster); if( rc==SQLITE_OK ){ rc = newDatabase(pBt); } diff --git a/src/main.c b/src/main.c index 8768bf661c..53b5c4472a 100644 --- a/src/main.c +++ b/src/main.c @@ -14,7 +14,7 @@ ** other files are for internal use by SQLite and should not be ** accessed by users of the library. ** -** $Id: main.c,v 1.209 2004/06/09 12:30:06 danielk1977 Exp $ +** $Id: main.c,v 1.210 2004/06/09 20:03:09 drh Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -1033,6 +1033,9 @@ static int openDatabase( /* Open the backend database driver */ if( zFilename[0]==':' && strcmp(zFilename,":memory:")==0 ){ db->temp_store = 2; + db->nMaster = 0; /* Disable atomic multi-file commit for :memory: */ + }else{ + db->nMaster = -1; /* Size of master journal filename initially unknown */ } rc = sqlite3BtreeFactory(db, zFilename, 0, MAX_PAGES, &db->aDb[0].pBt); if( rc!=SQLITE_OK ){ @@ -1161,4 +1164,3 @@ int sqlite3_create_collation16( sqliteFree(zName8); return rc; } - diff --git a/src/pager.c b/src/pager.c index 50eedd80ae..814d7d6f16 100644 --- a/src/pager.c +++ b/src/pager.c @@ -18,7 +18,7 @@ ** file simultaneously, or one process from reading the database while ** another is writing. ** -** @(#) $Id: pager.c,v 1.116 2004/06/09 19:03:55 drh Exp $ +** @(#) $Id: pager.c,v 1.117 2004/06/09 20:03:09 drh Exp $ */ #include "os.h" /* Must be first to enable large file support */ #include "sqliteInt.h" @@ -1934,7 +1934,8 @@ static int pager_open_journal(Pager *pPager){ rc = write32bits(&pPager->jfd, pPager->nMaster); } if( rc==SQLITE_OK ){ - rc = sqlite3OsSeek(&pPager->jfd, 24 + pPager->nMaster); + sqlite3OsSeek(&pPager->jfd, 24 + pPager->nMaster - 1); + rc = sqlite3OsWrite(&pPager->jfd, "\000", 1); } if( pPager->stmtAutoopen && rc==SQLITE_OK ){ rc = sqlite3pager_stmt_begin(pPager); diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 64cf766660..61998e9e3d 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -11,7 +11,7 @@ ************************************************************************* ** Internal interface definitions for SQLite. ** -** @(#) $Id: sqliteInt.h,v 1.275 2004/06/09 14:01:51 drh Exp $ +** @(#) $Id: sqliteInt.h,v 1.276 2004/06/09 20:03:09 drh Exp $ */ #include "config.h" #include "sqlite3.h" @@ -422,6 +422,7 @@ struct sqlite { void *zErrMsg16; /* Most recent error message (UTF-16 encoded) */ u8 enc; /* Text encoding for this database. */ u8 autoCommit; /* The auto-commit flag. */ + int nMaster; /* Length of master journal name. -1=unknown */ }; /* diff --git a/src/vdbe.c b/src/vdbe.c index 1390e6d306..c1707f3371 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -43,7 +43,7 @@ ** in this file for details. If in doubt, do not deviate from existing ** commenting and indentation practices when changing or adding code. ** -** $Id: vdbe.c,v 1.361 2004/06/09 09:55:19 danielk1977 Exp $ +** $Id: vdbe.c,v 1.362 2004/06/09 20:03:10 drh Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -2319,8 +2319,10 @@ case OP_Transaction: { pBt = db->aDb[i].pBt; if( pBt ){ - int nMaster = strlen(sqlite3BtreeGetFilename(db->aDb[0].pBt))+11; - rc = sqlite3BtreeBeginTrans(pBt, pOp->p2, nMaster); + if( db->nMaster<0 ){ + db->nMaster = strlen(sqlite3BtreeGetFilename(db->aDb[0].pBt))+20; + } + rc = sqlite3BtreeBeginTrans(pBt, pOp->p2, db->nMaster); if( rc==SQLITE_BUSY ){ if( db->busyHandler.xFunc==0 ){ p->pc = pc; diff --git a/src/vdbeaux.c b/src/vdbeaux.c index e97f99c69d..0486aca9c9 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -933,8 +933,12 @@ static int vdbeCommit(sqlite *db){ /* The simple case - no more than one database file (not counting the TEMP ** database) has a transaction active. There is no need for the ** master-journal. + ** + ** if db->nMaster==0, it means the main database is :memory:. In that case + ** we do not support atomic multi-file commits, so use the simple case then + ** too. */ - if( nTrans<=100 ){ /**** FIX ME ****/ + if( db->nMaster<=0 || nTrans<=1 ){ for(i=0; rc==SQLITE_OK && inDb; i++){ Btree *pBt = db->aDb[i].pBt; if( pBt ){ @@ -974,6 +978,7 @@ static int vdbeCommit(sqlite *db){ }while( sqlite3OsFileExists(zMaster) ); /* Open the master journal. */ + assert( strlen(zMaster)nMaster ); rc = sqlite3OsOpenExclusive(zMaster, &master, 0); if( rc!=SQLITE_OK ){ sqliteFree(zMaster); @@ -988,16 +993,11 @@ static int vdbeCommit(sqlite *db){ */ for(i=0; inDb; i++){ Btree *pBt = db->aDb[i].pBt; + if( i==1 ) continue; /* Ignore the TEMP database */ if( pBt && sqlite3BtreeIsInTrans(pBt) ){ char const *zFile = sqlite3BtreeGetFilename(pBt); - rc = sqlite3OsWrite(&master, zFile, strlen(zFile)); - if( rc!=SQLITE_OK ){ - sqlite3OsClose(&master); - sqlite3OsDelete(zMaster); - sqliteFree(zMaster); - return rc; - } - rc = sqlite3OsWrite(&master, "\0", 1); + if( zFile[0]==0 ) continue; /* Ignore :memory: databases */ + rc = sqlite3OsWrite(&master, zFile, strlen(zFile)+1); if( rc!=SQLITE_OK ){ sqlite3OsClose(&master); sqlite3OsDelete(zMaster); @@ -1011,6 +1011,9 @@ static int vdbeCommit(sqlite *db){ rc = sqlite3OsSync(&master); sqlite3OsClose(&master); + /* FIXME: Sync the directory that contains the master journal to + ** make sure the i-node is up to date. */ + /* Sync all the db files involved in the transaction. The same call ** sets the master journal pointer in each individual journal. If ** an error occurs here, do not delete the master journal file. diff --git a/test/pager2.test b/test/pager2.test index 201631c6b2..cc38d2b477 100644 --- a/test/pager2.test +++ b/test/pager2.test @@ -11,7 +11,7 @@ # This file implements regression tests for SQLite library. The # focus of this script is page cache subsystem. # -# $Id: pager2.test,v 1.1 2004/05/12 13:30:09 drh Exp $ +# $Id: pager2.test,v 1.2 2004/06/09 20:03:10 drh Exp $ set testdir [file dirname $argv0] @@ -122,7 +122,7 @@ do_test pager2-2.14 { } {0 {}} do_test pager2-2.15 { pager_stats $::p1 -} {ref 1 page 1 max 10 size 1 state 2 err 0 hit 1 miss 1 ovfl 0} +} {ref 1 page 1 max 10 size 1 state 3 err 0 hit 1 miss 1 ovfl 0} do_test pager2-2.16 { page_read $::g1 } {Page-One} @@ -295,7 +295,7 @@ for {set i 1} {$i<20} {incr i} { do_test pager2-4.5.$i.1 { page_write $g1 "Page-1 v$i" lrange [pager_stats $p1] 8 9 - } {state 2} + } {state 3} do_test pager2-4.5.$i.2 { for {set j 2} {$j<=20} {incr j} { set gx [page_get $p1 $j] @@ -336,7 +336,7 @@ for {set i 1} {$i<20} {incr i} { do_test pager2-4.5.$i.5 { page_write $g1 "Page-1 v$i" lrange [pager_stats $p1] 8 9 - } {state 2} + } {state 3} do_test pager2-4.5.$i.6 { for {set j 2} {$j<=20} {incr j} { set gx [page_get $p1 $j]