/ Check-in [0c41f7cf]
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:Enhance sqlite3_shutdown() so that it automatically invokes sqlite3_reset_auto_extension(). This is a harmless no-op if applications are already calling sqlite3_reset_auto_extension() prior to sqlite3_shutdown(). And it prevents possible memory corruption if they do not. So it works either way. Most of the changes are to the test cases. (CVS 6475)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 0c41f7cff4f6ffb9321f6f6b6ef3e431b750d41a
User & Date: drh 2009-04-09 01:23:49
Context
2009-04-09
14:02
Remove misuse detection from the deprecated sqlite3_transfer_bindings() interface. The code was hard to test and was simply taking up space. (CVS 6476) check-in: 4cd82910 user: drh tags: trunk
01:23
Enhance sqlite3_shutdown() so that it automatically invokes sqlite3_reset_auto_extension(). This is a harmless no-op if applications are already calling sqlite3_reset_auto_extension() prior to sqlite3_shutdown(). And it prevents possible memory corruption if they do not. So it works either way. Most of the changes are to the test cases. (CVS 6475) check-in: 0c41f7cf user: drh tags: trunk
2009-04-08
23:05
Simplify the implementation of the columnName() function in vdbeapi.c. This is a code cleanup only - no behavior changes. (CVS 6474) check-in: 0628f586 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/main.c.

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
...
215
216
217
218
219
220
221

222
223
224
225
226
227
228
**
*************************************************************************
** Main file for the SQLite library.  The routines in this file
** implement the programmer interface to the library.  Routines in
** other files are for internal use by SQLite and should not be
** accessed by users of the library.
**
** $Id: main.c,v 1.535 2009/04/02 17:22:42 drh Exp $
*/
#include "sqliteInt.h"

#ifdef SQLITE_ENABLE_FTS3
# include "fts3.h"
#endif
#ifdef SQLITE_ENABLE_RTREE
................................................................................
*/
int sqlite3_shutdown(void){
  sqlite3GlobalConfig.isMallocInit = 0;
  sqlite3PcacheShutdown();
  if( sqlite3GlobalConfig.isInit ){
    sqlite3_os_end();
  }

  sqlite3MallocEnd();
  sqlite3MutexEnd();
  sqlite3GlobalConfig.isInit = 0;
  return SQLITE_OK;
}

/*







|







 







>







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
...
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
**
*************************************************************************
** Main file for the SQLite library.  The routines in this file
** implement the programmer interface to the library.  Routines in
** other files are for internal use by SQLite and should not be
** accessed by users of the library.
**
** $Id: main.c,v 1.536 2009/04/09 01:23:49 drh Exp $
*/
#include "sqliteInt.h"

#ifdef SQLITE_ENABLE_FTS3
# include "fts3.h"
#endif
#ifdef SQLITE_ENABLE_RTREE
................................................................................
*/
int sqlite3_shutdown(void){
  sqlite3GlobalConfig.isMallocInit = 0;
  sqlite3PcacheShutdown();
  if( sqlite3GlobalConfig.isInit ){
    sqlite3_os_end();
  }
  sqlite3_reset_auto_extension();
  sqlite3MallocEnd();
  sqlite3MutexEnd();
  sqlite3GlobalConfig.isInit = 0;
  return SQLITE_OK;
}

/*

Changes to test/lookaside.test.

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
34
35
...
100
101
102
103
104
105
106

107
108
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
#
# Tests for the lookaside memory allocator.
#
# $Id: lookaside.test,v 1.9 2009/03/24 15:08:10 drh Exp $

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

ifcapable !lookaside {
  finish_test
  return
................................................................................
}

catch {db close}
sqlite3_shutdown
sqlite3_config_pagecache 0 0
sqlite3_config_scratch 0 0
sqlite3_initialize

sqlite3 db test.db

# Make sure sqlite3_db_config() and sqlite3_db_status are working.
#
do_test lookaside-1.1 {
  catch {sqlite3_config_error db}
} {0}
................................................................................
#
do_test lookaside-4.1 {
  db close
  sqlite3_shutdown
  catch sqlite3_config_error
} {0}
sqlite3_initialize


finish_test







|







 







>







 







>


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
34
35
36
...
101
102
103
104
105
106
107
108
109
110
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
#
# Tests for the lookaside memory allocator.
#
# $Id: lookaside.test,v 1.10 2009/04/09 01:23:49 drh Exp $

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

ifcapable !lookaside {
  finish_test
  return
................................................................................
}

catch {db close}
sqlite3_shutdown
sqlite3_config_pagecache 0 0
sqlite3_config_scratch 0 0
sqlite3_initialize
autoinstall_test_functions
sqlite3 db test.db

# Make sure sqlite3_db_config() and sqlite3_db_status are working.
#
do_test lookaside-1.1 {
  catch {sqlite3_config_error db}
} {0}
................................................................................
#
do_test lookaside-4.1 {
  db close
  sqlite3_shutdown
  catch sqlite3_config_error
} {0}
sqlite3_initialize
autoinstall_test_functions

finish_test

Changes to test/malloc.test.

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
...
190
191
192
193
194
195
196

197
198
199
200
201
202
203
...
655
656
657
658
659
660
661

662
663
664
665
666
667
668
# This file attempts to check the behavior of the SQLite library in 
# an out-of-memory situation. When compiled with -DSQLITE_DEBUG=1, 
# the SQLite library accepts a special command (sqlite3_memdebug_fail N C)
# which causes the N-th malloc to fail.  This special feature is used
# to see what happens in the library if a malloc were to really fail
# due to an out-of-memory situation.
#
# $Id: malloc.test,v 1.77 2009/03/19 18:51:07 danielk1977 Exp $

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


# Only run these tests if memory debugging is turned on.
#
................................................................................
    DELETE FROM t1 where rowid%5 = 0;
    COMMIT;
  } -sqlbody {
    VACUUM;
  } 
}


do_malloc_test 7 -sqlprep {
  CREATE TABLE t1(a, b);
  INSERT INTO t1 VALUES(1, 2);
  INSERT INTO t1 VALUES(3, 4);
  INSERT INTO t1 VALUES(5, 6);
  INSERT INTO t1 VALUES(7, randstr(1200,1200));
} -sqlbody {
................................................................................
  sqlite3_shutdown
} -tclbody {
  set rc [sqlite3_initialize]
  if {$rc == "SQLITE_NOMEM"} {
    error "out of memory"
  }
}


# Test that malloc failures that occur while processing INDEXED BY
# clauses are handled correctly.
do_malloc_test 28 -sqlprep {
  CREATE TABLE t1(a, b);
  CREATE INDEX i1 ON t1(a);
  CREATE VIEW v1 AS SELECT * FROM t1 INDEXED BY i1 WHERE a = 10;







|







 







>







 







>







12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
...
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
...
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
# This file attempts to check the behavior of the SQLite library in 
# an out-of-memory situation. When compiled with -DSQLITE_DEBUG=1, 
# the SQLite library accepts a special command (sqlite3_memdebug_fail N C)
# which causes the N-th malloc to fail.  This special feature is used
# to see what happens in the library if a malloc were to really fail
# due to an out-of-memory situation.
#
# $Id: malloc.test,v 1.78 2009/04/09 01:23:49 drh Exp $

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


# Only run these tests if memory debugging is turned on.
#
................................................................................
    DELETE FROM t1 where rowid%5 = 0;
    COMMIT;
  } -sqlbody {
    VACUUM;
  } 
}

autoinstall_test_functions
do_malloc_test 7 -sqlprep {
  CREATE TABLE t1(a, b);
  INSERT INTO t1 VALUES(1, 2);
  INSERT INTO t1 VALUES(3, 4);
  INSERT INTO t1 VALUES(5, 6);
  INSERT INTO t1 VALUES(7, randstr(1200,1200));
} -sqlbody {
................................................................................
  sqlite3_shutdown
} -tclbody {
  set rc [sqlite3_initialize]
  if {$rc == "SQLITE_NOMEM"} {
    error "out of memory"
  }
}
autoinstall_test_functions

# Test that malloc failures that occur while processing INDEXED BY
# clauses are handled correctly.
do_malloc_test 28 -sqlprep {
  CREATE TABLE t1(a, b);
  CREATE INDEX i1 ON t1(a);
  CREATE VIEW v1 AS SELECT * FROM t1 INDEXED BY i1 WHERE a = 10;

Changes to test/permutations.test.

5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
...
175
176
177
178
179
180
181

182
183
184
185
186
187

188
189
190
191
192
193
194
...
201
202
203
204
205
206
207

208
209
210
211
212
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
241
242
243
244
245
246
247


248
249
250
251
252
253
254
...
270
271
272
273
274
275
276


277
278
279
280
281
282
283
284


285
286
287
288
289
290
291
...
476
477
478
479
480
481
482
483
484
485
486
487
488

489
490
491
492
493
494
495
...
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518

519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541

542
543
544
545
546
547
548
549
550
551
552
553


554
555
556
557


558
559
560
561
562
563
564
...
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630

631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647

648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664

665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681

682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698

699
700
701
702
703
704
705
#
#    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: permutations.test,v 1.46 2009/04/01 23:09:44 drh Exp $

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

# Argument processing.
#
#puts "PERM-DEBUG: argv=$argv"
................................................................................
  malloc5.test
} -initialize {
  catch {db close}
  sqlite3_shutdown
  sqlite3_config_pagecache 4096 24
  sqlite3_config_scratch 25000 1
  sqlite3_initialize

} -shutdown {
  catch {db close}
  sqlite3_shutdown
  sqlite3_config_pagecache 0 0
  sqlite3_config_scratch 0 0
  sqlite3_initialize

}

# Run some tests using pre-allocated page and scratch blocks. This time
# the allocations are too small to use in most cases.
#
# Both ioerr5.test and malloc5.test are excluded because they test the
# sqlite3_soft_heap_limit() and sqlite3_release_memory() functionality.
................................................................................
  malloc5.test
} -initialize {
  catch {db close}
  sqlite3_shutdown
  sqlite3_config_pagecache 512 5
  sqlite3_config_scratch 1000 1
  sqlite3_initialize

} -shutdown {
  catch {db close}
  sqlite3_shutdown
  sqlite3_config_pagecache 0 0
  sqlite3_config_scratch 0 0
  sqlite3_initialize

}

# Run all tests with the lookaside allocator disabled.
#
run_tests "nolookaside" -description {
  OOM tests with lookaside disabled
} -initialize {
  catch {db close}
  sqlite3_shutdown
  sqlite3_config_lookaside 0 0
  sqlite3_initialize

} -shutdown {
  catch {db close}
  sqlite3_shutdown
  sqlite3_config_lookaside 100 500
  sqlite3_initialize

}

# Run some tests in SQLITE_CONFIG_SINGLETHREAD mode.
#
run_tests "singlethread" -description {
  Tests run in SQLITE_CONFIG_SINGLETHREAD mode
} -initialize {
  catch {db close}
  sqlite3_shutdown
  catch {sqlite3_config singlethread}


} -include {
  delete.test   delete2.test  insert.test  rollback.test  select1.test
  select2.test  trans.test    update.test  vacuum.test    types.test
  types2.test   types3.test
} -shutdown {
  catch {db close}
  sqlite3_shutdown
  catch {sqlite3_config serialized}


}

run_tests "nomutex" -description {
  Tests run with the SQLITE_OPEN_MULTITHREADED flag passed to sqlite3_open().
} -initialize {
  rename sqlite3 sqlite3_nomutex
  proc sqlite3 {args} {
................................................................................
#
run_tests "multithread" -description {
  Tests run in SQLITE_CONFIG_MULTITHREAD mode
} -initialize {
  catch {db close}
  sqlite3_shutdown
  catch {sqlite3_config multithread}


} -include {
  delete.test   delete2.test  insert.test  rollback.test  select1.test
  select2.test  trans.test    update.test  vacuum.test    types.test
  types2.test   types3.test
} -shutdown {
  catch {db close}
  sqlite3_shutdown
  catch {sqlite3_config serialized}


}

# Run some tests in SQLITE_OPEN_FULLMUTEX mode.
#
run_tests "fullmutex" -description {
  Tests run in SQLITE_OPEN_FULLMUTEX mode
} -initialize {
................................................................................
    sqlite3_config_heap 25000000 0
    sqlite3_config_lookaside 0 0
    install_malloc_faultsim 1 
    sqlite3_initialize
    autoinstall_test_functions
  } -shutdown {
    catch {db close}
    sqlite3_reset_auto_extension
    sqlite3_shutdown
    sqlite3_config_heap 0 0
    sqlite3_config_lookaside 100 500
    install_malloc_faultsim 1 
    sqlite3_initialize

  }
}

ifcapable mem5 {
  run_tests "memsys5" -description {
    Run tests using the allocator in mem5.c.
  } -exclude {
................................................................................
    bigrow.test               incrblob2.test            memdb.test
    bitvec.test               index2.test               memsubsys1.test
    capi3c.test               ioerr.test                memsubsys2.test
    capi3.test                join3.test                pagesize.test
    collate5.test             limit.test                zeroblob.test
  } -initialize {
    catch {db close}
    sqlite3_reset_auto_extension
    sqlite3_shutdown
    sqlite3_config_heap 25000000 64
    sqlite3_config_lookaside 0 0
    install_malloc_faultsim 1 
    sqlite3_initialize
    autoinstall_test_functions
  } -shutdown {
    catch {db close}
    sqlite3_reset_auto_extension
    sqlite3_shutdown
    sqlite3_config_heap 0 0
    sqlite3_config_lookaside 100 500
    install_malloc_faultsim 1 
    sqlite3_initialize

  }

  run_tests "memsys5-2" -description {
    Run tests using the allocator in mem5.c in a different configuration.
  } -include {
    select1.test 
  } -initialize {
    catch {db close}
    sqlite3_reset_auto_extension
    sqlite3_shutdown
    sqlite3_config_heap 40000000 16
    sqlite3_config_lookaside 0 0
    install_malloc_faultsim 1 
    sqlite3_initialize
    autoinstall_test_functions
  } -shutdown {
    catch {db close}
    sqlite3_reset_auto_extension
    sqlite3_shutdown
    sqlite3_config_heap 0 0
    sqlite3_config_lookaside 100 500
    install_malloc_faultsim 1 
    sqlite3_initialize

  }
}

ifcapable threadsafe {
  run_tests "no_mutex_try" -description {
     The sqlite3_mutex_try() interface always fails
  } -exclude [concat $EXCLUDE mutex1.test mutex2.test] \
  -initialize {
    catch {db close}
    sqlite3_shutdown
    install_mutex_counters 1
    set ::disable_mutex_try 1


  } -shutdown {
    catch {db close}
    sqlite3_shutdown
    install_mutex_counters 0


  }
}

# run_tests "crash_safe_append" -description {
#   Run crash.test with persistent journals on a SAFE_APPEND file-system.
# } -initialize {
#   rename crashsql sa_crashsql
................................................................................
  update.test
}

run_tests "pcache0" -description {
  Alternative pcache implementation without random discard
} -initialize {
  catch {db close}
  sqlite3_reset_auto_extension
  sqlite3_shutdown
  sqlite3_config_alt_pcache 1 0 1
  sqlite3_initialize
  autoinstall_test_functions
} -shutdown {
  catch {db close}
  sqlite3_reset_auto_extension
  sqlite3_shutdown
  sqlite3_config_alt_pcache 0 0 0
  sqlite3_config_lookaside 100 500
  install_malloc_faultsim 1 
  sqlite3_initialize

} -include ${perm-alt-pcache-testset}

run_tests "pcache10" -description {
  Alternative pcache implementation without 10% random discard
} -initialize {
  catch {db close}
  sqlite3_reset_auto_extension
  sqlite3_shutdown
  sqlite3_config_alt_pcache 1 50 1
  sqlite3_initialize
  autoinstall_test_functions
} -shutdown {
  catch {db close}
  sqlite3_reset_auto_extension
  sqlite3_shutdown
  sqlite3_config_alt_pcache 0 0 0
  sqlite3_initialize

} -include ${perm-alt-pcache-testset}

run_tests "pcache50" -description {
  Alternative pcache implementation without 50% random discard
} -initialize {
  catch {db close}
  sqlite3_reset_auto_extension
  sqlite3_shutdown
  sqlite3_config_alt_pcache 1 50 1
  sqlite3_initialize
  autoinstall_test_functions
} -shutdown {
  catch {db close}
  sqlite3_reset_auto_extension
  sqlite3_shutdown
  sqlite3_config_alt_pcache 0 0 0
  sqlite3_initialize

} -include ${perm-alt-pcache-testset}

run_tests "pcache90" -description {
  Alternative pcache implementation without 90% random discard
} -initialize {
  catch {db close}
  sqlite3_reset_auto_extension
  sqlite3_shutdown
  sqlite3_config_alt_pcache 1 50 1
  sqlite3_initialize
  autoinstall_test_functions
} -shutdown {
  catch {db close}
  sqlite3_reset_auto_extension
  sqlite3_shutdown
  sqlite3_config_alt_pcache 0 0 0
  sqlite3_initialize

} -include ${perm-alt-pcache-testset}

run_tests "pcache100" -description {
  Alternative pcache implementation that always discards when unpinning
} -initialize {
  catch {db close}
  sqlite3_reset_auto_extension
  sqlite3_shutdown
  sqlite3_config_alt_pcache 1 100 1
  sqlite3_initialize
  autoinstall_test_functions
} -shutdown {
  catch {db close}
  sqlite3_reset_auto_extension
  sqlite3_shutdown
  sqlite3_config_alt_pcache 0 0 0
  sqlite3_initialize

} -include ${perm-alt-pcache-testset}

run_tests "journaltest" -description {
  Check that pages are synced before being written (test_journal.c).
} -initialize {
  set ISQUICK 1
  catch {db close}







|







 







>






>







 







>






>











>





>










>
>








>
>







 







>
>








>
>







 







<





>







 







<








<





>








<








<





>












>
>




>
>







 







<






<





>






<






<



>






<






<



>






<






<



>






<






<



>







5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
...
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
...
203
204
205
206
207
208
209
210
211
212
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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
...
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
...
490
491
492
493
494
495
496

497
498
499
500
501
502
503
504
505
506
507
508
509
...
511
512
513
514
515
516
517

518
519
520
521
522
523
524
525

526
527
528
529
530
531
532
533
534
535
536
537
538
539

540
541
542
543
544
545
546
547

548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
...
627
628
629
630
631
632
633

634
635
636
637
638
639

640
641
642
643
644
645
646
647
648
649
650
651

652
653
654
655
656
657

658
659
660
661
662
663
664
665
666
667

668
669
670
671
672
673

674
675
676
677
678
679
680
681
682
683

684
685
686
687
688
689

690
691
692
693
694
695
696
697
698
699

700
701
702
703
704
705

706
707
708
709
710
711
712
713
714
715
716
#
#    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: permutations.test,v 1.47 2009/04/09 01:23:49 drh Exp $

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

# Argument processing.
#
#puts "PERM-DEBUG: argv=$argv"
................................................................................
  malloc5.test
} -initialize {
  catch {db close}
  sqlite3_shutdown
  sqlite3_config_pagecache 4096 24
  sqlite3_config_scratch 25000 1
  sqlite3_initialize
  autoinstall_test_functions
} -shutdown {
  catch {db close}
  sqlite3_shutdown
  sqlite3_config_pagecache 0 0
  sqlite3_config_scratch 0 0
  sqlite3_initialize
  autoinstall_test_functions
}

# Run some tests using pre-allocated page and scratch blocks. This time
# the allocations are too small to use in most cases.
#
# Both ioerr5.test and malloc5.test are excluded because they test the
# sqlite3_soft_heap_limit() and sqlite3_release_memory() functionality.
................................................................................
  malloc5.test
} -initialize {
  catch {db close}
  sqlite3_shutdown
  sqlite3_config_pagecache 512 5
  sqlite3_config_scratch 1000 1
  sqlite3_initialize
  autoinstall_test_functions
} -shutdown {
  catch {db close}
  sqlite3_shutdown
  sqlite3_config_pagecache 0 0
  sqlite3_config_scratch 0 0
  sqlite3_initialize
  autoinstall_test_functions
}

# Run all tests with the lookaside allocator disabled.
#
run_tests "nolookaside" -description {
  OOM tests with lookaside disabled
} -initialize {
  catch {db close}
  sqlite3_shutdown
  sqlite3_config_lookaside 0 0
  sqlite3_initialize
  autoinstall_test_functions
} -shutdown {
  catch {db close}
  sqlite3_shutdown
  sqlite3_config_lookaside 100 500
  sqlite3_initialize
  autoinstall_test_functions
}

# Run some tests in SQLITE_CONFIG_SINGLETHREAD mode.
#
run_tests "singlethread" -description {
  Tests run in SQLITE_CONFIG_SINGLETHREAD mode
} -initialize {
  catch {db close}
  sqlite3_shutdown
  catch {sqlite3_config singlethread}
  sqlite3_initialize
  autoinstall_test_functions
} -include {
  delete.test   delete2.test  insert.test  rollback.test  select1.test
  select2.test  trans.test    update.test  vacuum.test    types.test
  types2.test   types3.test
} -shutdown {
  catch {db close}
  sqlite3_shutdown
  catch {sqlite3_config serialized}
  sqlite3_initialize
  autoinstall_test_functions
}

run_tests "nomutex" -description {
  Tests run with the SQLITE_OPEN_MULTITHREADED flag passed to sqlite3_open().
} -initialize {
  rename sqlite3 sqlite3_nomutex
  proc sqlite3 {args} {
................................................................................
#
run_tests "multithread" -description {
  Tests run in SQLITE_CONFIG_MULTITHREAD mode
} -initialize {
  catch {db close}
  sqlite3_shutdown
  catch {sqlite3_config multithread}
  sqlite3_initialize
  autoinstall_test_functions
} -include {
  delete.test   delete2.test  insert.test  rollback.test  select1.test
  select2.test  trans.test    update.test  vacuum.test    types.test
  types2.test   types3.test
} -shutdown {
  catch {db close}
  sqlite3_shutdown
  catch {sqlite3_config serialized}
  sqlite3_initialize
  autoinstall_test_functions
}

# Run some tests in SQLITE_OPEN_FULLMUTEX mode.
#
run_tests "fullmutex" -description {
  Tests run in SQLITE_OPEN_FULLMUTEX mode
} -initialize {
................................................................................
    sqlite3_config_heap 25000000 0
    sqlite3_config_lookaside 0 0
    install_malloc_faultsim 1 
    sqlite3_initialize
    autoinstall_test_functions
  } -shutdown {
    catch {db close}

    sqlite3_shutdown
    sqlite3_config_heap 0 0
    sqlite3_config_lookaside 100 500
    install_malloc_faultsim 1 
    sqlite3_initialize
    autoinstall_test_functions
  }
}

ifcapable mem5 {
  run_tests "memsys5" -description {
    Run tests using the allocator in mem5.c.
  } -exclude {
................................................................................
    bigrow.test               incrblob2.test            memdb.test
    bitvec.test               index2.test               memsubsys1.test
    capi3c.test               ioerr.test                memsubsys2.test
    capi3.test                join3.test                pagesize.test
    collate5.test             limit.test                zeroblob.test
  } -initialize {
    catch {db close}

    sqlite3_shutdown
    sqlite3_config_heap 25000000 64
    sqlite3_config_lookaside 0 0
    install_malloc_faultsim 1 
    sqlite3_initialize
    autoinstall_test_functions
  } -shutdown {
    catch {db close}

    sqlite3_shutdown
    sqlite3_config_heap 0 0
    sqlite3_config_lookaside 100 500
    install_malloc_faultsim 1 
    sqlite3_initialize
    autoinstall_test_functions
  }

  run_tests "memsys5-2" -description {
    Run tests using the allocator in mem5.c in a different configuration.
  } -include {
    select1.test 
  } -initialize {
    catch {db close}

    sqlite3_shutdown
    sqlite3_config_heap 40000000 16
    sqlite3_config_lookaside 0 0
    install_malloc_faultsim 1 
    sqlite3_initialize
    autoinstall_test_functions
  } -shutdown {
    catch {db close}

    sqlite3_shutdown
    sqlite3_config_heap 0 0
    sqlite3_config_lookaside 100 500
    install_malloc_faultsim 1 
    sqlite3_initialize
    autoinstall_test_functions
  }
}

ifcapable threadsafe {
  run_tests "no_mutex_try" -description {
     The sqlite3_mutex_try() interface always fails
  } -exclude [concat $EXCLUDE mutex1.test mutex2.test] \
  -initialize {
    catch {db close}
    sqlite3_shutdown
    install_mutex_counters 1
    set ::disable_mutex_try 1
    sqlite3_initialize
    autoinstall_test_functions
  } -shutdown {
    catch {db close}
    sqlite3_shutdown
    install_mutex_counters 0
    sqlite3_initialize
    autoinstall_test_functions
  }
}

# run_tests "crash_safe_append" -description {
#   Run crash.test with persistent journals on a SAFE_APPEND file-system.
# } -initialize {
#   rename crashsql sa_crashsql
................................................................................
  update.test
}

run_tests "pcache0" -description {
  Alternative pcache implementation without random discard
} -initialize {
  catch {db close}

  sqlite3_shutdown
  sqlite3_config_alt_pcache 1 0 1
  sqlite3_initialize
  autoinstall_test_functions
} -shutdown {
  catch {db close}

  sqlite3_shutdown
  sqlite3_config_alt_pcache 0 0 0
  sqlite3_config_lookaside 100 500
  install_malloc_faultsim 1 
  sqlite3_initialize
  autoinstall_test_functions
} -include ${perm-alt-pcache-testset}

run_tests "pcache10" -description {
  Alternative pcache implementation without 10% random discard
} -initialize {
  catch {db close}

  sqlite3_shutdown
  sqlite3_config_alt_pcache 1 50 1
  sqlite3_initialize
  autoinstall_test_functions
} -shutdown {
  catch {db close}

  sqlite3_shutdown
  sqlite3_config_alt_pcache 0 0 0
  sqlite3_initialize
  autoinstall_test_functions
} -include ${perm-alt-pcache-testset}

run_tests "pcache50" -description {
  Alternative pcache implementation without 50% random discard
} -initialize {
  catch {db close}

  sqlite3_shutdown
  sqlite3_config_alt_pcache 1 50 1
  sqlite3_initialize
  autoinstall_test_functions
} -shutdown {
  catch {db close}

  sqlite3_shutdown
  sqlite3_config_alt_pcache 0 0 0
  sqlite3_initialize
  autoinstall_test_functions
} -include ${perm-alt-pcache-testset}

run_tests "pcache90" -description {
  Alternative pcache implementation without 90% random discard
} -initialize {
  catch {db close}

  sqlite3_shutdown
  sqlite3_config_alt_pcache 1 50 1
  sqlite3_initialize
  autoinstall_test_functions
} -shutdown {
  catch {db close}

  sqlite3_shutdown
  sqlite3_config_alt_pcache 0 0 0
  sqlite3_initialize
  autoinstall_test_functions
} -include ${perm-alt-pcache-testset}

run_tests "pcache100" -description {
  Alternative pcache implementation that always discards when unpinning
} -initialize {
  catch {db close}

  sqlite3_shutdown
  sqlite3_config_alt_pcache 1 100 1
  sqlite3_initialize
  autoinstall_test_functions
} -shutdown {
  catch {db close}

  sqlite3_shutdown
  sqlite3_config_alt_pcache 0 0 0
  sqlite3_initialize
  autoinstall_test_functions
} -include ${perm-alt-pcache-testset}

run_tests "journaltest" -description {
  Check that pages are synced before being written (test_journal.c).
} -initialize {
  set ISQUICK 1
  catch {db close}

Changes to test/speed1.test.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
289
290
291
292
293
294
295


296
#    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 measuring executing speed.
#
# $Id: speed1.test,v 1.10 2008/10/15 11:43:55 danielk1977 Exp $
#

sqlite3_shutdown
#sqlite3_config_scratch 29000 1
set old_lookaside [sqlite3_config_lookaside 1000 300]
#sqlite3_config_pagecache 1024 10000
set testdir [file dirname $argv0]
................................................................................
  db one {SELECT count(*) FROM t1}
} 10000
speed_trial_summary speed1

db close
sqlite3_shutdown
eval sqlite3_config_lookaside $old_lookaside


finish_test







|







 







>
>

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
289
290
291
292
293
294
295
296
297
298
#    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 measuring executing speed.
#
# $Id: speed1.test,v 1.11 2009/04/09 01:23:49 drh Exp $
#

sqlite3_shutdown
#sqlite3_config_scratch 29000 1
set old_lookaside [sqlite3_config_lookaside 1000 300]
#sqlite3_config_pagecache 1024 10000
set testdir [file dirname $argv0]
................................................................................
  db one {SELECT count(*) FROM t1}
} 10000
speed_trial_summary speed1

db close
sqlite3_shutdown
eval sqlite3_config_lookaside $old_lookaside
sqlite3_initialize
autoinstall_test_functions
finish_test

Changes to test/speed1p.test.

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
337
338
339
340
341
342
343


344
#
#*************************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this script is measuring executing speed.  
#
# This is a copy of speed1.test modified to user prepared statements.
#
# $Id: speed1p.test,v 1.6 2008/10/15 11:43:55 danielk1977 Exp $
#

sqlite3_shutdown
#sqlite3_config_scratch 29000 1
set old_lookaside [sqlite3_config_lookaside 2048 300]
#sqlite3_config_pagecache 1024 11000
set testdir [file dirname $argv0]
................................................................................
  db one {SELECT count(*) FROM t1}
} 10000
speed_trial_summary speed1

db close
sqlite3_shutdown
eval sqlite3_config_lookaside $old_lookaside


finish_test







|







 







>
>

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
337
338
339
340
341
342
343
344
345
346
#
#*************************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this script is measuring executing speed.  
#
# This is a copy of speed1.test modified to user prepared statements.
#
# $Id: speed1p.test,v 1.7 2009/04/09 01:23:49 drh Exp $
#

sqlite3_shutdown
#sqlite3_config_scratch 29000 1
set old_lookaside [sqlite3_config_lookaside 2048 300]
#sqlite3_config_pagecache 1024 11000
set testdir [file dirname $argv0]
................................................................................
  db one {SELECT count(*) FROM t1}
} 10000
speed_trial_summary speed1

db close
sqlite3_shutdown
eval sqlite3_config_lookaside $old_lookaside
sqlite3_initialize
autoinstall_test_functions
finish_test

Changes to test/tester.tcl.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
128
129
130
131
132
133
134

135
136
137
138
139
140
141
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements some common TCL routines used for regression
# testing the SQLite library
#
# $Id: tester.tcl,v 1.142 2009/04/06 17:50:03 danielk1977 Exp $

#
# What for user input before continuing.  This gives an opportunity
# to connect profiling tools to the process.
#
for {set i 0} {$i<[llength $argv]} {incr i} {
  if {[regexp {^-+pause$} [lindex $argv $i] all value]} {
................................................................................

# Create a test database
#
if {![info exists nTest]} {
  sqlite3_shutdown 
  install_malloc_faultsim 1 
  sqlite3_initialize

  if {[info exists tester_do_binarylog]} {
    sqlite3_instvfs binarylog -default binarylog ostrace.bin
    sqlite3_instvfs marker binarylog "$argv0 $argv"
  }
}

proc reset_db {} {







|







 







>







7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements some common TCL routines used for regression
# testing the SQLite library
#
# $Id: tester.tcl,v 1.143 2009/04/09 01:23:49 drh Exp $

#
# What for user input before continuing.  This gives an opportunity
# to connect profiling tools to the process.
#
for {set i 0} {$i<[llength $argv]} {incr i} {
  if {[regexp {^-+pause$} [lindex $argv $i] all value]} {
................................................................................

# Create a test database
#
if {![info exists nTest]} {
  sqlite3_shutdown 
  install_malloc_faultsim 1 
  sqlite3_initialize
  autoinstall_test_functions
  if {[info exists tester_do_binarylog]} {
    sqlite3_instvfs binarylog -default binarylog ostrace.bin
    sqlite3_instvfs marker binarylog "$argv0 $argv"
  }
}

proc reset_db {} {

Changes to test/tkt2565.test.

11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
..
82
83
84
85
86
87
88


89
90
#
# This script attempts to reproduce the circumstances of ticket #2565.
#
# More specifically, this script attempts to generate rollback journals
# that contain headers with nRec==0 that are followed by additional
# valid headers.
#
# $Id: tkt2565.test,v 1.1 2009/01/08 15:24:02 drh Exp $

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

# Use the alternative pcache and rig it to call pagerStress()
# very frequently.
#
................................................................................
  set sqlite_open_file_count
} 0

# Restore the pcache configuration for subsequent tests.
#
sqlite3_shutdown
sqlite3_config_alt_pcache 0



finish_test







|







 







>
>


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
..
82
83
84
85
86
87
88
89
90
91
92
#
# This script attempts to reproduce the circumstances of ticket #2565.
#
# More specifically, this script attempts to generate rollback journals
# that contain headers with nRec==0 that are followed by additional
# valid headers.
#
# $Id: tkt2565.test,v 1.2 2009/04/09 01:23:49 drh Exp $

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

# Use the alternative pcache and rig it to call pagerStress()
# very frequently.
#
................................................................................
  set sqlite_open_file_count
} 0

# Restore the pcache configuration for subsequent tests.
#
sqlite3_shutdown
sqlite3_config_alt_pcache 0
sqlite3_initialize
autoinstall_test_functions

finish_test