SQLite

Check-in [ef126e775a]
Login

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
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: ef126e775a02d69a9cab53028513e8799e1b6044
User & Date: dan 2010-07-07 13:54:29.000
References
2010-07-08
09:44
Changes to test scripts so that the "inmemory_journal" permutation works with [ef126e775a]. (check-in: f553c8ed04 user: dan tags: trunk)
Context
2010-07-07
14:00
Merge together the accident fork. (check-in: cdcf08cb18 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: ef126e775a user: dan tags: trunk)
13:43
Add testcase macros to ensure that large-file cases are tested in WAL. (check-in: 8156b57ac3 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/pragma.c.
532
533
534
535
536
537
538




539
540
541
542
543
544
545
  /*
  **  PRAGMA [database.]journal_mode
  **  PRAGMA [database.]journal_mode =
  **                      (delete|persist|off|truncate|memory|wal|off)
  */
  if( sqlite3StrICmp(zLeft,"journal_mode")==0 ){
    int eMode;                    /* One of the PAGER_JOURNALMODE_XXX symbols */





    sqlite3VdbeSetNumCols(v, 1);
    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "journal_mode", SQLITE_STATIC);

    if( zRight==0 ){
      eMode = PAGER_JOURNALMODE_QUERY;
    }else{







>
>
>
>







532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
  /*
  **  PRAGMA [database.]journal_mode
  **  PRAGMA [database.]journal_mode =
  **                      (delete|persist|off|truncate|memory|wal|off)
  */
  if( sqlite3StrICmp(zLeft,"journal_mode")==0 ){
    int eMode;                    /* One of the PAGER_JOURNALMODE_XXX symbols */

    if( sqlite3ReadSchema(pParse) ){
      goto pragma_out;
    }

    sqlite3VdbeSetNumCols(v, 1);
    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "journal_mode", SQLITE_STATIC);

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







|







1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
  execsql {
    PRAGMA journal_mode = TRUNCATE;
    PRAGMA integrity_check;
  } db2
} {truncate ok}
do_test pager1-11.4 {
  db2 close
  file exists test.db-journal
} {0}
do_execsql_test pager1-11.5 { SELECT count(*) FROM zz } {32}
db close
tv delete
  
#-------------------------------------------------------------------------
# Test "PRAGMA page_size"
Changes to test/wal2.test.
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
    BEGIN;
      CREATE TABLE t1(x);
      INSERT INTO t1 VALUES('Leonard');
      INSERT INTO t1 VALUES('Arthur');
    COMMIT;
  } {wal} {
    $RECOVERY 
    $READMARK0_READ 
    $READMARK0_WRITE
  }

  3 {
    # This test should do the READMARK1_SET locking to populate the 
    # aReadMark[1] slot with the current mxFrame value. Followed by
    # READMARK1_READ to read the database.







<







615
616
617
618
619
620
621

622
623
624
625
626
627
628
    BEGIN;
      CREATE TABLE t1(x);
      INSERT INTO t1 VALUES('Leonard');
      INSERT INTO t1 VALUES('Arthur');
    COMMIT;
  } {wal} {
    $RECOVERY 

    $READMARK0_WRITE
  }

  3 {
    # This test should do the READMARK1_SET locking to populate the 
    # aReadMark[1] slot with the current mxFrame value. Followed by
    # READMARK1_READ to read the database.
Changes to test/walmode.test.
269
270
271
272
273
274
275


276
277
278
279
280
281
282
283
284
285
286
287
288
289




































290
291
} [list 1 2 3 4 $tempJrnlMode]


#-------------------------------------------------------------------------
# Test changing to WAL mode from journal_mode=off or journal_mode=memory
#
foreach {tn mode} {


  3 persist
  4 delete
  5 truncate
  2 memory
  1 off
} {
  do_test walmode-6.$tn {
    faultsim_delete_and_reopen
    execsql "
      PRAGMA journal_mode = $mode;
      PRAGMA journal_mode = wal;
    "
  } [list $mode wal]
}





































finish_test







>
>



<
<









>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


269
270
271
272
273
274
275
276
277
278
279
280


281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
} [list 1 2 3 4 $tempJrnlMode]


#-------------------------------------------------------------------------
# Test changing to WAL mode from journal_mode=off or journal_mode=memory
#
foreach {tn mode} {
  1 off
  2 memory
  3 persist
  4 delete
  5 truncate


} {
  do_test walmode-6.$tn {
    faultsim_delete_and_reopen
    execsql "
      PRAGMA journal_mode = $mode;
      PRAGMA journal_mode = wal;
    "
  } [list $mode wal]
}
db close

do_test walmode-7.0 {
  file delete -force test.db
  sqlite3 db test.db
  execsql {
    PRAGMA journal_mode = WAL;
    CREATE TABLE t1(a, b);
  }
} {wal}
foreach {tn sql result} {
  1  "PRAGMA journal_mode"                delete
  2  "PRAGMA main.journal_mode"           wal
  3  "PRAGMA journal_mode = delete"       delete
  4  "PRAGMA journal_mode"                delete
  5  "PRAGMA main.journal_mode"           delete
  6  "PRAGMA journal_mode = wal"          wal
  7  "PRAGMA journal_mode"                delete
  8  "PRAGMA main.journal_mode"           wal

  9  "PRAGMA journal_mode"                delete
 10  "PRAGMA main.journal_mode"           wal
 11  "PRAGMA main.journal_mode = delete"  delete
 12  "PRAGMA journal_mode"                delete
 13  "PRAGMA main.journal_mode"           delete
 14  "PRAGMA main.journal_mode = wal"     wal
 15  "PRAGMA journal_mode"                delete
 16  "PRAGMA main.journal_mode"           wal
} {
  do_test walmode-7.$tn { 
    db close
    sqlite3 db test.db
    execsql $sql
  } $result
}
db close

finish_test