/ Check-in [93e012a3]
Login

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

Overview
Comment:Do not count temporary databases that have been attached using ATTACH when figuring out if a master-journal file is required by a transaction.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 93e012a317c8a4bfb84327616a597acabfcb24417197eefdccb8031bcf64e0c0
User & Date: dan 2017-11-17 13:21:12
Context
2017-11-17
15:02
Clarification of comments on sqlite3FindInIndex(). No changes to code. check-in: 071cabd2 user: drh tags: trunk
13:23
Merge latest changes from trunk, including the temporary db/ATTACH/master-journal fix. check-in: 162c7543 user: dan tags: apple-osx
13:21
Do not count temporary databases that have been attached using ATTACH when figuring out if a master-journal file is required by a transaction. check-in: 93e012a3 user: dan tags: trunk
08:20
Avoid creating a master journal if all or all but one of the databases in the transaction is a temp file. Closed-Leaf check-in: 355d1232 user: dan tags: master-journal-temp-files
2017-11-16
20:48
In the LSM extension, ensure that empty space on pages is zeroed before they are written to disk. This helps with compressed databases, and stops valgrind complaining about uninitialized bytes and write(). check-in: 5ffec5db user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vdbeaux.c.

  2264   2264         };
  2265   2265         Pager *pPager;   /* Pager associated with pBt */
  2266   2266         needXcommit = 1;
  2267   2267         sqlite3BtreeEnter(pBt);
  2268   2268         pPager = sqlite3BtreePager(pBt);
  2269   2269         if( db->aDb[i].safety_level!=PAGER_SYNCHRONOUS_OFF
  2270   2270          && aMJNeeded[sqlite3PagerGetJournalMode(pPager)]
         2271  +       && sqlite3PagerIsMemdb(pPager)==0
  2271   2272         ){ 
  2272   2273           assert( i!=1 );
  2273   2274           nTrans++;
  2274   2275         }
  2275   2276         rc = sqlite3PagerExclusiveLock(pPager);
  2276   2277         sqlite3BtreeLeave(pBt);
  2277   2278       }

Changes to test/mjournal.test.

    75     75     hexio_write test1 0 abcd
    76     76   } {2}
    77     77   
    78     78   do_execsql_test 1.6 {
    79     79     SELECT * FROM t1;
    80     80   }
    81     81   
    82         -  
           82  +#-------------------------------------------------------------------------
           83  +# Check that master journals are not created if the transaction involves
           84  +# multiple temp files.
           85  +#
           86  +db close
           87  +testvfs tvfs
           88  +tvfs filter xOpen
           89  +tvfs script open_cb
           90  +set ::open ""
           91  +proc open_cb {method file arglist} {
           92  +  lappend ::open $file
           93  +}
           94  +
           95  +proc contains_mj {} {
           96  +  foreach f $::open {
           97  +    set t [file tail $f]
           98  +    if {[string match *mj* $t]} { return 1 }
           99  +  }
          100  +  return 0
          101  +}
          102  +
          103  +# Like [do_execsql_test], except that a boolean indicating whether or
          104  +# not a master journal file was opened ([file tail] contains "mj") or
          105  +# not. Example:
          106  +#
          107  +#   do_hasmj_test 1.0 { SELECT 'a', 'b' } {0 a b}
          108  +#
          109  +proc do_hasmj_test {tn sql expected} {
          110  +  set ::open [list]
          111  +  uplevel [list do_test $tn [subst -nocommands {
          112  +    set res [execsql "$sql"]
          113  +    concat [contains_mj] [set res]
          114  +  }] [list {*}$expected]]
          115  +}
          116  +
          117  +forcedelete test.db
          118  +forcedelete test.db2
          119  +forcedelete test.db3
          120  +sqlite3 db test.db -vfs tvfs
          121  +
          122  +do_execsql_test 2.0 {
          123  +  ATTACH 'test.db2' AS dbfile;
          124  +  ATTACH ''         AS dbtemp;
          125  +  ATTACH ':memory:'  AS dbmem;
          126  +
          127  +  CREATE TABLE t1(x);
          128  +  CREATE TABLE dbfile.t2(x);
          129  +  CREATE TABLE dbtemp.t3(x);
          130  +  CREATE TABLE dbmem.t4(x);
          131  +}
          132  +
          133  +# Two real files.
          134  +do_hasmj_test 2.1 {
          135  +  BEGIN;
          136  +    INSERT INTO t1 VALUES(1);
          137  +    INSERT INTO t2 VALUES(1);
          138  +  COMMIT;
          139  +} {1}
          140  +
          141  +# One real, one temp file.
          142  +do_hasmj_test 2.2 {
          143  +  BEGIN;
          144  +    INSERT INTO t1 VALUES(1);
          145  +    INSERT INTO t3 VALUES(1);
          146  +  COMMIT;
          147  +} {0}
          148  +
          149  +# One file, one :memory: db.
          150  +do_hasmj_test 2.3 {
          151  +  BEGIN;
          152  +    INSERT INTO t1 VALUES(1);
          153  +    INSERT INTO t4 VALUES(1);
          154  +  COMMIT;
          155  +} {0}
          156  +
    83    157   finish_test
          158  +