aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2018-04-20 19:32:35 +0000
committerdrh <drh@noemail.net>2018-04-20 19:32:35 +0000
commitac9151d8489160078d1ff9bb954367c62b8eed9d (patch)
tree772ac7714886715b4723b52c82d90adc14116eb0 /src
parent9cadb2308bfd9f5965bdf09032ec4a650660363a (diff)
downloadsqlite-ac9151d8489160078d1ff9bb954367c62b8eed9d.tar.gz
sqlite-ac9151d8489160078d1ff9bb954367c62b8eed9d.zip
Avoid opening a statement journal on single-row UPDATEs without triggers or
FK constraints. FossilOrigin-Name: 2772404b8c570caf3c31d2b0530cf347a24f6f60e220e726c086537b38ebfa85
Diffstat (limited to 'src')
-rw-r--r--src/update.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/update.c b/src/update.c
index 30d8a1ec6..a98bfa7d4 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