From: drh Date: Mon, 10 May 2010 11:20:05 +0000 (+0000) Subject: Enhance the OP_JournalMode opcode with an ignore-errors option and use that X-Git-Tag: version-3.7.2~394 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ab9b74443c31f3271f39c04f9569d4418cf0049f;p=thirdparty%2Fsqlite.git Enhance the OP_JournalMode opcode with an ignore-errors option and use that option the ATTACH command. FossilOrigin-Name: 0bdea4cfbd7832f2a00c01b93c92ba13d20139ef --- diff --git a/manifest b/manifest index 81acdf4335..a91bfec1ac 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C When\srunning\sa\scheckpoint\swhile\sin\slocking_mode=EXCLUSIVE,\sbe\ssure\sto\smove\nthe\swal-index\slock\sto\sUNLOCK\sfrom\sREAD\sprior\sto\spromoting\sto\sCHECKPOINT. -D 2010-05-07T20:34:17 +C Enhance\sthe\sOP_JournalMode\sopcode\swith\san\signore-errors\soption\sand\suse\sthat\noption\sthe\sATTACH\scommand. +D 2010-05-10T11:20:06 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in a5cad1f8f3e021356bfcc6c77dc16f6f1952bbc3 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -109,7 +109,7 @@ F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc F sqlite3.pc.in ae6f59a76e862f5c561eb32a380228a02afc3cad F src/alter.c a9ff6f14b3935502537e90194b66c7bc79bed317 F src/analyze.c 8dfd781ac326496746ecdfc3e099250ed5d79be5 -F src/attach.c 0d7c4c820d193161238bce8900b4bc4bed7577b6 +F src/attach.c 7f1f760bacd9c5b6cbf6fbc3ceb159ed19ee910a F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c de9809091b3b99f69e37261c133f7f8b19f6eca6 F src/bitvec.c 06ad2c36a9c3819c0b9cbffec7b15f58d5d834e0 @@ -218,7 +218,7 @@ F src/update.c c0dc6b75ad28b76b619042d934f337b02acee208 F src/utf.c 1baeeac91707a4df97ccc6141ec0f808278af685 F src/util.c 32aebf04c10e51ad3977a928b7416bed671b620b F src/vacuum.c 90a32e098cf06c5524c76b21027ee7520a821065 -F src/vdbe.c 267e0431ccd1a7536c1c8160288ad44c6efeb27d +F src/vdbe.c 066dab3af747cb56a8277b26695f88b17b189b3d F src/vdbe.h 471f6a3dcec4817ca33596fe7f6654d56c0e75f3 F src/vdbeInt.h 19ebc8c2a2e938340051ee65af3f377fb99102d1 F src/vdbeapi.c dc3138f10afbc95ed3c21dd25abb154504b1db9d @@ -816,14 +816,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P a65c2939267ef6acec4e355a207f98f217e263d6 -R a46357f982ebdd4520842ec1c873b4c4 +P be114bdf9bb98c7287f8cb54340c630b0c412e9d +R 338d6602848868b4fdc5f43d8042cacf U drh -Z 46431e902a37a907f9e07e8180abbf8b +Z 84070859675575cea6f23c42561ae695 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFL5HlMoxKgR168RlERAnrAAKCMJ4zxVnnT86OHLDJpyko7/j+9/QCgjflR -YUDucsN2KcpF/NWFDOXGwZ8= -=xUef +iD8DBQFL5+vqoxKgR168RlERAhAYAJ9X+wZ4rOhzhAxjTWIMsJCrOuKhnQCeMjaZ +7HQKFwCzaUZuXQ/pI06hEvs= +=kH/t -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 92fe02cdb3..fd06dc3781 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -be114bdf9bb98c7287f8cb54340c630b0c412e9d \ No newline at end of file +0bdea4cfbd7832f2a00c01b93c92ba13d20139ef \ No newline at end of file diff --git a/src/attach.c b/src/attach.c index 2b57793f94..0299cbfb37 100644 --- a/src/attach.c +++ b/src/attach.c @@ -348,6 +348,7 @@ static void codeAttach( */ sqlite3VdbeAddOp3(v, OP_JournalMode, db->nDb, regArgs+3, db->dfltJournalMode); + sqlite3VdbeChangeP5(v, 1); } /* Code an OP_Expire. For an ATTACH statement, set P1 to true (expire this diff --git a/src/vdbe.c b/src/vdbe.c index 4e7cedb960..001044bc5c 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -5198,7 +5198,7 @@ case OP_Checkpoint: { }; #endif -/* Opcode: JournalMode P1 P2 P3 * * +/* Opcode: JournalMode P1 P2 P3 * P5 ** ** Change the journal mode of database P1 to P3. P3 must be one of the ** PAGER_JOURNALMODE_XXX values. If changing between the various rollback @@ -5208,6 +5208,11 @@ case OP_Checkpoint: { ** If changing into or out of WAL mode the procedure is more complicated. ** ** Write a string containing the final journal-mode to register P2. +** +** If an attempt to change in to or out of WAL mode fails because another +** connection also has the same database open, then an SQLITE_BUSY error +** is raised if P5==0, or of P5!=0 the journal mode changed is skipped +** without signaling the error. */ case OP_JournalMode: { /* out2-prerelease */ Btree *pBt; /* Btree to change journal mode of */ @@ -5285,18 +5290,27 @@ case OP_JournalMode: { /* out2-prerelease */ ** after a successful return. */ rc = sqlite3PagerCloseWal(pPager); - if( rc!=SQLITE_OK ) goto abort_due_to_error; - sqlite3PagerJournalMode(pPager, eNew); + if( rc==SQLITE_OK ){ + sqlite3PagerJournalMode(pPager, eNew); + }else if( rc==SQLITE_BUSY && pOp->p5==0 ){ + goto abort_due_to_error; + } }else{ sqlite3PagerJournalMode(pPager, PAGER_JOURNALMODE_DELETE); + rc = SQLITE_OK; } /* Open a transaction on the database file. Regardless of the journal ** mode, this transaction always uses a rollback journal. */ assert( sqlite3BtreeIsInTrans(pBt)==0 ); - rc = sqlite3BtreeSetVersion(pBt, (eNew==PAGER_JOURNALMODE_WAL ? 2 : 1)); - if( rc!=SQLITE_OK ) goto abort_due_to_error; + if( rc==SQLITE_OK ){ + rc = sqlite3BtreeSetVersion(pBt, + (eNew==PAGER_JOURNALMODE_WAL ? 2 : 1)); + if( rc==SQLITE_BUSY && pOp->p5==0 ) goto abort_due_to_error; + }else if( rc==SQLITE_BUSY ){ + rc = SQLITE_OK; + } } } }