/ Check-in [990f621f]
Login

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

Overview
Comment:Updates to test scripts for better support of soft-heap-limit testing. (CVS 4209)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 990f621f2247f1636e895dcf51fea1e08f202d31
User & Date: drh 2007-08-12 20:07:59
Context
2007-08-13
11:10
Remove a memory allocation from sqlite3VdbeIOTraceSql(). This means that when doing I/O tracing, the text of an SQL statement is truncated to the first 1000 characters. But it also means tracing works in an out-of-memory situation. (CVS 4210) check-in: 578da247 user: drh tags: trunk
2007-08-12
20:07
Updates to test scripts for better support of soft-heap-limit testing. (CVS 4209) check-in: 990f621f user: drh tags: trunk
2007-08-11
00:26
Backout check-in (4206) and replace it with a much better and more general fix for the problem identified in ticket #2565. (CVS 4208) check-in: 7961a738 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to test/avtrans.test.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
..
83
84
85
86
87
88
89

90
91
92
93
94
95
96
...
157
158
159
160
161
162
163

164
165
166
167
168
169
170
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.  This
# file is a copy of "trans.test" modified to run under autovacuum mode.
# the point is to stress the autovacuum logic and try to get it to fail.
#
# $Id: avtrans.test,v 1.4 2006/02/11 01:25:51 drh Exp $


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


# Create several tables to work with.
................................................................................
    END;
  }
} {1 2 3 1 5 10}
integrity_check avtrans-2.11

# Check the locking behavior
#

do_test avtrans-3.1 {
  execsql {
    BEGIN;
    UPDATE one SET a = 0 WHERE 0;
    SELECT a FROM one ORDER BY a;
  }
} {1 2 3}
................................................................................
} {0 {1 4 5 10}}
do_test avtrans-3.14 {
  set v [catch {execsql {
    SELECT a FROM one ORDER BY a;
  } db} msg]
  lappend v $msg
} {0 {1 2 3 4}}

integrity_check avtrans-3.15

do_test avtrans-4.1 {
  set v [catch {execsql {
    COMMIT;
  } db} msg]
  lappend v $msg







|







 







>







 







>







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
..
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
...
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.  This
# file is a copy of "trans.test" modified to run under autovacuum mode.
# the point is to stress the autovacuum logic and try to get it to fail.
#
# $Id: avtrans.test,v 1.5 2007/08/12 20:07:59 drh Exp $


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


# Create several tables to work with.
................................................................................
    END;
  }
} {1 2 3 1 5 10}
integrity_check avtrans-2.11

# Check the locking behavior
#
sqlite3_soft_heap_limit 0
do_test avtrans-3.1 {
  execsql {
    BEGIN;
    UPDATE one SET a = 0 WHERE 0;
    SELECT a FROM one ORDER BY a;
  }
} {1 2 3}
................................................................................
} {0 {1 4 5 10}}
do_test avtrans-3.14 {
  set v [catch {execsql {
    SELECT a FROM one ORDER BY a;
  } db} msg]
  lappend v $msg
} {0 {1 2 3 4}}
sqlite3_soft_heap_limit $soft_limit
integrity_check avtrans-3.15

do_test avtrans-4.1 {
  set v [catch {execsql {
    COMMIT;
  } db} msg]
  lappend v $msg

Changes to test/cache.test.

5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

21
22
23
24
25
26
27
..
51
52
53
54
55
56
57

58
59
#
#    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: cache.test,v 1.2 2007/04/06 21:42:22 drh Exp $

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

ifcapable {!pager_pragmas} {
  finish_test
  return
}


proc pager_cache_size {db} {
  set bt [btree_from_db $db]
  array set stats [btree_pager_stats $bt]
  return $stats(page)
}

................................................................................

  do_test cache-1.3.$ii {
    execsql {SELECT * FROM abc}
    pager_cache_size db
  } $::cache_size

}


finish_test







|








>







 







>


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
..
52
53
54
55
56
57
58
59
60
61
#
#    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: cache.test,v 1.3 2007/08/12 20:07:59 drh Exp $

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

ifcapable {!pager_pragmas} {
  finish_test
  return
}
sqlite3_soft_heap_limit 0

proc pager_cache_size {db} {
  set bt [btree_from_db $db]
  array set stats [btree_pager_stats $bt]
  return $stats(page)
}

................................................................................

  do_test cache-1.3.$ii {
    execsql {SELECT * FROM abc}
    pager_cache_size db
  } $::cache_size

}
sqlite3_soft_heap_limit $soft_limit

finish_test

Changes to test/capi3.test.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
#    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 testing the callback-free C/C++ API.
#
# $Id: capi3.test,v 1.50 2007/06/21 15:25:05 drh Exp $
#

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

# Return the UTF-16 representation of the supplied UTF-8 string $str.
# If $nt is true, append two 0x00 bytes as a nul terminator.
................................................................................
#
# set STMT [sqlite3_prepare "SELECT 1, 2, 2;" -1 DUMMY]
# check_header test1.1 {1 2 3} {"" "" ""}
#
proc check_origin_header {STMT test dbs tables cols} {
  # If sqlite3_column_origin_name() and friends are not compiled into
  # this build, this proc is a no-op.
ifcapable columnmetadata {

    # Use the return value of sqlite3_column_count() to build
    # a list of column indexes. i.e. If sqlite3_column_count
    # is 3, build the list {0 1 2}.
    set ::idxlist [list]
    set ::numcols [sqlite3_column_count $STMT]
    for {set i 0} {$i < $::numcols} {incr i} {lappend ::idxlist $i}
  







|







 







|
<







7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
306
307
308
309
310
311
312
313

314
315
316
317
318
319
320
#    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 testing the callback-free C/C++ API.
#
# $Id: capi3.test,v 1.51 2007/08/12 20:07:59 drh Exp $
#

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

# Return the UTF-16 representation of the supplied UTF-8 string $str.
# If $nt is true, append two 0x00 bytes as a nul terminator.
................................................................................
#
# set STMT [sqlite3_prepare "SELECT 1, 2, 2;" -1 DUMMY]
# check_header test1.1 {1 2 3} {"" "" ""}
#
proc check_origin_header {STMT test dbs tables cols} {
  # If sqlite3_column_origin_name() and friends are not compiled into
  # this build, this proc is a no-op.
  ifcapable columnmetadata {

    # Use the return value of sqlite3_column_count() to build
    # a list of column indexes. i.e. If sqlite3_column_count
    # is 3, build the list {0 1 2}.
    set ::idxlist [list]
    set ::numcols [sqlite3_column_count $STMT]
    for {set i 0} {$i < $::numcols} {incr i} {lappend ::idxlist $i}
  

Changes to test/exclusive.test.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
193
194
195
196
197
198
199

200
201
202
203
204
205
206
...
214
215
216
217
218
219
220

221
222
223
224
225
226
227
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library. The focus
# of these tests is exclusive access mode (i.e. the thing activated by 
# "PRAGMA locking_mode = EXCLUSIVE").
#
# $Id: exclusive.test,v 1.5 2007/04/06 21:42:22 drh Exp $

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

ifcapable {!pager_pragmas} {
  finish_test
  return
................................................................................
  } db2
} {1 2 3 4 5 6}
do_test exclusive-2.5 {
  catchsql {
    INSERT INTO abc VALUES(7, 8, 9);
  } db2
} {1 {database is locked}}

do_test exclusive-2.6 {
  # Because connection 'db' only has a shared-lock, the other connection
  # will be able to get a RESERVED, but will fail to upgrade to EXCLUSIVE.
  execsql {
    BEGIN;
    INSERT INTO abc VALUES(7, 8, 9);
  } db2
................................................................................
  } db2
} {1 {database is locked}}
do_test exclusive-2.8 {
  execsql {
    ROLLBACK;
  } db2
} {}


do_test exclusive-2.9 {
  # Write the database to establish the exclusive lock with connection 'db.
  execsql {
    INSERT INTO abc VALUES(7, 8, 9);
  } db
  catchsql {







|







 







>







 







>







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
...
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library. The focus
# of these tests is exclusive access mode (i.e. the thing activated by 
# "PRAGMA locking_mode = EXCLUSIVE").
#
# $Id: exclusive.test,v 1.6 2007/08/12 20:07:59 drh Exp $

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

ifcapable {!pager_pragmas} {
  finish_test
  return
................................................................................
  } db2
} {1 2 3 4 5 6}
do_test exclusive-2.5 {
  catchsql {
    INSERT INTO abc VALUES(7, 8, 9);
  } db2
} {1 {database is locked}}
sqlite3_soft_heap_limit 0
do_test exclusive-2.6 {
  # Because connection 'db' only has a shared-lock, the other connection
  # will be able to get a RESERVED, but will fail to upgrade to EXCLUSIVE.
  execsql {
    BEGIN;
    INSERT INTO abc VALUES(7, 8, 9);
  } db2
................................................................................
  } db2
} {1 {database is locked}}
do_test exclusive-2.8 {
  execsql {
    ROLLBACK;
  } db2
} {}
sqlite3_soft_heap_limit $soft_limit

do_test exclusive-2.9 {
  # Write the database to establish the exclusive lock with connection 'db.
  execsql {
    INSERT INTO abc VALUES(7, 8, 9);
  } db
  catchsql {

Changes to test/exclusive2.test.

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





22
23
24
25
26
27
28
...
161
162
163
164
165
166
167
168

169
170
171
172
173
174
175
...
282
283
284
285
286
287
288

289
290
#    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 implements regression tests for SQLite library.
#
# $Id: exclusive2.test,v 1.7 2007/07/20 20:25:38 aswift Exp $

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

ifcapable {!pager_pragmas} {
  finish_test
  return
}






proc pagerChangeCounter {filename {new ""}} {
  set fd [open $filename RDWR]
  fconfigure $fd -translation binary -encoding binary
  if {$new ne ""} {
    seek $fd 24
    set a [expr {($new&0xFF000000)>>24}]
................................................................................
#        change-counter.
# 7-8    Set the locking-mode back to normal. After the db is unlocked,
#        SQLite detects the modified change-counter and discards the
#        in-memory cache. Then it finds the corruption caused in step 4....
#
# As above, this test is only applicable if the pager cache is
# large enough to hold the entire database. With 1024 byte pages,
# this means 19 pages.

#
do_test exclusive2-2.1 {
  execsql {PRAGMA locking_mode = exclusive;}
  execsql {
    BEGIN;
    DELETE FROM t1;
    INSERT INTO t1(a) VALUES(randstr(10, 400));
................................................................................
} {4}
do_test exclusive2-3.6 {
  execsql {
    INSERT INTO t1 VALUES(randstr(10, 400));
  }
  readPagerChangeCounter test.db
} {5}


finish_test







|








>
>
>
>
>







 







|
>







 







>


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
...
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
...
288
289
290
291
292
293
294
295
296
297
#    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 implements regression tests for SQLite library.
#
# $Id: exclusive2.test,v 1.8 2007/08/12 20:07:59 drh Exp $

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

ifcapable {!pager_pragmas} {
  finish_test
  return
}

# This module does not work right if the cache spills at unexpected
# moments.  So disable the soft-heap-limit.
#
sqlite3_soft_heap_limit 0

proc pagerChangeCounter {filename {new ""}} {
  set fd [open $filename RDWR]
  fconfigure $fd -translation binary -encoding binary
  if {$new ne ""} {
    seek $fd 24
    set a [expr {($new&0xFF000000)>>24}]
................................................................................
#        change-counter.
# 7-8    Set the locking-mode back to normal. After the db is unlocked,
#        SQLite detects the modified change-counter and discards the
#        in-memory cache. Then it finds the corruption caused in step 4....
#
# As above, this test is only applicable if the pager cache is
# large enough to hold the entire database. With 1024 byte pages,
# this means 19 pages.  We also need to disable the soft-heap-limit
# to prevent memory-induced cache spills.
#
do_test exclusive2-2.1 {
  execsql {PRAGMA locking_mode = exclusive;}
  execsql {
    BEGIN;
    DELETE FROM t1;
    INSERT INTO t1(a) VALUES(randstr(10, 400));
................................................................................
} {4}
do_test exclusive2-3.6 {
  execsql {
    INSERT INTO t1 VALUES(randstr(10, 400));
  }
  readPagerChangeCounter test.db
} {5}
sqlite3_soft_heap_limit $soft_limit

finish_test

Changes to test/incrblob.test.

5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
...
100
101
102
103
104
105
106


107
108
109
110
111
112
113
...
198
199
200
201
202
203
204

205
206
207
208
209
210
211
...
359
360
361
362
363
364
365

366
367
368
369
370
371
372
...
434
435
436
437
438
439
440

441
442
443
444
445
446
447
#
#    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: incrblob.test,v 1.12 2007/06/27 00:36:14 drh Exp $
#

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

ifcapable {!autovacuum || !pragma || !incrblob} {
  finish_test
................................................................................
  return $stats(read)
}
proc nWrite {db} {
  set bt [btree_from_db $db]
  array set stats [btree_pager_stats $bt]
  return $stats(write)
}



foreach AutoVacuumMode [list 0 1] {

  if {$AutoVacuumMode>0} {
    ifcapable !autovacuum {
      break
    }
................................................................................
    execsql { SELECT i FROM blobs } 
  } {45}

  do_test incrblob-2.$AutoVacuumMode.9 {
    nRead db
  } [expr $AutoVacuumMode ? 4 : 30]
}


#------------------------------------------------------------------------
# incrblob-3.*: 
#
# Test the outcome of trying to write to a read-only blob handle.
#
do_test incrblob-3.1 {
................................................................................
#     another connection has the database RESERVED lock.
#
#     Then test that blob writes that take place inside of a
#     transaction are not visible to external connections until
#     after the transaction is commited and the blob channel 
#     closed.
#

do_test incrblob-6.1 {
  sqlite3 db2 test.db
  execsql {
    BEGIN;
    INSERT INTO blobs(k, v, i) VALUES('a', 'different', 'connection');
  } db2
} {}
................................................................................
} {}
do_test incrblob-6.14 {
  execsql {
    SELECT * FROM blobs WHERE rowid = 4;
  }
} {a different invocation}
db2 close


#-----------------------------------------------------------------------
# The following tests verify the behaviour of the incremental IO
# APIs in the following cases:
#
#     7.1 A row that containing an open blob is modified.
#







|







 







>
>







 







>







 







>







 







>







5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
...
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
...
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
...
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
...
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
#
#    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: incrblob.test,v 1.13 2007/08/12 20:07:59 drh Exp $
#

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

ifcapable {!autovacuum || !pragma || !incrblob} {
  finish_test
................................................................................
  return $stats(read)
}
proc nWrite {db} {
  set bt [btree_from_db $db]
  array set stats [btree_pager_stats $bt]
  return $stats(write)
}

sqlite3_soft_heap_limit 0

foreach AutoVacuumMode [list 0 1] {

  if {$AutoVacuumMode>0} {
    ifcapable !autovacuum {
      break
    }
................................................................................
    execsql { SELECT i FROM blobs } 
  } {45}

  do_test incrblob-2.$AutoVacuumMode.9 {
    nRead db
  } [expr $AutoVacuumMode ? 4 : 30]
}
sqlite3_soft_heap_limit $soft_limit

#------------------------------------------------------------------------
# incrblob-3.*: 
#
# Test the outcome of trying to write to a read-only blob handle.
#
do_test incrblob-3.1 {
................................................................................
#     another connection has the database RESERVED lock.
#
#     Then test that blob writes that take place inside of a
#     transaction are not visible to external connections until
#     after the transaction is commited and the blob channel 
#     closed.
#
sqlite3_soft_heap_limit 0
do_test incrblob-6.1 {
  sqlite3 db2 test.db
  execsql {
    BEGIN;
    INSERT INTO blobs(k, v, i) VALUES('a', 'different', 'connection');
  } db2
} {}
................................................................................
} {}
do_test incrblob-6.14 {
  execsql {
    SELECT * FROM blobs WHERE rowid = 4;
  }
} {a different invocation}
db2 close
sqlite3_soft_heap_limit $soft_limit

#-----------------------------------------------------------------------
# The following tests verify the behaviour of the incremental IO
# APIs in the following cases:
#
#     7.1 A row that containing an open blob is modified.
#

Changes to test/lock2.test.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
..
97
98
99
100
101
102
103

104
105
106
107
108
109
110
...
159
160
161
162
163
164
165

166
167
#    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 database locks between competing processes.
#
# $Id: lock2.test,v 1.7 2007/04/09 11:20:54 danielk1977 Exp $


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

# Launch another testfixture process to be controlled by this one. A
# channel name is returned that may be passed as the first argument to proc
................................................................................
    sqlite3 db test.db -key xyzzy
    db eval {select * from sqlite_master}
  }
} {}
do_test lock2-1.1.1 {
  execsql {pragma lock_status}
} {main unlocked temp closed}

do_test lock2-1.2 {
  execsql {
    BEGIN;
    CREATE TABLE abc(a, b, c);
  }
} {}
do_test lock2-1.3 {
................................................................................
      SELECT * FROM sqlite_master;
    }
  }
} "table abc abc [expr $AUTOVACUUM?3:2] {CREATE TABLE abc(a, b, c)}"

catch {testfixture $::tf1 {db close}}
catch {close $::tf1}


finish_test







|







 







>







 







>


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
..
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
...
160
161
162
163
164
165
166
167
168
169
#    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 database locks between competing processes.
#
# $Id: lock2.test,v 1.8 2007/08/12 20:07:59 drh Exp $


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

# Launch another testfixture process to be controlled by this one. A
# channel name is returned that may be passed as the first argument to proc
................................................................................
    sqlite3 db test.db -key xyzzy
    db eval {select * from sqlite_master}
  }
} {}
do_test lock2-1.1.1 {
  execsql {pragma lock_status}
} {main unlocked temp closed}
sqlite3_soft_heap_limit 0
do_test lock2-1.2 {
  execsql {
    BEGIN;
    CREATE TABLE abc(a, b, c);
  }
} {}
do_test lock2-1.3 {
................................................................................
      SELECT * FROM sqlite_master;
    }
  }
} "table abc abc [expr $AUTOVACUUM?3:2] {CREATE TABLE abc(a, b, c)}"

catch {testfixture $::tf1 {db close}}
catch {close $::tf1}
sqlite3_soft_heap_limit $soft_limit

finish_test

Changes to test/malloc5.test.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
..
33
34
35
36
37
38
39

40
41
42
43
44
45
46
#    May you share freely, never taking more than you give.
#
#***********************************************************************
#
# This file contains test cases focused on the two memory-management APIs, 
# sqlite3_soft_heap_limit() and sqlite3_release_memory().
#
# $Id: malloc5.test,v 1.11 2007/08/10 16:41:09 drh Exp $

#---------------------------------------------------------------------------
# NOTES ON EXPECTED BEHAVIOUR
#
#---------------------------------------------------------------------------


................................................................................

# Skip these tests if OMIT_MEMORY_MANAGEMENT was defined at compile time.
ifcapable !memorymanage {
   finish_test
   return
}


sqlite3 db test.db

do_test malloc5-1.1 {
  # Simplest possible test. Call sqlite3_release_memory when there is exactly
  # one unused page in a single pager cache. This test case set's the 
  # value of the ::pgalloc variable, which is used in subsequent tests.
  #







|







 







>







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
..
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#    May you share freely, never taking more than you give.
#
#***********************************************************************
#
# This file contains test cases focused on the two memory-management APIs, 
# sqlite3_soft_heap_limit() and sqlite3_release_memory().
#
# $Id: malloc5.test,v 1.12 2007/08/12 20:07:59 drh Exp $

#---------------------------------------------------------------------------
# NOTES ON EXPECTED BEHAVIOUR
#
#---------------------------------------------------------------------------


................................................................................

# Skip these tests if OMIT_MEMORY_MANAGEMENT was defined at compile time.
ifcapable !memorymanage {
   finish_test
   return
}

sqlite3_soft_heap_limit 0
sqlite3 db test.db

do_test malloc5-1.1 {
  # Simplest possible test. Call sqlite3_release_memory when there is exactly
  # one unused page in a single pager cache. This test case set's the 
  # value of the ::pgalloc variable, which is used in subsequent tests.
  #

Changes to test/pageropt.test.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
..
47
48
49
50
51
52
53

54
55
56
57
58
59
60
...
191
192
193
194
195
196
197
198

199
200
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.
# The focus of the tests in this file are to verify that the
# pager optimizations implemented in version 3.3.14 work.
#
# $Id: pageropt.test,v 1.2 2007/04/13 03:23:21 drh Exp $

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

ifcapable {!pager_pragmas} {
  finish_test
  return
................................................................................
                $sqlite3_pager_pgfree_count]
  return [concat $cnt $r]
}

# Setup the test database
#
do_test pageropt-1.1 {

  execsql {
    PRAGMA auto_vacuum = OFF;
    PRAGMA page_size = 1024;
  }
  pagercount_sql {
    CREATE TABLE t1(x);
  }
................................................................................
  db close
  sqlite3 db test.db
  pagercount_sql {
    DELETE FROM t1
  }
} {12 3 3 0}



catch {db2 close}
finish_test







|







 







>







 







<
>


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
..
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
...
192
193
194
195
196
197
198

199
200
201
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.
# The focus of the tests in this file are to verify that the
# pager optimizations implemented in version 3.3.14 work.
#
# $Id: pageropt.test,v 1.3 2007/08/12 20:07:59 drh Exp $

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

ifcapable {!pager_pragmas} {
  finish_test
  return
................................................................................
                $sqlite3_pager_pgfree_count]
  return [concat $cnt $r]
}

# Setup the test database
#
do_test pageropt-1.1 {
  sqlite3_soft_heap_limit 0
  execsql {
    PRAGMA auto_vacuum = OFF;
    PRAGMA page_size = 1024;
  }
  pagercount_sql {
    CREATE TABLE t1(x);
  }
................................................................................
  db close
  sqlite3 db test.db
  pagercount_sql {
    DELETE FROM t1
  }
} {12 3 3 0}


sqlite3_soft_heap_limit $soft_limit
catch {db2 close}
finish_test

Changes to test/softheap1.test.

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28


29


30


31
32
33
34
35
36
#
#***********************************************************************
# 
# This test script reproduces the problem reported by ticket #2565,
# A database corruption bug that occurs in auto_vacuum mode when
# the soft_heap_limit is set low enough to be triggered.
#
# $Id: softheap1.test,v 1.1 2007/08/10 19:46:44 drh Exp $


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

sqlite3_soft_heap_limit 5000
do_test softheap1-1.1 {
  execsql {
    PRAGMA auto_vacuum=1;
    CREATE TABLE t1(x);
    INSERT INTO t1 VALUES(hex(randomblob(5000)));
    BEGIN;


    CREATE TABLE t2 AS SELECT * FROM t1;


    ROLLBACK;


    PRAGMA integrity_check;
  }
} {ok}
sqlite3_soft_heap_limit $soft_limit
   
finish_test







|










|

>
>

>
>

>
>






9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#
#***********************************************************************
# 
# This test script reproduces the problem reported by ticket #2565,
# A database corruption bug that occurs in auto_vacuum mode when
# the soft_heap_limit is set low enough to be triggered.
#
# $Id: softheap1.test,v 1.2 2007/08/12 20:07:59 drh Exp $


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

sqlite3_soft_heap_limit 5000
do_test softheap1-1.1 {
  execsql {
    PRAGMA auto_vacuum=1;
    CREATE TABLE t1(x);
    INSERT INTO t1 VALUES(hex(randomblob(1000)));
    BEGIN;
  }
  execsql {
    CREATE TABLE t2 AS SELECT * FROM t1;
  }
  execsql {
    ROLLBACK;
  }
  execsql {
    PRAGMA integrity_check;
  }
} {ok}
sqlite3_soft_heap_limit $soft_limit
   
finish_test