/ Check-in [cf627752]
Login

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

Overview
Comment:Fix some test code problems in "permutations.test journaltest pager.test". (CVS 6109)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:cf627752c4537f709acae26a1e335731d55bddb2
User & Date: danielk1977 2009-01-05 17:15:00
Context
2009-01-05
17:19
Include fuzz3.test in all.test. Get fuzz3.test working again. (CVS 6110) check-in: 77dc19cf user: drh tags: trunk
17:15
Fix some test code problems in "permutations.test journaltest pager.test". (CVS 6109) check-in: cf627752 user: danielk1977 tags: trunk
2009-01-03
15:06
Add some tests with attached databases to savepoint.test. Also tests of creating and dropping tables in auto-vacuum mode inside of a savepoint. (CVS 6108) check-in: ca7f11d5 user: danielk1977 tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/test_journal.c.

15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
...
311
312
313
314
315
316
317
318
319
320
321










322
323
324
325
326
327
328
...
332
333
334
335
336
337
338




339
340
341
342
343
344
345
** bug in SQLite - writing data to a database file page when:
**
**   a) the original page data is not stored in a synced portion of the
**      journal file, and
**   b) the page was not a free-list leaf page when the transaction was
**      first opened.
**
** $Id: test_journal.c,v 1.3 2008/12/24 09:30:22 danielk1977 Exp $
*/
#if SQLITE_TEST          /* This file is used for testing only */

#include "sqlite3.h"
#include "sqliteInt.h"

/*
................................................................................
  while( rc==SQLITE_OK && iOff<iSize ){
    u32 nRec, nPage, nSector, nPagesize;
    u32 ii;
    rc = sqlite3OsRead(pReal, zBuf, 28, iOff);
    if( rc!=SQLITE_OK 
     || decodeJournalHdr(zBuf, &nRec, &nPage, &nSector, &nPagesize) 
    ){
      return rc;
    }
    iOff += nSector;
    if( nRec==0 ){










      nRec = (iSize - iOff)/(pMain->nPagesize + 8);
    }
    for(ii=0; rc==SQLITE_OK && ii<nRec && iOff<iSize; ii++){
      u32 pgno;
      rc = sqlite3OsRead(pReal, zBuf, 4, iOff);
      if( rc==SQLITE_OK ){
        pgno = decodeUint32(zBuf);
................................................................................
        }
      }
    }

    iOff = ((iOff + (nSector-1)) / nSector) * nSector;
  }





  return rc;
}

/*
** Sync an jt-file.
*/
static int jtSync(sqlite3_file *pFile, int flags){







|







 







|



>
>
>
>
>
>
>
>
>
>







 







>
>
>
>







15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
...
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
...
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
** bug in SQLite - writing data to a database file page when:
**
**   a) the original page data is not stored in a synced portion of the
**      journal file, and
**   b) the page was not a free-list leaf page when the transaction was
**      first opened.
**
** $Id: test_journal.c,v 1.4 2009/01/05 17:15:00 danielk1977 Exp $
*/
#if SQLITE_TEST          /* This file is used for testing only */

#include "sqlite3.h"
#include "sqliteInt.h"

/*
................................................................................
  while( rc==SQLITE_OK && iOff<iSize ){
    u32 nRec, nPage, nSector, nPagesize;
    u32 ii;
    rc = sqlite3OsRead(pReal, zBuf, 28, iOff);
    if( rc!=SQLITE_OK 
     || decodeJournalHdr(zBuf, &nRec, &nPage, &nSector, &nPagesize) 
    ){
      goto finish_rjf;
    }
    iOff += nSector;
    if( nRec==0 ){
      /* A trick. There might be another journal-header immediately 
      ** following this one. In this case, 0 records means 0 records, 
      ** not "read until the end of the file". See also ticket #2565.
      */
      if( iSize>=(nRec+nSector) ){
        rc = sqlite3OsRead(pReal, zBuf, 28, iOff);
        if( rc!=SQLITE_OK || 0==decodeJournalHdr(zBuf, 0, 0, 0, 0) ){
          continue;
        }
      }
      nRec = (iSize - iOff)/(pMain->nPagesize + 8);
    }
    for(ii=0; rc==SQLITE_OK && ii<nRec && iOff<iSize; ii++){
      u32 pgno;
      rc = sqlite3OsRead(pReal, zBuf, 4, iOff);
      if( rc==SQLITE_OK ){
        pgno = decodeUint32(zBuf);
................................................................................
        }
      }
    }

    iOff = ((iOff + (nSector-1)) / nSector) * nSector;
  }

finish_rjf:
  if( rc==SQLITE_IOERR_SHORT_READ ){
    rc = SQLITE_OK;
  }
  return rc;
}

/*
** Sync an jt-file.
*/
static int jtSync(sqlite3_file *pFile, int flags){

Changes to test/pager.test.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
210
211
212
213
214
215
216

217
218
219
220
221
222
223
...
455
456
457
458
459
460
461
462



463



464
465
466
467
468
469
470
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this script is page cache subsystem.
#
# $Id: pager.test,v 1.32 2008/10/17 18:51:53 danielk1977 Exp $


set testdir [file dirname $argv0]
source $testdir/tester.tcl

if {[info commands pager_open]!=""} {
db close
................................................................................
} {Page-One}
do_test pager-3.5 {
  for {set i 2} {$i<=20} {incr i} {
    set gx [page_get $::p1 $i]
    page_write $gx "Page-$i"
    page_unref $gx
  }

  pager_commit $::p1
  page_unref $::g(1)
} {}
for {set i 2} {$i<=20} {incr i} {
  do_test pager-3.6.[expr {$i-1}] [subst {
    set gx \[page_get $::p1 $i\]
    set v \[page_read \$gx\]
................................................................................
  }
} {}
}

# The following tests cover rolling back hot journal files. 
# They can't be run on windows because the windows version of 
# SQLite holds a mandatory exclusive lock on journal files it has open.
#



if {$tcl_platform(platform)!="windows"} {



do_test pager-6.1 {
  file delete -force test2.db
  file delete -force test2.db-journal
  sqlite3 db2 test2.db
  execsql {
    PRAGMA synchronous = 0;
    CREATE TABLE abc(a, b, c);







|







 







>







 







|
>
>
>
|
>
>
>







7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
...
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this script is page cache subsystem.
#
# $Id: pager.test,v 1.33 2009/01/05 17:15:00 danielk1977 Exp $


set testdir [file dirname $argv0]
source $testdir/tester.tcl

if {[info commands pager_open]!=""} {
db close
................................................................................
} {Page-One}
do_test pager-3.5 {
  for {set i 2} {$i<=20} {incr i} {
    set gx [page_get $::p1 $i]
    page_write $gx "Page-$i"
    page_unref $gx
  }
breakpoint
  pager_commit $::p1
  page_unref $::g(1)
} {}
for {set i 2} {$i<=20} {incr i} {
  do_test pager-3.6.[expr {$i-1}] [subst {
    set gx \[page_get $::p1 $i\]
    set v \[page_read \$gx\]
................................................................................
  }
} {}
}

# The following tests cover rolling back hot journal files. 
# They can't be run on windows because the windows version of 
# SQLite holds a mandatory exclusive lock on journal files it has open.
# 
# They cannot be run during the journaltest permutation because 
# "PRAGMA synchronous = 0" is used.
#
if {$tcl_platform(platform)!="windows" && (
      0 == [info exists ::permutations_test_prefix] 
   || $::permutations_test_prefix ne "journaltest"
)} {
do_test pager-6.1 {
  file delete -force test2.db
  file delete -force test2.db-journal
  sqlite3 db2 test2.db
  execsql {
    PRAGMA synchronous = 0;
    CREATE TABLE abc(a, b, c);