/ Check-in [ee1e0122]
Login

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

Overview
Comment:Change the multiplexor VFS so that xTruncate is a no-op on database files.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: ee1e012256ae8010b6b6c4895a74b6883f20e73c
User & Date: dan 2011-12-12 18:55:44
Context
2011-12-12
19:48
Fix os_unix.c so that, unless 8.3 filenames are actually in use, journal and wal file permissions are assigned correctly even if SQLITE_ENABLE_8_3_NAMES is defined. check-in: 169e1229 user: dan tags: trunk
18:55
Change the multiplexor VFS so that xTruncate is a no-op on database files. check-in: ee1e0122 user: dan tags: trunk
18:21
Fix for the xFileSize method of test_multiplex.c when used on a file opened with the DELETEONCLOSE flag set. check-in: 713071c4 user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/test_multiplex.c.

   745    745     if( !pGroup->bEnabled ){
   746    746       sqlite3_file *pSubOpen = multiplexSubOpen(pGroup, 0, &rc, NULL);
   747    747       if( pSubOpen==0 ){
   748    748         rc = SQLITE_IOERR_TRUNCATE;
   749    749       }else{
   750    750         rc = pSubOpen->pMethods->xTruncate(pSubOpen, size);
   751    751       }
   752         -  }else{
          752  +  }else if( (pGroup->flags & SQLITE_OPEN_MAIN_DB)==0 ){
   753    753       int rc2;
   754    754       int i;
   755    755       sqlite3_file *pSubOpen;
   756    756       sqlite3_vfs *pOrigVfs = gMultiplex.pOrigVfs;   /* Real VFS */
   757    757       /* delete the chunks above the truncate limit */
   758    758       for(i=(int)(size / pGroup->szChunk)+1; i<pGroup->nReal; i++){
   759    759         multiplexSubClose(pGroup, i, pOrigVfs);

Added test/multiplex2.test.

            1  +# 2010 October 29
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            6  +#    May you do good and not evil.
            7  +#    May you find forgiveness for yourself and forgive others.
            8  +#    May you share freely, never taking more than you give.
            9  +#
           10  +#***********************************************************************
           11  +#
           12  +
           13  +set testdir [file dirname $argv0]
           14  +source $testdir/tester.tcl
           15  +source $testdir/malloc_common.tcl
           16  +source $testdir/lock_common.tcl
           17  +
           18  +
           19  +do_multiclient_test tn {
           20  +  code1 { catch { sqlite3_multiplex_initialize "" 0 } }
           21  +  code2 { catch { sqlite3_multiplex_initialize "" 0 } }
           22  +
           23  +  code1 { db close }
           24  +  code2 { db2 close }
           25  +
           26  +  code1 { sqlite3 db test.db -vfs multiplex }
           27  +  code2 { sqlite3 db2 test.db -vfs multiplex }
           28  +
           29  +  code1 { sqlite3_multiplex_control db main chunk_size [expr 1024*1024] }
           30  +  code2 { sqlite3_multiplex_control db2 main chunk_size [expr 1024*1024] }
           31  +
           32  +  sql1 {
           33  +    CREATE TABLE t1(a, b);
           34  +    INSERT INTO t1 VALUES(randomblob(10), randomblob(4000));          --    1
           35  +    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --    2
           36  +    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --    4
           37  +    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --    8
           38  +    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --   16
           39  +    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --   32
           40  +    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --   64
           41  +    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --  128
           42  +    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --  256
           43  +    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --  512
           44  +    SELECT count(*) FROM t1;
           45  +  } 
           46  +
           47  +  do_test multiplex-1.$tn.1 { sql1 { SELECT count(*) FROM t1 } } 512
           48  +  do_test multiplex-1.$tn.2 { sql2 { SELECT count(*) FROM t1 } } 512
           49  +  sql2 { DELETE FROM t1 ; VACUUM }
           50  +  do_test multiplex-1.$tn.3 { sql1 { SELECT count(*) FROM t1 } } 0
           51  +
           52  +  sql1 {
           53  +    INSERT INTO t1 VALUES(randomblob(10), randomblob(4000));          --    1
           54  +    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --    2
           55  +    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --    4
           56  +    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --    8
           57  +    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --   16
           58  +    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --   32
           59  +    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --   64
           60  +    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --  128
           61  +    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --  256
           62  +    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --  512
           63  +    SELECT count(*) FROM t1;
           64  +  }
           65  +
           66  +  do_test multiplex-1.$tn.4 { sql2 { SELECT count(*) FROM t1 } } 512
           67  +}
           68  +
           69  +catch { sqlite3_multiplex_shutdown }
           70  +finish_test