/ Check-in [6237c294]
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:Changes to make sure tests work when SQLITE_DEFAULT_AUTOVACUUM is defined. (CVS 2219)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 6237c294d1211d5848bafb1310574e2486a43757
User & Date: danielk1977 2005-01-16 11:07:07
Context
2005-01-16
20:47
Drop support for MAC OS9. SQLite 3 has never worked for that OS because the developers do not have access to a machine running it and nobody from the community has stepped forward to provide a port. By moving the os_mac.c file into the attic, we make the lack of support official. (CVS 2220) check-in: de9ad673 user: drh tags: trunk
11:07
Changes to make sure tests work when SQLITE_DEFAULT_AUTOVACUUM is defined. (CVS 2219) check-in: 6237c294 user: danielk1977 tags: trunk
09:06
Fixes so that compiling and testing works when SQLITE_OMIT_AUTOVACUUM is defined. (CVS 2218) check-in: fe548561 user: danielk1977 tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/btree.c.

5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
....
3066
3067
3068
3069
3070
3071
3072



3073
3074
3075
3076
3077
3078
3079
....
3094
3095
3096
3097
3098
3099
3100



3101
3102
3103
3104
3105
3106
3107
....
4290
4291
4292
4293
4294
4295
4296

4297
4298
4299
4300
4301
4302
4303
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** $Id: btree.c,v 1.236 2005/01/16 09:06:34 danielk1977 Exp $
**
** This file implements a external (disk-based) database using BTrees.
** For a detailed discussion of BTrees, refer to
**
**     Donald E. Knuth, THE ART OF COMPUTER PROGRAMMING, Volume 3:
**     "Sorting And Searching", pages 473-480. Addison-Wesley
**     Publishing Company, Reading, Massachusetts.
................................................................................
            memcpy(&aData[8+closest*4], &aData[4+k*4], 4);
          }
          put4byte(&aData[4], k-1);
          rc = getPage(pBt, *pPgno, ppPage);
          if( rc==SQLITE_OK ){
            sqlite3pager_dont_rollback((*ppPage)->aData);
            rc = sqlite3pager_write((*ppPage)->aData);



          }
          searchList = 0;
        }
      }
      releasePage(pPrevTrunk);
    }while( searchList );
    releasePage(pTrunk);
................................................................................
    }
#endif

    assert( *pPgno!=PENDING_BYTE_PAGE(pBt) );
    rc = getPage(pBt, *pPgno, ppPage);
    if( rc ) return rc;
    rc = sqlite3pager_write((*ppPage)->aData);



    TRACE(("ALLOCATE: %d from end of file\n", *pPgno));
  }

  assert( *pPgno!=PENDING_BYTE_PAGE(pBt) );
  return rc;
}

................................................................................
      TRACE(("BALANCE: transfer child %d into root %d\n",
              pChild->pgno, pPage->pgno));
    }
    rc = reparentChildPages(pPage);
    assert( pPage->nOverflow==0 );
#ifndef SQLITE_OMIT_AUTOVACUUM
    if( pBt->autoVacuum ){

      for(i=0; i<pPage->nCell; i++){ 
        rc = ptrmapPutOvfl(pPage, i);
        if( rc!=SQLITE_OK ){
          goto end_shallow_balance;
        }
      }
    }







|







 







>
>
>







 







>
>
>







 







>







5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
....
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
....
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
....
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** $Id: btree.c,v 1.237 2005/01/16 11:07:07 danielk1977 Exp $
**
** This file implements a external (disk-based) database using BTrees.
** For a detailed discussion of BTrees, refer to
**
**     Donald E. Knuth, THE ART OF COMPUTER PROGRAMMING, Volume 3:
**     "Sorting And Searching", pages 473-480. Addison-Wesley
**     Publishing Company, Reading, Massachusetts.
................................................................................
            memcpy(&aData[8+closest*4], &aData[4+k*4], 4);
          }
          put4byte(&aData[4], k-1);
          rc = getPage(pBt, *pPgno, ppPage);
          if( rc==SQLITE_OK ){
            sqlite3pager_dont_rollback((*ppPage)->aData);
            rc = sqlite3pager_write((*ppPage)->aData);
            if( rc!=SQLITE_OK ){
              releasePage(*ppPage);
            }
          }
          searchList = 0;
        }
      }
      releasePage(pPrevTrunk);
    }while( searchList );
    releasePage(pTrunk);
................................................................................
    }
#endif

    assert( *pPgno!=PENDING_BYTE_PAGE(pBt) );
    rc = getPage(pBt, *pPgno, ppPage);
    if( rc ) return rc;
    rc = sqlite3pager_write((*ppPage)->aData);
    if( rc!=SQLITE_OK ){
      releasePage(*ppPage);
    }
    TRACE(("ALLOCATE: %d from end of file\n", *pPgno));
  }

  assert( *pPgno!=PENDING_BYTE_PAGE(pBt) );
  return rc;
}

................................................................................
      TRACE(("BALANCE: transfer child %d into root %d\n",
              pChild->pgno, pPage->pgno));
    }
    rc = reparentChildPages(pPage);
    assert( pPage->nOverflow==0 );
#ifndef SQLITE_OMIT_AUTOVACUUM
    if( pBt->autoVacuum ){
      int i;
      for(i=0; i<pPage->nCell; i++){ 
        rc = ptrmapPutOvfl(pPage, i);
        if( rc!=SQLITE_OK ){
          goto end_shallow_balance;
        }
      }
    }

Changes to test/all.test.

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
..
57
58
59
60
61
62
63



64
65
66

67
68
69
70
71
72
73
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file runs all tests.
#
# $Id: all.test,v 1.27 2005/01/13 11:07:54 danielk1977 Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl
rename finish_test really_finish_test
proc finish_test {} {memleak_check}

if {[file exists ./sqlite_test_count]} {
................................................................................
  memleak.test
}

# Test files btree2.test and btree4.test don't work if the 
# SQLITE_DEFAULT_AUTOVACUUM macro is defined to true (because they depend
# on tables being allocated starting at page 2).
#



ifcapable default_autovacuum {
  lappend EXCLUDE btree2.test
  lappend EXCLUDE btree4.test

}

for {set Counter 0} {$Counter<$COUNT && $nErr==0} {incr Counter} {
  if {$Counter%2} {
    set ::SETUP_SQL {PRAGMA default_synchronous=off;}
  } else {
    catch {unset ::SETUP_SQL}







|







 







>
>
>



>







6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
..
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file runs all tests.
#
# $Id: all.test,v 1.28 2005/01/16 11:07:07 danielk1977 Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl
rename finish_test really_finish_test
proc finish_test {} {memleak_check}

if {[file exists ./sqlite_test_count]} {
................................................................................
  memleak.test
}

# Test files btree2.test and btree4.test don't work if the 
# SQLITE_DEFAULT_AUTOVACUUM macro is defined to true (because they depend
# on tables being allocated starting at page 2).
#
# Also corrupt.test doesn't work, because currently SQLite can't detect
# corruption in pointer-map pages.
#
ifcapable default_autovacuum {
  lappend EXCLUDE btree2.test
  lappend EXCLUDE btree4.test
  lappend EXCLUDE corrupt.test
}

for {set Counter 0} {$Counter<$COUNT && $nErr==0} {incr Counter} {
  if {$Counter%2} {
    set ::SETUP_SQL {PRAGMA default_synchronous=off;}
  } else {
    catch {unset ::SETUP_SQL}

Changes to test/ioerr.test.

11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
...
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
...
213
214
215
216
217
218
219
220
221




222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
...
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
# This file implements regression tests for SQLite library.  The
# focus of this file is testing for correct handling of I/O errors
# such as writes failing because the disk is full.
# 
# The tests in this file use special facilities that are only
# available in the SQLite test fixture.
#
# $Id: ioerr.test,v 1.14 2005/01/16 09:06:34 danielk1977 Exp $

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

# Usage: do_ioerr_test <test number> <options...>
#
# The first argument, <test number>, is an integer used to name the
................................................................................
} -sqlbody {
  CREATE TABLE abc2(a);
  BEGIN;
  DELETE FROM abc WHERE length(a)>100;
  UPDATE abc SET a = randstr(90,90);
  COMMIT;
  CREATE TABLE abc3(a);
}

# Test IO errors that can occur retrieving a record header that flows over
# onto an overflow page.
do_ioerr_test 4 -tclprep {
  set sql "CREATE TABLE abc(a1"
  for {set i 2} {$i<1300} {incr i} {
    append sql ", a$i"
................................................................................
  execsql {INSERT INTO abc (a1) VALUES(NULL)}
} -sqlbody {
 SELECT * FROM abc;
}

# Test IO errors that may occur during a multi-file commit.
#
# Test 8 is excluded when auto-vacuum is enabled for the same reason
# as in test cases ioerr-1.XXX




do_ioerr_test 5 -sqlprep {
  ATTACH 'test2.db' AS test2;
} -sqlbody {
  BEGIN;
  CREATE TABLE t1(a,b,c);
  CREATE TABLE test2.t2(a,b,c);
  COMMIT;
} -exclude [expr [string match [execsql {pragma auto_vacuum}] 1] ? 8 : 0]

# Test IO errors when replaying two hot journals from a 2-file 
# transaction. This test only runs on UNIX.
if {$tcl_platform(platform)=="unix" && [file exists ./crashtest]} {
  do_ioerr_test 6 -tclprep {
    set rc [crashsql 2 test2.db-journal {
      ATTACH 'test2.db' as aux;
................................................................................
    SELECT * FROM t1;
    SELECT * FROM t2;
  }
}

# Test handling of IO errors that occur while rolling back hot journal
# files.
do_ioerr_test 14 -tclprep {
  db close
  sqlite3 db2 test2.db
  db2 eval {
    PRAGMA synchronous = 0;
    CREATE TABLE t1(a, b);
    INSERT INTO t1 VALUES(1, 2);
    BEGIN;







|







 







|







 







|
|
>
>
>
>







|







 







|







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
...
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
...
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
...
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
# This file implements regression tests for SQLite library.  The
# focus of this file is testing for correct handling of I/O errors
# such as writes failing because the disk is full.
# 
# The tests in this file use special facilities that are only
# available in the SQLite test fixture.
#
# $Id: ioerr.test,v 1.15 2005/01/16 11:07:07 danielk1977 Exp $

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

# Usage: do_ioerr_test <test number> <options...>
#
# The first argument, <test number>, is an integer used to name the
................................................................................
} -sqlbody {
  CREATE TABLE abc2(a);
  BEGIN;
  DELETE FROM abc WHERE length(a)>100;
  UPDATE abc SET a = randstr(90,90);
  COMMIT;
  CREATE TABLE abc3(a);
} 

# Test IO errors that can occur retrieving a record header that flows over
# onto an overflow page.
do_ioerr_test 4 -tclprep {
  set sql "CREATE TABLE abc(a1"
  for {set i 2} {$i<1300} {incr i} {
    append sql ", a$i"
................................................................................
  execsql {INSERT INTO abc (a1) VALUES(NULL)}
} -sqlbody {
 SELECT * FROM abc;
}

# Test IO errors that may occur during a multi-file commit.
#
# Tests 8 and 17 are excluded when auto-vacuum is enabled for the same 
# reason as in test cases ioerr-1.XXX
set ex ""
if {[string match [execsql {pragma auto_vacuum}] 1]} {
  set ex [list 8 17]
}
do_ioerr_test 5 -sqlprep {
  ATTACH 'test2.db' AS test2;
} -sqlbody {
  BEGIN;
  CREATE TABLE t1(a,b,c);
  CREATE TABLE test2.t2(a,b,c);
  COMMIT;
} -exclude $ex

# Test IO errors when replaying two hot journals from a 2-file 
# transaction. This test only runs on UNIX.
if {$tcl_platform(platform)=="unix" && [file exists ./crashtest]} {
  do_ioerr_test 6 -tclprep {
    set rc [crashsql 2 test2.db-journal {
      ATTACH 'test2.db' as aux;
................................................................................
    SELECT * FROM t1;
    SELECT * FROM t2;
  }
}

# Test handling of IO errors that occur while rolling back hot journal
# files.
do_ioerr_test 7 -tclprep {
  db close
  sqlite3 db2 test2.db
  db2 eval {
    PRAGMA synchronous = 0;
    CREATE TABLE t1(a, b);
    INSERT INTO t1 VALUES(1, 2);
    BEGIN;