/ Check-in [f509eb8b]
Login

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

Overview
Comment:Added SQLITE_OPEN_SHAREDCACHE and SQLITE_OPEN_PRIVATECACHE flags as possibilities to sqlite3_open_v2(), to override the global shared cache mode setting. Ticket [9fd0bc36639c15]
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: f509eb8b488bb39deda4ca88f66ed40c6784af02
User & Date: drh 2009-09-09 14:17:53
References
2009-09-09
14:26 Fixed ticket [9fd0bc36]: Add a new open flag to enable shared cache for a single db connection plus 3 other changes artifact: afa0825e user: drh
Context
2009-09-09
14:48
Update the README file to state that TCL is required in order to run the makefiles for SQLite. Ticket [7d96113ff]. check-in: ba20091a user: drh tags: trunk
14:17
Added SQLITE_OPEN_SHAREDCACHE and SQLITE_OPEN_PRIVATECACHE flags as possibilities to sqlite3_open_v2(), to override the global shared cache mode setting. Ticket [9fd0bc36639c15] check-in: f509eb8b user: drh tags: trunk
12:41
Increase the size of bitvec objects to 1024 bytes on 64-bit systems. check-in: f1272b90 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/btree.c.

  1690   1690   
  1691   1691   #if !defined(SQLITE_OMIT_SHARED_CACHE) && !defined(SQLITE_OMIT_DISKIO)
  1692   1692     /*
  1693   1693     ** If this Btree is a candidate for shared cache, try to find an
  1694   1694     ** existing BtShared object that we can share with
  1695   1695     */
  1696   1696     if( isMemdb==0 && zFilename && zFilename[0] ){
  1697         -    if( sqlite3GlobalConfig.sharedCacheEnabled ){
         1697  +    if( vfsFlags & SQLITE_OPEN_SHAREDCACHE ){
  1698   1698         int nFullPathname = pVfs->mxPathname+1;
  1699   1699         char *zFullPathname = sqlite3Malloc(nFullPathname);
  1700   1700         sqlite3_mutex *mutexShared;
  1701   1701         p->sharable = 1;
  1702   1702         if( !zFullPathname ){
  1703   1703           sqlite3_free(p);
  1704   1704           return SQLITE_NOMEM;

Changes to src/main.c.

  1539   1539       isThreadsafe = 0;
  1540   1540     }else if( flags & SQLITE_OPEN_NOMUTEX ){
  1541   1541       isThreadsafe = 0;
  1542   1542     }else if( flags & SQLITE_OPEN_FULLMUTEX ){
  1543   1543       isThreadsafe = 1;
  1544   1544     }else{
  1545   1545       isThreadsafe = sqlite3GlobalConfig.bFullMutex;
         1546  +  }
         1547  +  if( flags & SQLITE_OPEN_PRIVATECACHE ){
         1548  +    flags &= SQLITE_OPEN_SHAREDCACHE;
         1549  +  }else if( sqlite3GlobalConfig.sharedCacheEnabled ){
         1550  +    flags |= SQLITE_OPEN_SHAREDCACHE;
  1546   1551     }
  1547   1552   
  1548   1553     /* Remove harmful bits from the flags parameter
  1549   1554     **
  1550   1555     ** The SQLITE_OPEN_NOMUTEX and SQLITE_OPEN_FULLMUTEX flags were
  1551   1556     ** dealt with in the previous code block.  Besides these, the only
  1552   1557     ** valid input flags for sqlite3_open_v2() are SQLITE_OPEN_READONLY,

Changes to src/os.c.

   110    110     const char *zPath, 
   111    111     sqlite3_file *pFile, 
   112    112     int flags, 
   113    113     int *pFlagsOut
   114    114   ){
   115    115     int rc;
   116    116     DO_OS_MALLOC_TEST(0);
   117         -  rc = pVfs->xOpen(pVfs, zPath, pFile, flags, pFlagsOut);
          117  +  /* 0x7f1f is a mask of SQLITE_OPEN_ flags that are valid to be passed
          118  +  ** down into the VFS layer.  Some SQLITE_OPEN_ flags (for example,
          119  +  ** SQLITE_OPEN_FULLMUTEX or SQLITE_OPEN_SHAREDCACHE) are blocked before
          120  +  ** reaching the VFS. */
          121  +  rc = pVfs->xOpen(pVfs, zPath, pFile, flags & 0x7f1f, pFlagsOut);
   118    122     assert( rc==SQLITE_OK || pFile->pMethods==0 );
   119    123     return rc;
   120    124   }
   121    125   int sqlite3OsDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){
   122    126     return pVfs->xDelete(pVfs, zPath, dirSync);
   123    127   }
   124    128   int sqlite3OsAccess(

Changes to src/sqlite.h.in.

   430    430   #define SQLITE_OPEN_TRANSIENT_DB     0x00000400  /* VFS only */
   431    431   #define SQLITE_OPEN_MAIN_JOURNAL     0x00000800  /* VFS only */
   432    432   #define SQLITE_OPEN_TEMP_JOURNAL     0x00001000  /* VFS only */
   433    433   #define SQLITE_OPEN_SUBJOURNAL       0x00002000  /* VFS only */
   434    434   #define SQLITE_OPEN_MASTER_JOURNAL   0x00004000  /* VFS only */
   435    435   #define SQLITE_OPEN_NOMUTEX          0x00008000  /* Ok for sqlite3_open_v2() */
   436    436   #define SQLITE_OPEN_FULLMUTEX        0x00010000  /* Ok for sqlite3_open_v2() */
          437  +#define SQLITE_OPEN_SHAREDCACHE      0x00020000  /* Ok for sqlite3_open_v2() */
          438  +#define SQLITE_OPEN_PRIVATECACHE     0x00040000  /* Ok for sqlite3_open_v2() */
   437    439   
   438    440   /*
   439    441   ** CAPI3REF: Device Characteristics {H10240} <H11120>
   440    442   **
   441    443   ** The xDeviceCapabilities method of the [sqlite3_io_methods]
   442    444   ** object returns an integer which is a vector of the these
   443    445   ** bit values expressing I/O characteristics of the mass storage
................................................................................
  2091   2093   ** associated with the [database connection] handle should be released by
  2092   2094   ** passing it to [sqlite3_close()] when it is no longer required.
  2093   2095   **
  2094   2096   ** The sqlite3_open_v2() interface works like sqlite3_open()
  2095   2097   ** except that it accepts two additional parameters for additional control
  2096   2098   ** over the new database connection.  The flags parameter can take one of
  2097   2099   ** the following three values, optionally combined with the 
  2098         -** [SQLITE_OPEN_NOMUTEX] or [SQLITE_OPEN_FULLMUTEX] flags:
         2100  +** [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX], [SQLITE_OPEN_SHAREDCACHE],
         2101  +** and/or [SQLITE_OPEN_PRIVATECACHE] flags:
  2099   2102   **
  2100   2103   ** <dl>
  2101   2104   ** <dt>[SQLITE_OPEN_READONLY]</dt>
  2102   2105   ** <dd>The database is opened in read-only mode.  If the database does not
  2103   2106   ** already exist, an error is returned.</dd>
  2104   2107   **
  2105   2108   ** <dt>[SQLITE_OPEN_READWRITE]</dt>
................................................................................
  2111   2114   ** <dd>The database is opened for reading and writing, and is creates it if
  2112   2115   ** it does not already exist. This is the behavior that is always used for
  2113   2116   ** sqlite3_open() and sqlite3_open16().</dd>
  2114   2117   ** </dl>
  2115   2118   **
  2116   2119   ** If the 3rd parameter to sqlite3_open_v2() is not one of the
  2117   2120   ** combinations shown above or one of the combinations shown above combined
  2118         -** with the [SQLITE_OPEN_NOMUTEX] or [SQLITE_OPEN_FULLMUTEX] flags,
         2121  +** with the [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX],
         2122  +** [SQLITE_OPEN_SHAREDCACHE] and/or [SQLITE_OPEN_SHAREDCACHE] flags,
  2119   2123   ** then the behavior is undefined.
  2120   2124   **
  2121   2125   ** If the [SQLITE_OPEN_NOMUTEX] flag is set, then the database connection
  2122   2126   ** opens in the multi-thread [threading mode] as long as the single-thread
  2123   2127   ** mode has not been set at compile-time or start-time.  If the
  2124   2128   ** [SQLITE_OPEN_FULLMUTEX] flag is set then the database connection opens
  2125   2129   ** in the serialized [threading mode] unless single-thread was
  2126   2130   ** previously selected at compile-time or start-time.
         2131  +** The [SQLITE_OPEN_SHAREDCACHE] flag causes the database connection to be
         2132  +** eligible to use [shared cache mode], regardless of whether or not shared
         2133  +** cache is enabled using [sqlite3_enable_shared_cache()].  The
         2134  +** [SQLITE_OPEN_PRIVATECACHE] flag causes the database connection to not
         2135  +** participate in [shared cache mode] even if it is enabled.
  2127   2136   **
  2128   2137   ** If the filename is ":memory:", then a private, temporary in-memory database
  2129   2138   ** is created for the connection.  This in-memory database will vanish when
  2130   2139   ** the database connection is closed.  Future versions of SQLite might
  2131   2140   ** make use of additional special filenames that begin with the ":" character.
  2132   2141   ** It is recommended that when a database filename actually does begin with
  2133   2142   ** a ":" character you should prefix the filename with a pathname such as