xref: /sqlite-3.40.0/test/cachespill.test (revision 4b173695)
1# 2017 April 26
2#
3# The author disclaims copyright to this source code.  In place of
4# 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
13set testdir [file dirname $argv0]
14source $testdir/tester.tcl
15set testprefix cachespill
16
17ifcapable !pager_pragmas {
18  finish_test
19  return
20}
21
22#-------------------------------------------------------------------------
23# Test that "PRAGMA cache_spill = 0" completely disables cache spilling.
24#
25do_execsql_test 1.1 {
26  PRAGMA auto_vacuum = 0;
27  PRAGMA page_size = 1024;
28  PRAGMA cache_size = 100;
29  CREATE TABLE t1(a);
30}
31
32do_test 1.2 {
33  file size test.db
34} {2048}
35
36do_test 1.3 {
37  execsql {
38    BEGIN;
39      WITH s(i) AS (
40        SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<200
41      ) INSERT INTO t1 SELECT randomblob(900) FROM s;
42  }
43  expr {[file size test.db] > 50000}
44} {1}
45
46do_test 1.4 {
47  execsql ROLLBACK
48  file size test.db
49} {2048}
50
51do_test 1.5 {
52  execsql {
53    PRAGMA cache_spill = 0;
54    BEGIN;
55      WITH s(i) AS (
56        SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<200
57      ) INSERT INTO t1 SELECT randomblob(900) FROM s;
58  }
59  file size test.db
60} {2048}
61
62do_test 1.5 {
63  execsql {
64    ROLLBACK;
65    PRAGMA cache_spill = 1;
66    BEGIN;
67      WITH s(i) AS (
68        SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<200
69      ) INSERT INTO t1 SELECT randomblob(900) FROM s;
70  }
71  expr {[file size test.db] > 50000}
72} {1}
73
74do_execsql_test 1.6 { ROLLBACK }
75
76
77finish_test
78