1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-11 01:42:22 +03:00

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
This commit is contained in:
dan
2010-02-18 08:19:19 +00:00
parent ad9f9f6693
commit da730f6eb4
5 changed files with 110 additions and 15 deletions

View File

@@ -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;