SQLite

Check-in [f2326dad4e]
Login

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

Overview
Comment:Add an extra test case for crash recovery.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: f2326dad4e47b2657be302e194970967960eb1c0
User & Date: dan 2010-03-22 17:38:11.000
References
2010-03-26
17:37
After any rollback that modifies the database file, sync the database before deleting the rollback journal. This is a cherry-pick merge of check-ins [b21b911f23] and [f2326dad4e] (check-in: ca0bc2a22e user: drh tags: branch-3.6.23)
Context
2010-03-23
15:29
Close the auxiliary database db2 at the end of the crash8.test script. (check-in: 0fbdc431e8 user: drh tags: trunk)
2010-03-22
17:38
Add an extra test case for crash recovery. (check-in: f2326dad4e user: dan tags: trunk)
17:13
After a rollback that writes or truncates the database file, sync the database file before invalidating the journal contents. Fix for [015d3820f2]. (check-in: b21b911f23 user: dan tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to test/crash8.test.
336
337
338
339
340
341
342

343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367































368
369

  do_test crash8-4.10 {
    file delete $zMasterJournal
    execsql { SELECT b FROM main.ab WHERE a = 0 }
  } {jkl}
}


catch { db close }
file delete -force test.db test.db-journal
sqlite3 db test.db

do_test crash8-5.1 {
  execsql {
    CREATE TABLE t1(x PRIMARY KEY);
    INSERT INTO t1 VALUES(randomblob(900));
    INSERT INTO t1 SELECT randomblob(900) FROM t1;
    INSERT INTO t1 SELECT randomblob(900) FROM t1;
    INSERT INTO t1 SELECT randomblob(900) FROM t1;
    INSERT INTO t1 SELECT randomblob(900) FROM t1;
    INSERT INTO t1 SELECT randomblob(900) FROM t1;
    INSERT INTO t1 SELECT randomblob(900) FROM t1;          /* 64 */
  }
  crashsql -file test.db -delay 1 {
    PRAGMA cache_size = 10;
    BEGIN;
      UPDATE t1 SET x = randomblob(900);
    ROLLBACK;
    INSERT INTO t1 VALUES(randomblob(900));
  }
  execsql { PRAGMA integrity_check }
} {ok}

































finish_test







>
|
|
|
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


336
337
338
339
340
341
342
343
344
345
346

347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400

  do_test crash8-4.10 {
    file delete $zMasterJournal
    execsql { SELECT b FROM main.ab WHERE a = 0 }
  } {jkl}
}

for {set i 1} {$i < 10} {incr i} {
  catch { db close }
  file delete -force test.db test.db-journal
  sqlite3 db test.db

  do_test crash8-5.$i.1 {
    execsql {
      CREATE TABLE t1(x PRIMARY KEY);
      INSERT INTO t1 VALUES(randomblob(900));
      INSERT INTO t1 SELECT randomblob(900) FROM t1;
      INSERT INTO t1 SELECT randomblob(900) FROM t1;
      INSERT INTO t1 SELECT randomblob(900) FROM t1;
      INSERT INTO t1 SELECT randomblob(900) FROM t1;
      INSERT INTO t1 SELECT randomblob(900) FROM t1;
      INSERT INTO t1 SELECT randomblob(900) FROM t1;          /* 64 rows */
    }
    crashsql -file test.db -delay [expr ($::i%2) + 1] {
      PRAGMA cache_size = 10;
      BEGIN;
        UPDATE t1 SET x = randomblob(900);
      ROLLBACK;
      INSERT INTO t1 VALUES(randomblob(900));
    }
    execsql { PRAGMA integrity_check }
  } {ok}
  
  catch { db close }
  file delete -force test.db test.db-journal
  sqlite3 db test.db
  do_test crash8-5.$i.2 {
    execsql {
      PRAGMA cache_size = 10;
      CREATE TABLE t1(x PRIMARY KEY);
      INSERT INTO t1 VALUES(randomblob(900));
      INSERT INTO t1 SELECT randomblob(900) FROM t1;
      INSERT INTO t1 SELECT randomblob(900) FROM t1;
      INSERT INTO t1 SELECT randomblob(900) FROM t1;
      INSERT INTO t1 SELECT randomblob(900) FROM t1;
      INSERT INTO t1 SELECT randomblob(900) FROM t1;
      INSERT INTO t1 SELECT randomblob(900) FROM t1;          /* 64 rows */
      BEGIN;
        UPDATE t1 SET x = randomblob(900);
    }
    file delete -force testX.db testX.db-journal
    copy_file test.db testX.db
    copy_file test.db-journal testX.db-journal
    db close

    crashsql -file test.db -delay [expr ($::i%2) + 1] {
      SELECT * FROM sqlite_master;
      INSERT INTO t1 VALUES(randomblob(900));
    }

    sqlite3 db2 testX.db
    execsql { PRAGMA integrity_check } db2
  } {ok}
}

finish_test