CoolFace
Modelpublic

AryaWu/sqlite

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
tkt2565.test93 linesDownload Raw Back to test
1# 2009 January 82#3# The author disclaims copyright to this source code.  In place of4# 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# This script attempts to reproduce the circumstances of ticket #2565.13#14# More specifically, this script attempts to generate rollback journals15# that contain headers with nRec==0 that are followed by additional16# valid headers.17#18# $Id: tkt2565.test,v 1.2 2009/04/09 01:23:49 drh Exp $19 20set testdir [file dirname $argv0]21source $testdir/tester.tcl22 23# Use the alternative pcache and rig it to call pagerStress()24# very frequently.25#26db close27sqlite3_shutdown28sqlite3_config_alt_pcache 1 100 0 129 30# Open two database connections to database "test.db".31#32proc reopen_database {} {33  catch {db close}34  sqlite3 db test.db35  db cache size 036  execsql {37    pragma page_size=512;38    pragma auto_vacuum=2;39    pragma cache_size=16;40  }41}42 43# Open two database connections and create a single table in the db.44#45do_test tkt2565-1.0 {46  reopen_database47  execsql { CREATE TABLE A(Id INTEGER, Name TEXT) }48} {}49 50for {set iFail 1} {$iFail<200} {incr iFail} {51  reopen_database52  execsql { pragma locking_mode=exclusive }53  set nRow [db one {SELECT count(*) FROM a}]54  55  # Dirty (at least) one of the pages in the cache.56  do_test tkt2565-1.$iFail.1 {57    execsql {58      BEGIN EXCLUSIVE;59      INSERT INTO a VALUES(1, 'ABCDEFGHIJKLMNOP');60    }61  } {}62  63  # Now try to commit the transaction. Cause an IO error to occur64  # within this operation, which moves the pager into the error state.65  #66  set ::sqlite_io_error_persist 167  set ::sqlite_io_error_pending $iFail68  do_test tkt2565-1.$iFail.2 {69    set rc [catchsql {COMMIT}]70    list71  } {}72  set ::sqlite_io_error_persist 073  set ::sqlite_io_error_pending 074  if {!$::sqlite_io_error_hit} break75  set ::sqlite_io_error_hit 076}77 78# Make sure this test script doesn't leave any files open.79#80do_test tkt2565-1.X {81  catch { db close }82  set sqlite_open_file_count83} 084 85# Restore the pcache configuration for subsequent tests.86#87sqlite3_shutdown88sqlite3_config_alt_pcache 089sqlite3_initialize90autoinstall_test_functions91 92finish_test93