Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Avoid automatically rolling back the transaction if an SQLITE_IOERR or SQLITE_FULL error occurs within sqlite3_db_cacheflush(). |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | cacheflush |
Files: | files | file ages | folders |
SHA1: |
370b5d520c6523526988d0db5299f1bd |
User & Date: | dan 2015-10-29 18:16:40.382 |
Context
2015-10-29
| ||
20:57 | Add a test case that calls sqlite3_db_cacheflush() on an in-memory database. (check-in: f0cdfb547b user: dan tags: cacheflush) | |
18:16 | Avoid automatically rolling back the transaction if an SQLITE_IOERR or SQLITE_FULL error occurs within sqlite3_db_cacheflush(). (check-in: 370b5d520c user: dan tags: cacheflush) | |
2015-10-28
| ||
19:46 | Add experimental API sqlite3_db_cacheflush(). (check-in: 65b86dc1fa user: dan tags: cacheflush) | |
Changes
Changes to src/main.c.
︙ | ︙ | |||
761 762 763 764 765 766 767 | rc = sqlite3PagerFlush(pPager); if( rc==SQLITE_BUSY ){ bSeenBusy = 1; rc = SQLITE_OK; } } } | < < < | 761 762 763 764 765 766 767 768 769 770 771 772 773 774 | rc = sqlite3PagerFlush(pPager); if( rc==SQLITE_BUSY ){ bSeenBusy = 1; rc = SQLITE_OK; } } } sqlite3BtreeLeaveAll(db); sqlite3_mutex_leave(db->mutex); return ((rc==SQLITE_OK && bSeenBusy) ? SQLITE_BUSY : rc); } /* ** Configuration settings for an individual database connection |
︙ | ︙ |
Changes to src/pager.c.
︙ | ︙ | |||
4473 4474 4475 4476 4477 4478 4479 | return pager_error(pPager, rc); } /* ** Flush all unreferenced dirty pages to disk. */ int sqlite3PagerFlush(Pager *pPager){ | | > | 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 | return pager_error(pPager, rc); } /* ** Flush all unreferenced dirty pages to disk. */ int sqlite3PagerFlush(Pager *pPager){ int rc = pPager->errCode; PgHdr *pList = sqlite3PcacheDirtyList(pPager->pPCache); assert( assert_pager_state(pPager) ); while( rc==SQLITE_OK && pList ){ PgHdr *pNext = pList->pDirty; if( pList->nRef==0 ){ rc = pagerStress((void*)pPager, pList); } pList = pNext; } |
︙ | ︙ | |||
6089 6090 6091 6092 6093 6094 6095 | ** ** If the EXCLUSIVE lock is already held or the attempt to obtain it is ** successful, or the connection is in WAL mode, SQLITE_OK is returned. ** Otherwise, either SQLITE_BUSY or an SQLITE_IOERR_XXX error code is ** returned. */ int sqlite3PagerExclusiveLock(Pager *pPager){ | > > | | | | | | | | > | 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 | ** ** If the EXCLUSIVE lock is already held or the attempt to obtain it is ** successful, or the connection is in WAL mode, SQLITE_OK is returned. ** Otherwise, either SQLITE_BUSY or an SQLITE_IOERR_XXX error code is ** returned. */ int sqlite3PagerExclusiveLock(Pager *pPager){ int rc = pPager->errCode; assert( assert_pager_state(pPager) ); if( rc==SQLITE_OK ){ assert( pPager->eState==PAGER_WRITER_CACHEMOD || pPager->eState==PAGER_WRITER_DBMOD || pPager->eState==PAGER_WRITER_LOCKED ); assert( assert_pager_state(pPager) ); if( 0==pagerUseWal(pPager) ){ rc = pager_wait_on_lock(pPager, EXCLUSIVE_LOCK); } } return rc; } /* ** Sync the database file for the pager pPager. zMaster points to the name ** of a master journal file that should be written into the individual |
︙ | ︙ |
Changes to src/sqlite.h.in.
︙ | ︙ | |||
7810 7811 7812 7813 7814 7815 7816 | ** belonging to the next (if any) database. If any databases are skipped ** because locks cannot be obtained, but no other error occurs, this ** function returns SQLITE_BUSY. ** ** If any other error occurs while flushing dirty pages to disk (for ** example an IO error or out-of-memory condition), then processing is ** abandoned and an SQLite error code returned to the caller immediately. | < | 7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 | ** belonging to the next (if any) database. If any databases are skipped ** because locks cannot be obtained, but no other error occurs, this ** function returns SQLITE_BUSY. ** ** If any other error occurs while flushing dirty pages to disk (for ** example an IO error or out-of-memory condition), then processing is ** abandoned and an SQLite error code returned to the caller immediately. ** ** Otherwise, if no error occurs, SQLITE_OK is returned. ** ** This function does not set the database handle error code or message ** returned by the sqlite3_errcode() and sqlite3_errmsg() functions. */ int sqlite3_db_cacheflush(sqlite3*); |
︙ | ︙ |
Changes to test/cffault.test.
︙ | ︙ | |||
34 35 36 37 38 39 40 | INSERT INTO t1 VALUES(1, 2); INSERT INTO t1 VALUES(3, 4); INSERT INTO t1 VALUES(5, 6); INSERT INTO t1 VALUES(7, 8); } faultsim_save_and_close | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | INSERT INTO t1 VALUES(1, 2); INSERT INTO t1 VALUES(3, 4); INSERT INTO t1 VALUES(5, 6); INSERT INTO t1 VALUES(7, 8); } faultsim_save_and_close do_faultsim_test 1.1 -prep { faultsim_restore_and_reopen db eval { BEGIN; UPDATE t1 SET b=b+1; } } -body { sqlite3_db_cacheflush db } -test { if {[sqlite3_get_autocommit db]} { error "Transaction rolled back!" } faultsim_test_result {0 {}} {1 {disk I/O error}} catch { db eval COMMIT } faultsim_integrity_check } do_faultsim_test 1.2 -prep { faultsim_restore_and_reopen db eval { BEGIN; UPDATE t1 SET b=b+1; } } -body { set result [list] db eval { SELECT * FROM t1 } { if {$a==5} { catch { sqlite3_db_cacheflush db } } lappend result $a $b } set result } -test { faultsim_test_result {0 {1 3 3 5 5 7 7 9}} {1 {disk I/O error}} catch { db eval COMMIT } faultsim_integrity_check } #------------------------------------------------------------------------- reset_db do_execsql_test 2.0 { CREATE TABLE t1(a PRIMARY KEY, b, c); CREATE INDEX i1 ON t1(b); CREATE INDEX i2 ON t1(c, b); INSERT INTO t1 VALUES(1, 2, randomblob(600)); INSERT INTO t1 VALUES(3, 4, randomblob(600)); INSERT INTO t1 VALUES(5, 6, randomblob(600)); INSERT INTO t1 VALUES(7, 8, randomblob(600)); INSERT INTO t1 VALUES(9, 10, randomblob(600)); } faultsim_save_and_close do_faultsim_test 2.1 -prep { faultsim_restore_and_reopen db eval { BEGIN; UPDATE t1 SET b=b+1; } } -body { set result [list] db eval { SELECT * FROM t1 } { if {$a==5} { catch { sqlite3_db_cacheflush db } } lappend result $a $b } set result } -test { faultsim_test_result {0 {1 3 3 5 5 7 7 9 9 11}} {1 {disk I/O error}} catch { db eval { INSERT INTO t1 VALUES(11, 12, randomblob(600)) } } catch { db eval COMMIT } faultsim_integrity_check } do_faultsim_test 2.2 -prep { faultsim_restore_and_reopen db eval { BEGIN; UPDATE t1 SET b=b+1; } } -body { sqlite3_db_cacheflush db } -test { if {[sqlite3_get_autocommit db]} { error "Transaction rolled back!" } faultsim_test_result {0 {}} {1 {disk I/O error}} catch { db eval { SELECT * FROM t1 } } catch { db eval COMMIT } faultsim_integrity_check } do_faultsim_test 2.3 -prep { faultsim_restore_and_reopen db eval { BEGIN; UPDATE t1 SET b=b-1; } } -body { sqlite3_db_cacheflush db } -test { if {[sqlite3_get_autocommit db]} { error "Transaction rolled back!" } faultsim_test_result {0 {}} {1 {disk I/O error}} catch { db eval { INSERT INTO t1 VALUES(11, 12, randomblob(600)) } } catch { db eval COMMIT } faultsim_integrity_check } do_faultsim_test 2.4 -prep { faultsim_restore_and_reopen db eval { BEGIN; UPDATE t1 SET b=b-1; } } -body { catch { sqlite3_db_cacheflush db } catch { sqlite3_db_release_memory db } catch { sqlite3_db_cacheflush db } execsql { SELECT a, b FROM t1 } } -test { faultsim_test_result {0 {1 1 3 3 5 5 7 7 9 9}} {1 {disk I/O error}} catchsql ROLLBACK faultsim_integrity_check } finish_test |