/ Check-in [ef126e77]
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:Make sure the schema is loaded before preparing a "PRAGMA journal_mode" command. This helps it return meaningful results when it is the first command executed by a new database connection.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: ef126e775a02d69a9cab53028513e8799e1b6044
User & Date: dan 2010-07-07 13:54:29
References
2010-07-08
09:44
Changes to test scripts so that the "inmemory_journal" permutation works with [ef126e775a]. check-in: f553c8ed user: dan tags: trunk
Context
2010-07-07
14:00
Merge together the accident fork. check-in: cdcf08cb user: drh tags: trunk
13:54
Make sure the schema is loaded before preparing a "PRAGMA journal_mode" command. This helps it return meaningful results when it is the first command executed by a new database connection. check-in: ef126e77 user: dan tags: trunk
13:43
Add testcase macros to ensure that large-file cases are tested in WAL. check-in: 8156b57a user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/pragma.c.

   532    532     /*
   533    533     **  PRAGMA [database.]journal_mode
   534    534     **  PRAGMA [database.]journal_mode =
   535    535     **                      (delete|persist|off|truncate|memory|wal|off)
   536    536     */
   537    537     if( sqlite3StrICmp(zLeft,"journal_mode")==0 ){
   538    538       int eMode;                    /* One of the PAGER_JOURNALMODE_XXX symbols */
          539  +
          540  +    if( sqlite3ReadSchema(pParse) ){
          541  +      goto pragma_out;
          542  +    }
   539    543   
   540    544       sqlite3VdbeSetNumCols(v, 1);
   541    545       sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "journal_mode", SQLITE_STATIC);
   542    546   
   543    547       if( zRight==0 ){
   544    548         eMode = PAGER_JOURNALMODE_QUERY;
   545    549       }else{

Changes to test/pager1.test.

  1436   1436     execsql {
  1437   1437       PRAGMA journal_mode = TRUNCATE;
  1438   1438       PRAGMA integrity_check;
  1439   1439     } db2
  1440   1440   } {truncate ok}
  1441   1441   do_test pager1-11.4 {
  1442   1442     db2 close
  1443         -  file size test.db-journal
         1443  +  file exists test.db-journal
  1444   1444   } {0}
  1445   1445   do_execsql_test pager1-11.5 { SELECT count(*) FROM zz } {32}
  1446   1446   db close
  1447   1447   tv delete
  1448   1448     
  1449   1449   #-------------------------------------------------------------------------
  1450   1450   # Test "PRAGMA page_size"

Changes to test/wal2.test.

   615    615       BEGIN;
   616    616         CREATE TABLE t1(x);
   617    617         INSERT INTO t1 VALUES('Leonard');
   618    618         INSERT INTO t1 VALUES('Arthur');
   619    619       COMMIT;
   620    620     } {wal} {
   621    621       $RECOVERY 
   622         -    $READMARK0_READ 
   623    622       $READMARK0_WRITE
   624    623     }
   625    624   
   626    625     3 {
   627    626       # This test should do the READMARK1_SET locking to populate the 
   628    627       # aReadMark[1] slot with the current mxFrame value. Followed by
   629    628       # READMARK1_READ to read the database.

Changes to test/walmode.test.

   269    269   } [list 1 2 3 4 $tempJrnlMode]
   270    270   
   271    271   
   272    272   #-------------------------------------------------------------------------
   273    273   # Test changing to WAL mode from journal_mode=off or journal_mode=memory
   274    274   #
   275    275   foreach {tn mode} {
          276  +  1 off
          277  +  2 memory
   276    278     3 persist
   277    279     4 delete
   278    280     5 truncate
   279         -  2 memory
   280         -  1 off
   281    281   } {
   282    282     do_test walmode-6.$tn {
   283    283       faultsim_delete_and_reopen
   284    284       execsql "
   285    285         PRAGMA journal_mode = $mode;
   286    286         PRAGMA journal_mode = wal;
   287    287       "
   288    288     } [list $mode wal]
   289    289   }
          290  +db close
          291  +
          292  +do_test walmode-7.0 {
          293  +  file delete -force test.db
          294  +  sqlite3 db test.db
          295  +  execsql {
          296  +    PRAGMA journal_mode = WAL;
          297  +    CREATE TABLE t1(a, b);
          298  +  }
          299  +} {wal}
          300  +foreach {tn sql result} {
          301  +  1  "PRAGMA journal_mode"                delete
          302  +  2  "PRAGMA main.journal_mode"           wal
          303  +  3  "PRAGMA journal_mode = delete"       delete
          304  +  4  "PRAGMA journal_mode"                delete
          305  +  5  "PRAGMA main.journal_mode"           delete
          306  +  6  "PRAGMA journal_mode = wal"          wal
          307  +  7  "PRAGMA journal_mode"                delete
          308  +  8  "PRAGMA main.journal_mode"           wal
          309  +
          310  +  9  "PRAGMA journal_mode"                delete
          311  + 10  "PRAGMA main.journal_mode"           wal
          312  + 11  "PRAGMA main.journal_mode = delete"  delete
          313  + 12  "PRAGMA journal_mode"                delete
          314  + 13  "PRAGMA main.journal_mode"           delete
          315  + 14  "PRAGMA main.journal_mode = wal"     wal
          316  + 15  "PRAGMA journal_mode"                delete
          317  + 16  "PRAGMA main.journal_mode"           wal
          318  +} {
          319  +  do_test walmode-7.$tn { 
          320  +    db close
          321  +    sqlite3 db test.db
          322  +    execsql $sql
          323  +  } $result
          324  +}
          325  +db close
   290    326   
   291    327   finish_test