Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch apple-osx-exp Excluding Merge-Ins
This is equivalent to a diff from fd4d38fa66 to 756589ad6e
2010-11-19
| ||
23:50 | Merge all the latest changes from the trunk into the apple-osx branch. (check-in: c8bc057c7d user: drh tags: apple-osx) | |
2010-11-09
| ||
20:08 | Add "PRAGMA checkpoint_fullfsync". Similar to "PRAGMA fullfsync", but enables full fsyncs only during checkpoint operations. Update: This change was added to the trunk by check-in [a069867301de3ca2e17] (Closed-Leaf check-in: 756589ad6e user: dan tags: apple-osx-exp) | |
01:53 | Back out the prior attempt to enable full-fsync for WAL and attempt the same thing using a completely different approach. (check-in: f59949fac1 user: drh tags: apple-osx-exp) | |
00:47 | Experimental changes to test defaulting to fullfsync for WAL mode (check-in: 77b343cfc3 user: adam tags: apple-osx-exp) | |
00:43 | Integrated proxy locking file support for WAL journal mode and double free fix (check-in: fd4d38fa66 user: adam tags: apple-osx) | |
2010-09-10
| ||
23:16 | fixed memory leak in proxy lock file error handling (check-in: e01c5f3eda user: adam tags: apple-osx) | |
Changes to src/pager.c.
615 615 u8 noReadlock; /* Do not bother to obtain readlocks */ 616 616 u8 noSync; /* Do not sync the journal if true */ 617 617 u8 fullSync; /* Do extra syncs of the journal for robustness */ 618 618 u8 sync_flags; /* One of SYNC_NORMAL or SYNC_FULL */ 619 619 u8 tempFile; /* zFilename is a temporary file */ 620 620 u8 readOnly; /* True for a read-only database */ 621 621 u8 memDb; /* True to inhibit all file I/O */ 622 + u8 ckptFullSync; /* True to pass SYNC_FULL to WalCheckpoint() */ 622 623 623 624 /************************************************************************** 624 625 ** The following block contains those class members that change during 625 626 ** routine opertion. Class members not in this block are either fixed 626 627 ** when the pager is first created or else only change when there is a 627 628 ** significant mode change (such as changing the page_size, locking_mode, 628 629 ** or the journal_mode). From another view, these class members describe ................................................................................ 3078 3079 }else if( pPager->journalMode==PAGER_JOURNALMODE_WAL ){ 3079 3080 pPager->journalMode = PAGER_JOURNALMODE_DELETE; 3080 3081 } 3081 3082 } 3082 3083 } 3083 3084 return rc; 3084 3085 } 3086 + 3087 +/* 3088 +** Return the value of the flags parameter that should be passed to 3089 +** sqlite3OsSync() when checkpointing a WAL file. 3090 +*/ 3091 +static int walCkptSyncFlags(Pager *pPager){ 3092 + int flags = 0; 3093 + if( pPager->noSync==0 ){ 3094 + flags = pPager->sync_flags | (pPager->ckptFullSync?SQLITE_SYNC_FULL:0); 3095 + } 3096 + return flags; 3097 +} 3098 + 3085 3099 #endif 3086 3100 3087 3101 /* 3088 3102 ** Playback savepoint pSavepoint. Or, if pSavepoint==NULL, then playback 3089 3103 ** the entire master journal file. The case pSavepoint==NULL occurs when 3090 3104 ** a ROLLBACK TO command is invoked on a SAVEPOINT that is a transaction 3091 3105 ** savepoint. ................................................................................ 3258 3272 ** assurance that the journal will not be corrupted to the 3259 3273 ** point of causing damage to the database during rollback. 3260 3274 ** 3261 3275 ** Numeric values associated with these states are OFF==1, NORMAL=2, 3262 3276 ** and FULL=3. 3263 3277 */ 3264 3278 #ifndef SQLITE_OMIT_PAGER_PRAGMAS 3265 -void sqlite3PagerSetSafetyLevel(Pager *pPager, int level, int bFullFsync){ 3279 +void sqlite3PagerSetSafetyLevel(Pager *pPager, int level, int fullFsync){ 3280 + assert( 0==(fullFsync & ~(SQLITE_FullFSync|SQLITE_CkptFullFSync)) ); 3266 3281 pPager->noSync = (level==1 || pPager->tempFile) ?1:0; 3267 3282 pPager->fullSync = (level==3 && !pPager->tempFile) ?1:0; 3268 - pPager->sync_flags = (bFullFsync?SQLITE_SYNC_FULL:SQLITE_SYNC_NORMAL); 3283 + if( fullFsync & SQLITE_FullFSync ){ 3284 + pPager->sync_flags = SQLITE_SYNC_FULL; 3285 + }else{ 3286 + pPager->sync_flags = SQLITE_SYNC_NORMAL; 3287 + } 3288 + pPager->ckptFullSync = (fullFsync & SQLITE_CkptFullFSync)!=0; 3269 3289 } 3270 3290 #endif 3271 3291 3272 3292 /* 3273 3293 ** The following global variable is incremented whenever the library 3274 3294 ** attempts to open a temporary file. This information is used for 3275 3295 ** testing and analysis only. ................................................................................ 3647 3667 u8 *pTmp = (u8 *)pPager->pTmpSpace; 3648 3668 3649 3669 disable_simulated_io_errors(); 3650 3670 sqlite3BeginBenignMalloc(); 3651 3671 /* pPager->errCode = 0; */ 3652 3672 pPager->exclusiveMode = 0; 3653 3673 #ifndef SQLITE_OMIT_WAL 3654 - sqlite3WalClose(pPager->pWal, 3655 - (pPager->noSync ? 0 : pPager->sync_flags), 3674 + sqlite3WalClose(pPager->pWal, walCkptSyncFlags(pPager), 3656 3675 pPager->pageSize, pTmp 3657 3676 ); 3658 3677 pPager->pWal = 0; 3659 3678 #endif 3660 3679 pager_reset(pPager); 3661 3680 if( MEMDB ){ 3662 3681 pager_unlock(pPager); ................................................................................ 6517 6536 /* 6518 6537 ** This function is called when the user invokes "PRAGMA checkpoint". 6519 6538 */ 6520 6539 int sqlite3PagerCheckpoint(Pager *pPager){ 6521 6540 int rc = SQLITE_OK; 6522 6541 if( pPager->pWal ){ 6523 6542 u8 *zBuf = (u8 *)pPager->pTmpSpace; 6524 - rc = sqlite3WalCheckpoint(pPager->pWal, 6525 - (pPager->noSync ? 0 : pPager->sync_flags), 6526 - pPager->pageSize, zBuf 6527 - ); 6543 + int flags = walCkptSyncFlags(pPager); 6544 + rc = sqlite3WalCheckpoint(pPager->pWal, flags, pPager->pageSize, zBuf); 6528 6545 } 6529 6546 return rc; 6530 6547 } 6531 6548 6532 6549 int sqlite3PagerWalCallback(Pager *pPager){ 6533 6550 return sqlite3WalCallback(pPager->pWal); 6534 6551 } ................................................................................ 6625 6642 6626 6643 /* Checkpoint and close the log. Because an EXCLUSIVE lock is held on 6627 6644 ** the database file, the log and log-summary files will be deleted. 6628 6645 */ 6629 6646 if( rc==SQLITE_OK && pPager->pWal ){ 6630 6647 rc = pagerLockDb(pPager, EXCLUSIVE_LOCK); 6631 6648 if( rc==SQLITE_OK ){ 6632 - rc = sqlite3WalClose(pPager->pWal, 6633 - (pPager->noSync ? 0 : pPager->sync_flags), 6634 - pPager->pageSize, (u8*)pPager->pTmpSpace 6649 + rc = sqlite3WalClose(pPager->pWal, walCkptSyncFlags(pPager), 6650 + pPager->pageSize, (u8*)pPager->pTmpSpace 6635 6651 ); 6636 6652 pPager->pWal = 0; 6637 6653 }else{ 6638 6654 /* If we cannot get an EXCLUSIVE lock, downgrade the PENDING lock 6639 6655 ** that we did get back to SHARED. */ 6640 6656 pagerUnlockDb(pPager, SQLITE_LOCK_SHARED); 6641 6657 }
Changes to src/pragma.c.
168 168 } aPragma[] = { 169 169 { "full_column_names", SQLITE_FullColNames }, 170 170 { "short_column_names", SQLITE_ShortColNames }, 171 171 { "count_changes", SQLITE_CountRows }, 172 172 { "empty_result_callbacks", SQLITE_NullCallback }, 173 173 { "legacy_file_format", SQLITE_LegacyFileFmt }, 174 174 { "fullfsync", SQLITE_FullFSync }, 175 + { "checkpoint_fullfsync", SQLITE_CkptFullFSync }, 175 176 { "reverse_unordered_selects", SQLITE_ReverseOrder }, 176 177 #ifndef SQLITE_OMIT_AUTOMATIC_INDEX 177 178 { "automatic_index", SQLITE_AutoIndex }, 178 179 #endif 179 180 #ifdef SQLITE_DEBUG 180 181 { "sql_trace", SQLITE_SqlTrace }, 181 182 { "vdbe_listing", SQLITE_VdbeListing }, ................................................................................ 1505 1506 /* 1506 1507 ** Reset the safety level, in case the fullfsync flag or synchronous 1507 1508 ** setting changed. 1508 1509 */ 1509 1510 #ifndef SQLITE_OMIT_PAGER_PRAGMAS 1510 1511 if( db->autoCommit ){ 1511 1512 sqlite3BtreeSetSafetyLevel(pDb->pBt, pDb->safety_level, 1512 - (db->flags&SQLITE_FullFSync)!=0); 1513 + db->flags&(SQLITE_FullFSync|SQLITE_CkptFullFSync)); 1513 1514 } 1514 1515 #endif 1515 1516 pragma_out: 1516 1517 sqlite3DbFree(db, zLeft); 1517 1518 sqlite3DbFree(db, zRight); 1518 1519 } 1519 1520 1520 1521 #endif /* SQLITE_OMIT_PRAGMA */
Changes to src/sqliteInt.h.
910 910 #define SQLITE_LoadExtension 0x00400000 /* Enable load_extension */ 911 911 #define SQLITE_RecoveryMode 0x00800000 /* Ignore schema errors */ 912 912 #define SQLITE_ReverseOrder 0x01000000 /* Reverse unordered SELECTs */ 913 913 #define SQLITE_RecTriggers 0x02000000 /* Enable recursive triggers */ 914 914 #define SQLITE_ForeignKeys 0x04000000 /* Enforce foreign key constraints */ 915 915 #define SQLITE_AutoIndex 0x08000000 /* Enable automatic indexes */ 916 916 #define SQLITE_PreferBuiltin 0x10000000 /* Preference to built-in funcs */ 917 +#define SQLITE_CkptFullFSync 0x20000000 /* Use full fsync on checkpoint */ 917 918 918 919 /* 919 920 ** Bits of the sqlite3.flags field that are used by the 920 921 ** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface. 921 922 ** These must be the low-order bits of the flags field. 922 923 */ 923 924 #define SQLITE_QueryFlattener 0x01 /* Disable query flattening */
Changes to test/pragma.test.
1289 1289 1290 1290 # Reset the sqlite3_temp_directory variable for the next run of tests: 1291 1291 sqlite3 dbX :memory: 1292 1292 dbX eval {PRAGMA temp_store_directory = ""} 1293 1293 dbX close 1294 1294 1295 1295 set skip_lock_proxy_tests [path_is_dos "."] 1296 -ifcapable !lock_proxy_pragmas&&prefer_proxy_locking { 1296 +ifcapable !lock_proxy_pragmas||prefer_proxy_locking { 1297 1297 set skip_lock_proxy_tests 1 1298 1298 } 1299 1299 1300 1300 if !$skip_lock_proxy_tests { 1301 1301 set sqlite_hostid_num 1 1302 1302 1303 1303 set using_proxy 0
Changes to test/wal2.test.
1148 1148 do_test wal2-13.$tn.4 { 1149 1149 catchsql { INSERT INTO t1 DEFAULT VALUES } 1150 1150 } $b($can_read,$can_write) 1151 1151 } 1152 1152 catch { db close } 1153 1153 } 1154 1154 } 1155 + 1156 +#------------------------------------------------------------------------- 1157 +# Test that "PRAGMA checkpoint_fullsync" appears to be working. 1158 +# 1159 +foreach {tn sql reslist} { 1160 + 1 { } {8 0 3 0 5 0} 1161 + 2 { PRAGMA checkpoint_fullfsync = 1 } {8 4 3 2 5 2} 1162 + 3 { PRAGMA checkpoint_fullfsync = 0 } {8 0 3 0 5 0} 1163 +} { 1164 + faultsim_delete_and_reopen 1165 + 1166 + execsql $sql 1167 + do_execsql_test wal2-14.$tn.1 { PRAGMA journal_mode = WAL } {wal} 1168 + 1169 + set sqlite_sync_count 0 1170 + set sqlite_fullsync_count 0 1171 + 1172 + do_execsql_test wal2-14.$tn.2 { 1173 + PRAGMA wal_autocheckpoint = 10; 1174 + CREATE TABLE t1(a, b); -- 2 wal syncs 1175 + INSERT INTO t1 VALUES(1, 2); -- 1 wal sync 1176 + PRAGMA wal_checkpoint; -- 1 wal sync, 1 db sync 1177 + BEGIN; 1178 + INSERT INTO t1 VALUES(3, 4); 1179 + INSERT INTO t1 VALUES(5, 6); 1180 + COMMIT; -- 1 wal sync 1181 + PRAGMA wal_checkpoint; -- 1 wal sync, 1 db sync 1182 + } {10} 1183 + 1184 + do_test wal2-14.$tn.3 { 1185 + list $sqlite_sync_count $sqlite_fullsync_count 1186 + } [lrange $reslist 0 1] 1187 + 1188 + set sqlite_sync_count 0 1189 + set sqlite_fullsync_count 0 1190 + 1191 + do_test wal2-14.$tn.4 { 1192 + execsql { INSERT INTO t1 VALUES(7, zeroblob(12*4096)) } 1193 + list $sqlite_sync_count $sqlite_fullsync_count 1194 + } [lrange $reslist 2 3] 1195 + 1196 + set sqlite_sync_count 0 1197 + set sqlite_fullsync_count 0 1198 + 1199 + do_test wal2-14.$tn.5 { 1200 + execsql { PRAGMA wal_autocheckpoint = 1000 } 1201 + execsql { INSERT INTO t1 VALUES(9, 10) } 1202 + execsql { INSERT INTO t1 VALUES(11, 12) } 1203 + execsql { INSERT INTO t1 VALUES(13, 14) } 1204 + db close 1205 + list $sqlite_sync_count $sqlite_fullsync_count 1206 + } [lrange $reslist 4 5] 1207 +} 1208 + 1209 + 1155 1210 1156 1211 finish_test