From: drh Date: Fri, 20 Apr 2018 19:32:35 +0000 (+0000) Subject: Avoid opening a statement journal on single-row UPDATEs without triggers or X-Git-Tag: version-3.24.0~126 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ac9151d8489160078d1ff9bb954367c62b8eed9d;p=thirdparty%2Fsqlite.git Avoid opening a statement journal on single-row UPDATEs without triggers or FK constraints. FossilOrigin-Name: 2772404b8c570caf3c31d2b0530cf347a24f6f60e220e726c086537b38ebfa85 --- diff --git a/manifest b/manifest index 76bebb5a69..c125bf160c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sVDBE\scomment\son\supsert.\s\sProvide\san\serror\smessage\swhen\supsert\sdetects\nindex\scorruption. -D 2018-04-20T18:01:31.106 +C Avoid\sopening\sa\sstatement\sjournal\son\ssingle-row\sUPDATEs\swithout\striggers\sor\nFK\sconstraints. +D 2018-04-20T19:32:35.766 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 5ce9343cba9c189046f1afe6d2bcc1f68079439febc05267b98aec6ecc752439 @@ -557,7 +557,7 @@ F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c F src/tokenize.c 5b0c661a85f783d35b9883830736eeb63be4aefc4f6b7d9cd081d48782c041e2 F src/treeview.c 14d5d1254702ec96876aa52642cb31548612384134970409fae333b25b39d6bb F src/trigger.c 4ace6d1d5ba9a89822deb287317f33c810440526eafe185c2d8a48c31df1e995 -F src/update.c ae56e307cf9009290845b79a5f930b7c71613dc9d3ff1d290cdc91c4bd0487d9 +F src/update.c 9db686e67ba51bb44f268620943a9c4bb43c3e6f44a97b80dc29005382a9e2da F src/upsert.c ae4a4823b45c4daf87e8aea8c0f582a8844763271f5ed54ee5956c4c612734f4 F src/utf.c 810fbfebe12359f10bc2a011520a6e10879ab2a163bcb26c74768eab82ea62a5 F src/util.c d9eb0a6c4aae1b00a7369eadd7ca0bbe946cb4c953b6751aa20d357c2f482157 @@ -1724,7 +1724,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P cf253584ecf7aed04406b4bae78b536818fadfb3fb96c05f2c99954b841db85f -R f900a0112e9d240a88403e46a25d1dbd +P 279c48f6061f766f5437edd6964c0dd1e10399314eb17b6e5ee34df925a776ed +R f59d9c8d7506cfee5d11867351ba9adc U drh -Z 9ce8371b47cee8e5430793df80417131 +Z f6c31c0d19eadcc475691d30218d7dbb diff --git a/manifest.uuid b/manifest.uuid index 57ff6bcfae..7d201a2559 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -279c48f6061f766f5437edd6964c0dd1e10399314eb17b6e5ee34df925a776ed \ No newline at end of file +2772404b8c570caf3c31d2b0530cf347a24f6f60e220e726c086537b38ebfa85 \ No newline at end of file diff --git a/src/update.c b/src/update.c index 30d8a1ec63..a98bfa7d49 100644 --- a/src/update.c +++ b/src/update.c @@ -339,7 +339,7 @@ void sqlite3Update( v = sqlite3GetVdbe(pParse); if( v==0 ) goto update_cleanup; if( pParse->nested==0 ) sqlite3VdbeCountChanges(v); - sqlite3BeginWriteOperation(pParse, 1, iDb); + sqlite3BeginWriteOperation(pParse, pTrigger || hasFK, iDb); /* Allocate required registers. */ if( !IsVirtual(pTab) ){ @@ -456,12 +456,15 @@ void sqlite3Update( ** strategy that uses an index for which one or more columns are being ** updated. */ eOnePass = sqlite3WhereOkOnePass(pWInfo, aiCurOnePass); - if( eOnePass==ONEPASS_MULTI ){ - int iCur = aiCurOnePass[1]; - if( iCur>=0 && iCur!=iDataCur && aToOpen[iCur-iBaseCur] ){ - eOnePass = ONEPASS_OFF; + if( eOnePass!=ONEPASS_SINGLE ){ + sqlite3MultiWrite(pParse); + if( eOnePass==ONEPASS_MULTI ){ + int iCur = aiCurOnePass[1]; + if( iCur>=0 && iCur!=iDataCur && aToOpen[iCur-iBaseCur] ){ + eOnePass = ONEPASS_OFF; + } + assert( iCur!=iDataCur || !HasRowid(pTab) ); } - assert( iCur!=iDataCur || !HasRowid(pTab) ); } } @@ -884,15 +887,12 @@ static void updateVirtualTable( if( bOnePass ){ /* If using the onepass strategy, no-op out the OP_OpenEphemeral coded - ** above. Also, if this is a top-level parse (not a trigger), clear the - ** multi-write flag so that the VM does not open a statement journal */ + ** above. */ sqlite3VdbeChangeToNoop(v, addr); - if( sqlite3IsToplevel(pParse) ){ - pParse->isMultiWrite = 0; - } }else{ /* Create a record from the argument register contents and insert it into ** the ephemeral table. */ + sqlite3MultiWrite(pParse); sqlite3VdbeAddOp3(v, OP_MakeRecord, regArg, nArg, regRec); #ifdef SQLITE_DEBUG /* Signal an assert() within OP_MakeRecord that it is allowed to