diff options
author | dan <dan@noemail.net> | 2010-02-18 08:19:19 +0000 |
---|---|---|
committer | dan <dan@noemail.net> | 2010-02-18 08:19:19 +0000 |
commit | da730f6eb4e1df1b844b8c0cb0b68f3389a37960 (patch) | |
tree | c3020cd0f9a3b36d7e57af63005930693dce5982 /src/insert.c | |
parent | ad9f9f669329c3a89dd3a7b119abb9aee6e5d9b4 (diff) | |
download | sqlite-da730f6eb4e1df1b844b8c0cb0b68f3389a37960.tar.gz sqlite-da730f6eb4e1df1b844b8c0cb0b68f3389a37960.zip |
Allow statements like "REPLACE INTO tbl(rowid) VALUES(...)" to run without a statement journal as long as there are no triggers, foreign keys or indexes.
FossilOrigin-Name: 0e4225804010cb0e3f254e2dbffc4fe0e7d982ce
Diffstat (limited to 'src/insert.c')
-rw-r--r-- | src/insert.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/src/insert.c b/src/insert.c index 9bd908534..537976206 100644 --- a/src/insert.c +++ b/src/insert.c @@ -1261,19 +1261,33 @@ void sqlite3GenerateConstraintChecks( ** the triggers and remove both the table and index b-tree entries. ** ** Otherwise, if there are no triggers or the recursive-triggers - ** flag is not set, call GenerateRowIndexDelete(). This removes - ** the index b-tree entries only. The table b-tree entry will be - ** replaced by the new entry when it is inserted. */ + ** flag is not set, but the table has one or more indexes, call + ** GenerateRowIndexDelete(). This removes the index b-tree entries + ** only. The table b-tree entry will be replaced by the new entry + ** when it is inserted. + ** + ** If either GenerateRowDelete() or GenerateRowIndexDelete() is called, + ** also invoke MultiWrite() to indicate that this VDBE may require + ** statement rollback (if the statement is aborted after the delete + ** takes place). Earlier versions called sqlite3MultiWrite() regardless, + ** but being more selective here allows statements like: + ** + ** REPLACE INTO t(rowid) VALUES($newrowid) + ** + ** to run without a statement journal if there are no indexes on the + ** table. + */ Trigger *pTrigger = 0; if( pParse->db->flags&SQLITE_RecTriggers ){ pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0); } - sqlite3MultiWrite(pParse); if( pTrigger || sqlite3FkRequired(pParse, pTab, 0, 0) ){ + sqlite3MultiWrite(pParse); sqlite3GenerateRowDelete( pParse, pTab, baseCur, regRowid, 0, pTrigger, OE_Replace ); - }else{ + }else if( pTab->pIndex ){ + sqlite3MultiWrite(pParse); sqlite3GenerateRowIndexDelete(pParse, pTab, baseCur, 0); } seenReplace = 1; |