mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-05 15:55:57 +03:00
Disable the PagerDontWrite() optimization for temp tables. It can cause database corruption if a page passed to PagerDontWrite() is dirty at the start of a transaction that is subsequently rolled back.
FossilOrigin-Name: 6341ab2ffef298ca16b323358afbea4a4c1fb0e1
This commit is contained in:
@@ -6008,10 +6008,16 @@ int sqlite3PagerIswriteable(DbPage *pPg){
|
||||
**
|
||||
** Tests show that this optimization can quadruple the speed of large
|
||||
** DELETE operations.
|
||||
**
|
||||
** This optimization cannot be used with a temp-file, as the page may
|
||||
** have been dirty at the start of the transaction. In that case, if
|
||||
** memory pressure forces page pPg out of the cache, the data does need
|
||||
** to be written out to disk so that it may be read back in if the
|
||||
** current transaction is rolled back.
|
||||
*/
|
||||
void sqlite3PagerDontWrite(PgHdr *pPg){
|
||||
Pager *pPager = pPg->pPager;
|
||||
if( (pPg->flags&PGHDR_DIRTY) && pPager->nSavepoint==0 ){
|
||||
if( !pPager->tempFile && (pPg->flags&PGHDR_DIRTY) && pPager->nSavepoint==0 ){
|
||||
PAGERTRACE(("DONT_WRITE page %d of %d\n", pPg->pgno, PAGERID(pPager)));
|
||||
IOTRACE(("CLEAN %p %d\n", pPager, pPg->pgno))
|
||||
pPg->flags |= PGHDR_DONT_WRITE;
|
||||
|
Reference in New Issue
Block a user