/ Check-in [3e490915]
Login

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

Overview
Comment:Have flags passed to sqlite3_open_v2() apply to the main and any attached databases. And change things so that any "mode=xxx" or "cache=xxx" options specified as part of a URI for the main database do not also apply to attached databases.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 3e490915301216e242a5cdeb0febaff12ed53cb9
User & Date: dan 2011-05-10 18:39:10
Context
2011-05-11
19:00
URI filename documentation updates. check-in: 8885c867 user: drh tags: trunk
15:53
Merge latest trunk changes. Add a couple of readonly shm tests. check-in: cde45a03 user: dan tags: wal-readonly
2011-05-10
18:39
Have flags passed to sqlite3_open_v2() apply to the main and any attached databases. And change things so that any "mode=xxx" or "cache=xxx" options specified as part of a URI for the main database do not also apply to attached databases. check-in: 3e490915 user: dan tags: trunk
17:43
Update URI test cases to account for the new error message format. check-in: 5bde5680 user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/main.c.

  2159   2159     assert( db->pDfltColl!=0 );
  2160   2160   
  2161   2161     /* Also add a UTF-8 case-insensitive collation sequence. */
  2162   2162     createCollation(db, "NOCASE", SQLITE_UTF8, SQLITE_COLL_NOCASE, 0,
  2163   2163                     nocaseCollatingFunc, 0);
  2164   2164   
  2165   2165     /* Parse the filename/URI argument. */
         2166  +  db->openFlags = flags;
  2166   2167     rc = sqlite3ParseUri(zVfs, zFilename, &flags, &db->pVfs, &zOpen, &zErrMsg);
  2167   2168     if( rc!=SQLITE_OK ){
  2168   2169       if( rc==SQLITE_NOMEM ) db->mallocFailed = 1;
  2169   2170       sqlite3Error(db, rc, zErrMsg ? "%s" : 0, zErrMsg);
  2170   2171       sqlite3_free(zErrMsg);
  2171   2172       goto opendb_out;
  2172   2173     }
  2173   2174   
  2174   2175     /* Open the backend database driver */
  2175         -  db->openFlags = flags;
  2176   2176     rc = sqlite3BtreeOpen(db->pVfs, zOpen, db, &db->aDb[0].pBt, 0,
  2177   2177                           flags | SQLITE_OPEN_MAIN_DB);
  2178   2178     if( rc!=SQLITE_OK ){
  2179   2179       if( rc==SQLITE_IOERR_NOMEM ){
  2180   2180         rc = SQLITE_NOMEM;
  2181   2181       }
  2182   2182       sqlite3Error(db, rc, 0);

Changes to test/uri.test.

    17     17   #
    18     18   #   1.*: That file names are correctly extracted from URIs.
    19     19   #   2.*: That URI options (query parameters) are correctly extracted from URIs.
    20     20   #   3.*: That specifying an unknown VFS causes an error.
    21     21   #   4.*: Tests for specifying other options (other than "vfs").
    22     22   #   5.*: Test using a different VFS with an attached database.
    23     23   #   6.*: Test that authorities other than "" and localhost cause errors.
           24  +#   7.*: Test that a read-write db can be attached to a read-only connection.
    24     25   #
    25     26   
    26     27   set testprefix uri
    27     28   db close
    28     29   sqlite3_shutdown
    29     30   sqlite3_config_uri 1
    30     31   
................................................................................
   278    279     do_test 6.$tn {
   279    280       set DB [sqlite3_open $uri]
   280    281       sqlite3_errmsg $DB
   281    282     } $res
   282    283     catch { sqlite3_close $DB }
   283    284   }
   284    285   
   285         -finish_test
          286  +forcedelete test.db test.db2
          287  +do_test 7.1 {
          288  +  sqlite3 db test.db
          289  +  execsql {
          290  +    CREATE TABLE t1(a, b);
          291  +    INSERT INTO t1 VALUES(1, 2);
          292  +    ATTACH 'test.db2' AS aux;
          293  +    CREATE TABLE aux.t2(a, b);
          294  +    INSERT INTO t1 VALUES('a', 'b');
          295  +  }
          296  +  db close
          297  +} {}
          298  +do_test 7.2 {
          299  +  sqlite3 db file:test.db?mode=ro
          300  +  execsql { ATTACH 'file:test.db2?mode=rw' AS aux }
          301  +} {}
          302  +do_execsql_test  7.3 { 
          303  +  INSERT INTO t2 VALUES('c', 'd') 
          304  +} {}
          305  +do_catchsql_test 7.4 { 
          306  +  INSERT INTO t1 VALUES(3, 4) 
          307  +} {1 {attempt to write a readonly database}}
   286    308   
          309  +finish_test