Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Changes to make pragma synchronous sticky when SQLITE_DEFAULT_WAL_SAFETYLEVEL is used |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | apple-osx |
Files: | files | file ages | folders |
SHA1: |
c6158b254fabd02a3d58b1a047a3c5fa |
User & Date: | adam 2011-06-25 21:43:15.946 |
Context
2011-10-10
| ||
18:59 | Cherrypick the sqlite_data_count() changes from [d4f95b3b6e] and [9913996e7b] into the apple-osx branch for version 3.7.7. (check-in: aef7945c42 user: drh tags: apple-osx-377) | |
2011-08-02
| ||
18:25 | Merge all the latest trunk changes into the apple-osx branch. (check-in: 77376b332b user: drh tags: apple-osx) | |
2011-06-25
| ||
21:43 | Changes to make pragma synchronous sticky when SQLITE_DEFAULT_WAL_SAFETYLEVEL is used (check-in: c6158b254f user: adam tags: apple-osx) | |
16:35 | Fix test cases so that they work with SQLITE_DEFAULT_WAL_SAFETYLEVEL defined. (check-in: 8f8b373eed user: dan tags: apple-osx) | |
Changes
Changes to src/btree.c.
︙ | ︙ | |||
2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 | }else if( isOpen==0 ){ #ifdef SQLITE_DEFAULT_WAL_SAFETYLEVEL /* Default to specified safety_level for WAL mode */ if( pBt->db!=0 && pBt->db->aDb!=0 ){ int iDb; sqlite3 *db = pBt->db; Db *aDb = db->aDb; for(iDb=0; iDb<db->nDb; iDb++){ if( aDb[iDb].pBt && aDb[iDb].pBt->pBt==pBt ) break; } assert( iDb<db->nDb ); | > > > | | 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 | }else if( isOpen==0 ){ #ifdef SQLITE_DEFAULT_WAL_SAFETYLEVEL /* Default to specified safety_level for WAL mode */ if( pBt->db!=0 && pBt->db->aDb!=0 ){ int iDb; sqlite3 *db = pBt->db; Db *aDb = db->aDb; u8 level = 0; for(iDb=0; iDb<db->nDb; iDb++){ if( aDb[iDb].pBt && aDb[iDb].pBt->pBt==pBt ) break; } assert( iDb<db->nDb ); level = db->aDb[iDb].safety_level; if( !SQLITE_DbSafetyLevelIsFixed(level) && (SQLITE_DbSafetyLevelValue(level) != SQLITE_DEFAULT_WAL_SAFETYLEVEL) ){ aDb[iDb].safety_level = SQLITE_DEFAULT_WAL_SAFETYLEVEL; sqlite3PagerSetSafetyLevel(pBt->pPager, SQLITE_DEFAULT_WAL_SAFETYLEVEL, (db->flags&SQLITE_FullFSync)!=0, (db->flags&SQLITE_CkptFullFSync)!=0); } } #endif |
︙ | ︙ |
Changes to src/pragma.c.
︙ | ︙ | |||
561 562 563 564 565 566 567 | } if( eMode==PAGER_JOURNALMODE_QUERY && pId2->n==0 ){ /* Convert "PRAGMA journal_mode" into "PRAGMA main.journal_mode" */ iDb = 0; pId2->n = 1; } #ifdef SQLITE_DEFAULT_WAL_SAFETYLEVEL | > | | | | | > > > > > | 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 | } if( eMode==PAGER_JOURNALMODE_QUERY && pId2->n==0 ){ /* Convert "PRAGMA journal_mode" into "PRAGMA main.journal_mode" */ iDb = 0; pId2->n = 1; } #ifdef SQLITE_DEFAULT_WAL_SAFETYLEVEL if( ! SQLITE_DbSafetyLevelIsFixed(pDb->safety_level) ){ if( eMode == PAGER_JOURNALMODE_WAL ){ /* when entering wal mode, immediately switch the safety_level ** so that a query to pragma synchronous returns the correct value */ pDb->safety_level = SQLITE_DEFAULT_WAL_SAFETYLEVEL; }else{ /* If the user hasn't overridden the synchronous setting, use the ** default for non-wal databases */ pDb->safety_level = 3; } } #endif /* SQLITE_DEFAULT_WAL_SAFETYLEVEL */ for(ii=db->nDb-1; ii>=0; ii--){ if( db->aDb[ii].pBt && (ii==iDb || pId2->n==0) ){ sqlite3VdbeUsesBtree(v, ii); sqlite3VdbeAddOp3(v, OP_JournalMode, ii, 1, eMode); } |
︙ | ︙ | |||
837 838 839 840 841 842 843 | ** the local value does not make changes to the disk file and the ** default value will be restored the next time the database is ** opened. */ if( sqlite3StrICmp(zLeft,"synchronous")==0 ){ if( sqlite3ReadSchema(pParse) ) goto pragma_out; if( !zRight ){ | | > | > | 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 | ** the local value does not make changes to the disk file and the ** default value will be restored the next time the database is ** opened. */ if( sqlite3StrICmp(zLeft,"synchronous")==0 ){ if( sqlite3ReadSchema(pParse) ) goto pragma_out; if( !zRight ){ u8 level = pDb->safety_level; i64 safetyLevel = (i64)(SQLITE_DbSafetyLevelValue(level)-1); returnSingleInt(pParse, "synchronous", &safetyLevel); }else{ if( !db->autoCommit ){ sqlite3ErrorMsg(pParse, "Safety level may not be changed inside a transaction"); }else{ u8 level = getSafetyLevel(zRight)+1; pDb->safety_level = (level | SQLITE_SAFETYLEVEL_FIXED); } } }else #endif /* SQLITE_OMIT_PAGER_PRAGMAS */ #ifndef SQLITE_OMIT_FLAG_PRAGMAS if( flagPragma(pParse, zLeft, zRight) ){ |
︙ | ︙ | |||
1523 1524 1525 1526 1527 1528 1529 | /* ** Reset the safety level, in case the fullfsync flag or synchronous ** setting changed. */ #ifndef SQLITE_OMIT_PAGER_PRAGMAS if( db->autoCommit ){ | | | 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 | /* ** Reset the safety level, in case the fullfsync flag or synchronous ** setting changed. */ #ifndef SQLITE_OMIT_PAGER_PRAGMAS if( db->autoCommit ){ sqlite3BtreeSetSafetyLevel(pDb->pBt, SQLITE_DbSafetyLevelValue(pDb->safety_level), (db->flags&SQLITE_FullFSync)!=0, (db->flags&SQLITE_CkptFullFSync)!=0); } #endif pragma_out: sqlite3DbFree(db, zLeft); sqlite3DbFree(db, zRight); } #endif /* SQLITE_OMIT_PRAGMA */ |
Changes to src/sqliteInt.h.
︙ | ︙ | |||
647 648 649 650 651 652 653 654 655 656 657 658 659 660 | #include "vdbe.h" #include "pager.h" #include "pcache.h" #include "os.h" #include "mutex.h" /* ** Each database file to be accessed by the system is an instance ** of the following structure. There are normally two of these structures ** in the sqlite.aDb[] array. aDb[0] is the main database file and ** aDb[1] is the database file used to hold temporary tables. Additional ** databases may be attached. | > > > > > > > > > > | 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 | #include "vdbe.h" #include "pager.h" #include "pcache.h" #include "os.h" #include "mutex.h" /* When using a default wal safety level, the safety level should only ** change with the journal mode if the user hasn't manually specified ** pragma synchronous, if they have the defaults shouldn't be applied. ** The SQLITE_SAFETYLEVEL_FIXED value is ORed into the Db->safety_level ** field when the user has specified a synchronous setting via pragma. */ #define SQLITE_SAFETYLEVEL_FIXED 0x10 #define SQLITE_SAFETYLEVEL_VALUE_MASK 0x03 #define SQLITE_DbSafetyLevelValue(level) (level&SQLITE_SAFETYLEVEL_VALUE_MASK) #define SQLITE_DbSafetyLevelIsFixed(level) (level&SQLITE_SAFETYLEVEL_FIXED) /* ** Each database file to be accessed by the system is an instance ** of the following structure. There are normally two of these structures ** in the sqlite.aDb[] array. aDb[0] is the main database file and ** aDb[1] is the database file used to hold temporary tables. Additional ** databases may be attached. |
︙ | ︙ |