/ Check-in [aa9f4c62]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Remove code not needed now that synchronous=OFF database files no longer trigger the use of a master journal.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: aa9f4c622af191edbeb6a535942944f8c91f5c37
User & Date: drh 2016-02-22 23:44:42
Context
2016-02-23
16:28
Add the SQLITE_BITMASK_TYPE compile-time option. check-in: 0064a8c7 user: drh tags: trunk
01:41
Merge trunk enhancements. check-in: fac4f4ec user: drh tags: lsm-vtab
2016-02-22
23:44
Remove code not needed now that synchronous=OFF database files no longer trigger the use of a master journal. check-in: aa9f4c62 user: drh tags: trunk
23:14
Avoid an unnecessary seek operation some corner-case skip-scan operations. check-in: 2a6003a9 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/btree.c.

  2615   2615     sqlite3BtreeEnter(p);
  2616   2616     sqlite3PagerSetFlags(pBt->pPager, pgFlags);
  2617   2617     sqlite3BtreeLeave(p);
  2618   2618     return SQLITE_OK;
  2619   2619   }
  2620   2620   #endif
  2621   2621   
  2622         -/*
  2623         -** Return TRUE if the given btree is set to safety level 1.  In other
  2624         -** words, return TRUE if no sync() occurs on the disk files.
  2625         -*/
  2626         -int sqlite3BtreeSyncDisabled(Btree *p){
  2627         -  BtShared *pBt = p->pBt;
  2628         -  int rc;
  2629         -  assert( sqlite3_mutex_held(p->db->mutex) );  
  2630         -  sqlite3BtreeEnter(p);
  2631         -  assert( pBt && pBt->pPager );
  2632         -  rc = sqlite3PagerNosync(pBt->pPager);
  2633         -  sqlite3BtreeLeave(p);
  2634         -  return rc;
  2635         -}
  2636         -
  2637   2622   /*
  2638   2623   ** Change the default pages size and the number of reserved bytes per page.
  2639   2624   ** Or, if the page size has already been fixed, return SQLITE_READONLY 
  2640   2625   ** without changing anything.
  2641   2626   **
  2642   2627   ** The page size must be a power of 2 between 512 and 65536.  If the page
  2643   2628   ** size supplied does not meet this constraint then the page size is not

Changes to src/btree.h.

    64     64   int sqlite3BtreeClose(Btree*);
    65     65   int sqlite3BtreeSetCacheSize(Btree*,int);
    66     66   int sqlite3BtreeSetSpillSize(Btree*,int);
    67     67   #if SQLITE_MAX_MMAP_SIZE>0
    68     68     int sqlite3BtreeSetMmapLimit(Btree*,sqlite3_int64);
    69     69   #endif
    70     70   int sqlite3BtreeSetPagerFlags(Btree*,unsigned);
    71         -int sqlite3BtreeSyncDisabled(Btree*);
    72     71   int sqlite3BtreeSetPageSize(Btree *p, int nPagesize, int nReserve, int eFix);
    73     72   int sqlite3BtreeGetPageSize(Btree*);
    74     73   int sqlite3BtreeMaxPageCount(Btree*,int);
    75     74   u32 sqlite3BtreeLastPage(Btree*);
    76     75   int sqlite3BtreeSecureDelete(Btree*,int);
    77     76   int sqlite3BtreeGetOptimalReserve(Btree*);
    78     77   int sqlite3BtreeGetReserveNoMutex(Btree *p);

Changes to src/pager.c.

  6734   6734   /*
  6735   6735   ** Return the full pathname of the journal file.
  6736   6736   */
  6737   6737   const char *sqlite3PagerJournalname(Pager *pPager){
  6738   6738     return pPager->zJournal;
  6739   6739   }
  6740   6740   
  6741         -/*
  6742         -** Return true if fsync() calls are disabled for this pager.  Return FALSE
  6743         -** if fsync()s are executed normally.
  6744         -*/
  6745         -int sqlite3PagerNosync(Pager *pPager){
  6746         -  return pPager->noSync;
  6747         -}
  6748         -
  6749   6741   #ifdef SQLITE_HAS_CODEC
  6750   6742   /*
  6751   6743   ** Set or retrieve the codec for this pager
  6752   6744   */
  6753   6745   void sqlite3PagerSetCodec(
  6754   6746     Pager *pPager,
  6755   6747     void *(*xCodec)(void*,void*,Pgno,int),

Changes to src/pager.h.

   187    187   #endif
   188    188   int sqlite3PagerMemUsed(Pager*);
   189    189   const char *sqlite3PagerFilename(Pager*, int);
   190    190   sqlite3_vfs *sqlite3PagerVfs(Pager*);
   191    191   sqlite3_file *sqlite3PagerFile(Pager*);
   192    192   sqlite3_file *sqlite3PagerJrnlFile(Pager*);
   193    193   const char *sqlite3PagerJournalname(Pager*);
   194         -int sqlite3PagerNosync(Pager*);
   195    194   void *sqlite3PagerTempSpace(Pager*);
   196    195   int sqlite3PagerIsMemdb(Pager*);
   197    196   void sqlite3PagerCacheStat(Pager *, int, int, int *);
   198    197   void sqlite3PagerClearCache(Pager *);
   199    198   int sqlite3SectorSize(sqlite3_file *);
   200    199   
   201    200   /* Functions used to truncate the database file. */

Changes to src/vdbeaux.c.

  2245   2245     /* The complex case - There is a multi-file write-transaction active.
  2246   2246     ** This requires a master journal file to ensure the transaction is
  2247   2247     ** committed atomically.
  2248   2248     */
  2249   2249   #ifndef SQLITE_OMIT_DISKIO
  2250   2250     else{
  2251   2251       sqlite3_vfs *pVfs = db->pVfs;
  2252         -    int needSync = 0;
  2253   2252       char *zMaster = 0;   /* File-name for the master journal */
  2254   2253       char const *zMainFile = sqlite3BtreeGetFilename(db->aDb[0].pBt);
  2255   2254       sqlite3_file *pMaster = 0;
  2256   2255       i64 offset = 0;
  2257   2256       int res;
  2258   2257       int retryCount = 0;
  2259   2258       int nMainFile;
................................................................................
  2305   2304         Btree *pBt = db->aDb[i].pBt;
  2306   2305         if( sqlite3BtreeIsInTrans(pBt) ){
  2307   2306           char const *zFile = sqlite3BtreeGetJournalname(pBt);
  2308   2307           if( zFile==0 ){
  2309   2308             continue;  /* Ignore TEMP and :memory: databases */
  2310   2309           }
  2311   2310           assert( zFile[0]!=0 );
  2312         -        if( !needSync && !sqlite3BtreeSyncDisabled(pBt) ){
  2313         -          needSync = 1;
  2314         -        }
  2315   2311           rc = sqlite3OsWrite(pMaster, zFile, sqlite3Strlen30(zFile)+1, offset);
  2316   2312           offset += sqlite3Strlen30(zFile)+1;
  2317   2313           if( rc!=SQLITE_OK ){
  2318   2314             sqlite3OsCloseFree(pMaster);
  2319   2315             sqlite3OsDelete(pVfs, zMaster, 0);
  2320   2316             sqlite3DbFree(db, zMaster);
  2321   2317             return rc;
................................................................................
  2322   2318           }
  2323   2319         }
  2324   2320       }
  2325   2321   
  2326   2322       /* Sync the master journal file. If the IOCAP_SEQUENTIAL device
  2327   2323       ** flag is set this is not required.
  2328   2324       */
  2329         -    if( needSync 
  2330         -     && 0==(sqlite3OsDeviceCharacteristics(pMaster)&SQLITE_IOCAP_SEQUENTIAL)
         2325  +    if( 0==(sqlite3OsDeviceCharacteristics(pMaster)&SQLITE_IOCAP_SEQUENTIAL)
  2331   2326        && SQLITE_OK!=(rc = sqlite3OsSync(pMaster, SQLITE_SYNC_NORMAL))
  2332   2327       ){
  2333   2328         sqlite3OsCloseFree(pMaster);
  2334   2329         sqlite3OsDelete(pVfs, zMaster, 0);
  2335   2330         sqlite3DbFree(db, zMaster);
  2336   2331         return rc;
  2337   2332       }
................................................................................
  2359   2354         return rc;
  2360   2355       }
  2361   2356   
  2362   2357       /* Delete the master journal file. This commits the transaction. After
  2363   2358       ** doing this the directory is synced again before any individual
  2364   2359       ** transaction files are deleted.
  2365   2360       */
  2366         -    rc = sqlite3OsDelete(pVfs, zMaster, needSync);
         2361  +    rc = sqlite3OsDelete(pVfs, zMaster, 1);
  2367   2362       sqlite3DbFree(db, zMaster);
  2368   2363       zMaster = 0;
  2369   2364       if( rc ){
  2370   2365         return rc;
  2371   2366       }
  2372   2367   
  2373   2368       /* All files and directories have already been synced, so the following