Artifact 2ae8f427d240099cc4b2dfef63cff44e2a68a1bd:
- File
test/wal7.test
— part of check-in
[177e2d72]
at
2011-06-15 19:18:47
on branch trunk
— Further tweaks to the wal7.test test case.
(user:
drh
size: 2832)
[more...]
0000: 23 20 32 30 31 31 20 4d 61 79 20 31 36 0a 23 0a # 2011 May 16.#.
0010: 23 20 54 68 65 20 61 75 74 68 6f 72 20 64 69 73 # The author dis
0020: 63 6c 61 69 6d 73 20 63 6f 70 79 72 69 67 68 74 claims copyright
0030: 20 74 6f 20 74 68 69 73 20 73 6f 75 72 63 65 20 to this source
0040: 63 6f 64 65 2e 20 20 49 6e 20 70 6c 61 63 65 20 code. In place
0050: 6f 66 0a 23 20 61 20 6c 65 67 61 6c 20 6e 6f 74 of.# a legal not
0060: 69 63 65 2c 20 68 65 72 65 20 69 73 20 61 20 62 ice, here is a b
0070: 6c 65 73 73 69 6e 67 3a 0a 23 0a 23 20 20 20 20 lessing:.#.#
0080: 4d 61 79 20 79 6f 75 20 64 6f 20 67 6f 6f 64 20 May you do good
0090: 61 6e 64 20 6e 6f 74 20 65 76 69 6c 2e 0a 23 20 and not evil..#
00a0: 20 20 20 4d 61 79 20 79 6f 75 20 66 69 6e 64 20 May you find
00b0: 66 6f 72 67 69 76 65 6e 65 73 73 20 66 6f 72 20 forgiveness for
00c0: 79 6f 75 72 73 65 6c 66 20 61 6e 64 20 66 6f 72 yourself and for
00d0: 67 69 76 65 20 6f 74 68 65 72 73 2e 0a 23 20 20 give others..#
00e0: 20 20 4d 61 79 20 79 6f 75 20 73 68 61 72 65 20 May you share
00f0: 66 72 65 65 6c 79 2c 20 6e 65 76 65 72 20 74 61 freely, never ta
0100: 6b 69 6e 67 20 6d 6f 72 65 20 74 68 61 6e 20 79 king more than y
0110: 6f 75 20 67 69 76 65 2e 0a 23 0a 23 2a 2a 2a 2a ou give..#.#****
0120: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ****************
0130: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ****************
0140: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ****************
0150: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ****************
0160: 2a 2a 2a 0a 23 20 54 68 69 73 20 66 69 6c 65 20 ***.# This file
0170: 69 6d 70 6c 65 6d 65 6e 74 73 20 72 65 67 72 65 implements regre
0180: 73 73 69 6f 6e 20 74 65 73 74 73 20 66 6f 72 20 ssion tests for
0190: 53 51 4c 69 74 65 20 6c 69 62 72 61 72 79 2e 20 SQLite library.
01a0: 20 54 68 65 0a 23 20 66 6f 63 75 73 20 6f 66 20 The.# focus of
01b0: 74 68 69 73 20 66 69 6c 65 20 69 73 20 74 65 73 this file is tes
01c0: 74 69 6e 67 20 74 68 65 20 50 52 41 47 4d 41 20 ting the PRAGMA
01d0: 6a 6f 75 72 6e 61 6c 5f 73 69 7a 65 5f 6c 69 6d journal_size_lim
01e0: 69 74 20 77 68 65 6e 0a 23 20 69 6e 20 57 41 4c it when.# in WAL
01f0: 20 6d 6f 64 65 2e 0a 23 0a 0a 73 65 74 20 74 65 mode..#..set te
0200: 73 74 64 69 72 20 5b 66 69 6c 65 20 64 69 72 6e stdir [file dirn
0210: 61 6d 65 20 24 61 72 67 76 30 5d 0a 73 6f 75 72 ame $argv0].sour
0220: 63 65 20 24 74 65 73 74 64 69 72 2f 74 65 73 74 ce $testdir/test
0230: 65 72 2e 74 63 6c 0a 69 66 63 61 70 61 62 6c 65 er.tcl.ifcapable
0240: 20 21 77 61 6c 20 7b 66 69 6e 69 73 68 5f 74 65 !wal {finish_te
0250: 73 74 20 3b 20 72 65 74 75 72 6e 20 7d 0a 0a 23 st ; return }..#
0260: 20 43 61 73 65 20 31 3a 20 20 4e 6f 20 73 69 7a Case 1: No siz
0270: 65 20 6c 69 6d 69 74 2e 20 20 4a 6f 75 72 6e 61 e limit. Journa
0280: 6c 20 63 61 6e 20 67 65 74 20 6c 61 72 67 65 2e l can get large.
0290: 0a 23 0a 64 6f 5f 74 65 73 74 20 77 61 6c 37 2d .#.do_test wal7-
02a0: 31 2e 30 20 7b 0a 20 20 64 62 20 63 6c 6f 73 65 1.0 {. db close
02b0: 0a 20 20 66 6f 72 63 65 64 65 6c 65 74 65 20 74 . forcedelete t
02c0: 65 73 74 2e 64 62 0a 20 20 73 71 6c 69 74 65 33 est.db. sqlite3
02d0: 20 64 62 20 74 65 73 74 2e 64 62 0a 20 20 64 62 db test.db. db
02e0: 20 65 76 61 6c 20 7b 0a 20 20 20 20 50 52 41 47 eval {. PRAG
02f0: 4d 41 20 70 61 67 65 5f 73 69 7a 65 3d 31 30 32 MA page_size=102
0300: 34 3b 0a 20 20 20 20 50 52 41 47 4d 41 20 6a 6f 4;. PRAGMA jo
0310: 75 72 6e 61 6c 5f 6d 6f 64 65 3d 57 41 4c 3b 0a urnal_mode=WAL;.
0320: 20 20 20 20 50 52 41 47 4d 41 20 77 61 6c 5f 61 PRAGMA wal_a
0330: 75 74 6f 63 68 65 63 6b 70 6f 69 6e 74 3d 35 30 utocheckpoint=50
0340: 3b 20 20 2d 2d 20 35 30 20 70 61 67 65 73 0a 20 ; -- 50 pages.
0350: 20 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 CREATE TABLE
0360: 74 31 28 78 2c 20 79 20 55 4e 49 51 55 45 29 3b t1(x, y UNIQUE);
0370: 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f . INSERT INTO
0380: 20 74 31 20 56 41 4c 55 45 53 28 31 2c 32 29 3b t1 VALUES(1,2);
0390: 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f . INSERT INTO
03a0: 20 74 31 20 56 41 4c 55 45 53 28 7a 65 72 6f 62 t1 VALUES(zerob
03b0: 6c 6f 62 28 32 30 30 30 30 30 29 2c 34 29 3b 0a lob(200000),4);.
03c0: 20 20 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 CREATE TABLE
03d0: 20 74 32 28 7a 29 3b 0a 20 20 20 20 44 45 4c 45 t2(z);. DELE
03e0: 54 45 20 46 52 4f 4d 20 74 31 3b 0a 20 20 20 20 TE FROM t1;.
03f0: 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 32 20 53 INSERT INTO t2 S
0400: 45 4c 45 43 54 20 78 20 46 52 4f 4d 20 74 31 3b ELECT x FROM t1;
0410: 0a 20 20 7d 0a 20 20 65 78 70 72 20 7b 5b 66 69 . }. expr {[fi
0420: 6c 65 20 73 69 7a 65 20 74 65 73 74 2e 64 62 2d le size test.db-
0430: 77 61 6c 5d 3e 35 30 2a 31 31 30 30 7d 0a 7d 20 wal]>50*1100}.}
0440: 31 0a 64 6f 5f 74 65 73 74 20 77 61 6c 37 2d 31 1.do_test wal7-1
0450: 2e 31 20 7b 0a 20 20 64 62 20 65 76 61 6c 20 7b .1 {. db eval {
0460: 50 52 41 47 4d 41 20 77 61 6c 5f 63 68 65 63 6b PRAGMA wal_check
0470: 70 6f 69 6e 74 7d 0a 20 20 65 78 70 72 20 7b 5b point}. expr {[
0480: 66 69 6c 65 20 73 69 7a 65 20 74 65 73 74 2e 64 file size test.d
0490: 62 2d 77 61 6c 5d 3e 35 30 2a 31 31 30 30 7d 0a b-wal]>50*1100}.
04a0: 7d 20 31 0a 64 6f 5f 74 65 73 74 20 77 61 6c 37 } 1.do_test wal7
04b0: 2d 31 2e 32 20 7b 0a 20 20 64 62 20 65 76 61 6c -1.2 {. db eval
04c0: 20 7b 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 32 {INSERT INTO t2
04d0: 20 56 41 4c 55 45 53 28 27 68 69 27 29 3b 7d 0a VALUES('hi');}.
04e0: 20 20 65 78 70 72 20 7b 5b 66 69 6c 65 20 73 69 expr {[file si
04f0: 7a 65 20 74 65 73 74 2e 64 62 2d 77 61 6c 5d 3e ze test.db-wal]>
0500: 35 30 2a 31 31 30 30 7d 0a 7d 20 31 0a 0a 23 20 50*1100}.} 1..#
0510: 43 61 73 65 20 32 3a 20 20 53 69 7a 65 20 6c 69 Case 2: Size li
0520: 6d 69 74 20 61 74 20 68 61 6c 66 20 74 68 65 20 mit at half the
0530: 61 75 74 6f 63 68 65 63 6b 70 6f 69 6e 74 20 73 autocheckpoint s
0540: 69 7a 65 2e 0a 23 0a 64 6f 5f 74 65 73 74 20 77 ize..#.do_test w
0550: 61 6c 37 2d 32 2e 30 20 7b 0a 20 20 64 62 20 63 al7-2.0 {. db c
0560: 6c 6f 73 65 0a 20 20 66 6f 72 63 65 64 65 6c 65 lose. forcedele
0570: 74 65 20 74 65 73 74 2e 64 62 0a 20 20 73 71 6c te test.db. sql
0580: 69 74 65 33 20 64 62 20 74 65 73 74 2e 64 62 0a ite3 db test.db.
0590: 20 20 64 62 20 65 76 61 6c 20 7b 0a 20 20 20 20 db eval {.
05a0: 50 52 41 47 4d 41 20 70 61 67 65 5f 73 69 7a 65 PRAGMA page_size
05b0: 3d 31 30 32 34 3b 0a 20 20 20 20 50 52 41 47 4d =1024;. PRAGM
05c0: 41 20 6a 6f 75 72 6e 61 6c 5f 6d 6f 64 65 3d 57 A journal_mode=W
05d0: 41 4c 3b 0a 20 20 20 20 50 52 41 47 4d 41 20 77 AL;. PRAGMA w
05e0: 61 6c 5f 61 75 74 6f 63 68 65 63 6b 70 6f 69 6e al_autocheckpoin
05f0: 74 3d 35 30 3b 20 20 2d 2d 20 35 30 20 70 61 67 t=50; -- 50 pag
0600: 65 73 0a 20 20 20 20 50 52 41 47 4d 41 20 6a 6f es. PRAGMA jo
0610: 75 72 6e 61 6c 5f 73 69 7a 65 5f 6c 69 6d 69 74 urnal_size_limit
0620: 3d 32 35 30 30 30 3b 0a 20 20 20 20 43 52 45 41 =25000;. CREA
0630: 54 45 20 54 41 42 4c 45 20 74 31 28 78 2c 20 79 TE TABLE t1(x, y
0640: 20 55 4e 49 51 55 45 29 3b 0a 20 20 20 20 49 4e UNIQUE);. IN
0650: 53 45 52 54 20 49 4e 54 4f 20 74 31 20 56 41 4c SERT INTO t1 VAL
0660: 55 45 53 28 31 2c 32 29 3b 0a 20 20 20 20 49 4e UES(1,2);. IN
0670: 53 45 52 54 20 49 4e 54 4f 20 74 31 20 56 41 4c SERT INTO t1 VAL
0680: 55 45 53 28 7a 65 72 6f 62 6c 6f 62 28 32 30 30 UES(zeroblob(200
0690: 30 30 30 29 2c 34 29 3b 0a 20 20 20 20 43 52 45 000),4);. CRE
06a0: 41 54 45 20 54 41 42 4c 45 20 74 32 28 7a 29 3b ATE TABLE t2(z);
06b0: 0a 20 20 20 20 44 45 4c 45 54 45 20 46 52 4f 4d . DELETE FROM
06c0: 20 74 31 3b 0a 20 20 20 20 49 4e 53 45 52 54 20 t1;. INSERT
06d0: 49 4e 54 4f 20 74 32 20 56 41 4c 55 45 53 28 31 INTO t2 VALUES(1
06e0: 29 3b 0a 20 20 7d 0a 20 20 66 69 6c 65 20 73 69 );. }. file si
06f0: 7a 65 20 74 65 73 74 2e 64 62 2d 77 61 6c 0a 7d ze test.db-wal.}
0700: 20 32 35 30 30 30 0a 0a 0a 23 20 43 61 73 65 20 25000...# Case
0710: 33 3a 20 20 53 69 7a 65 20 6c 69 6d 69 74 20 6f 3: Size limit o
0720: 66 20 7a 65 72 6f 2e 0a 23 0a 64 6f 5f 74 65 73 f zero..#.do_tes
0730: 74 20 77 61 6c 37 2d 33 2e 30 20 7b 0a 20 20 64 t wal7-3.0 {. d
0740: 62 20 63 6c 6f 73 65 0a 20 20 66 6f 72 63 65 64 b close. forced
0750: 65 6c 65 74 65 20 74 65 73 74 2e 64 62 0a 20 20 elete test.db.
0760: 73 71 6c 69 74 65 33 20 64 62 20 74 65 73 74 2e sqlite3 db test.
0770: 64 62 0a 20 20 64 62 20 65 76 61 6c 20 7b 0a 20 db. db eval {.
0780: 20 20 20 50 52 41 47 4d 41 20 70 61 67 65 5f 73 PRAGMA page_s
0790: 69 7a 65 3d 31 30 32 34 3b 0a 20 20 20 20 50 52 ize=1024;. PR
07a0: 41 47 4d 41 20 6a 6f 75 72 6e 61 6c 5f 6d 6f 64 AGMA journal_mod
07b0: 65 3d 57 41 4c 3b 0a 20 20 20 20 50 52 41 47 4d e=WAL;. PRAGM
07c0: 41 20 77 61 6c 5f 61 75 74 6f 63 68 65 63 6b 70 A wal_autocheckp
07d0: 6f 69 6e 74 3d 35 30 3b 20 20 2d 2d 20 35 30 20 oint=50; -- 50
07e0: 70 61 67 65 73 0a 20 20 20 20 50 52 41 47 4d 41 pages. PRAGMA
07f0: 20 6a 6f 75 72 6e 61 6c 5f 73 69 7a 65 5f 6c 69 journal_size_li
0800: 6d 69 74 3d 30 3b 0a 20 20 20 20 43 52 45 41 54 mit=0;. CREAT
0810: 45 20 54 41 42 4c 45 20 74 31 28 78 2c 20 79 20 E TABLE t1(x, y
0820: 55 4e 49 51 55 45 29 3b 0a 20 20 20 20 49 4e 53 UNIQUE);. INS
0830: 45 52 54 20 49 4e 54 4f 20 74 31 20 56 41 4c 55 ERT INTO t1 VALU
0840: 45 53 28 31 2c 32 29 3b 0a 20 20 20 20 49 4e 53 ES(1,2);. INS
0850: 45 52 54 20 49 4e 54 4f 20 74 31 20 56 41 4c 55 ERT INTO t1 VALU
0860: 45 53 28 7a 65 72 6f 62 6c 6f 62 28 32 30 30 30 ES(zeroblob(2000
0870: 30 30 29 2c 34 29 3b 0a 20 20 20 20 43 52 45 41 00),4);. CREA
0880: 54 45 20 54 41 42 4c 45 20 74 32 28 7a 29 3b 0a TE TABLE t2(z);.
0890: 20 20 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 DELETE FROM
08a0: 74 31 3b 0a 20 20 20 20 49 4e 53 45 52 54 20 49 t1;. INSERT I
08b0: 4e 54 4f 20 74 32 20 56 41 4c 55 45 53 28 31 29 NTO t2 VALUES(1)
08c0: 3b 0a 20 20 7d 0a 20 20 73 65 74 20 73 7a 20 5b ;. }. set sz [
08d0: 66 69 6c 65 20 73 69 7a 65 20 74 65 73 74 2e 64 file size test.d
08e0: 62 2d 77 61 6c 5d 0a 20 20 65 78 70 72 20 7b 24 b-wal]. expr {$
08f0: 73 7a 3e 30 20 26 26 20 24 73 7a 3c 31 33 37 30 sz>0 && $sz<1370
0900: 30 7d 0a 7d 20 31 0a 0a 0a 23 20 43 61 73 65 20 0}.} 1...# Case
0910: 34 3a 20 20 53 69 7a 65 20 6c 69 6d 69 74 20 73 4: Size limit s
0920: 65 74 20 62 65 66 6f 72 65 20 67 6f 69 6e 67 20 et before going
0930: 57 41 4c 0a 23 0a 64 6f 5f 74 65 73 74 20 77 61 WAL.#.do_test wa
0940: 6c 37 2d 34 2e 30 20 7b 0a 20 20 64 62 20 63 6c l7-4.0 {. db cl
0950: 6f 73 65 0a 20 20 66 6f 72 63 65 64 65 6c 65 74 ose. forcedelet
0960: 65 20 74 65 73 74 2e 64 62 0a 20 20 73 71 6c 69 e test.db. sqli
0970: 74 65 33 20 64 62 20 74 65 73 74 2e 64 62 0a 20 te3 db test.db.
0980: 20 64 62 20 65 76 61 6c 20 7b 0a 20 20 20 20 50 db eval {. P
0990: 52 41 47 4d 41 20 70 61 67 65 5f 73 69 7a 65 3d RAGMA page_size=
09a0: 31 30 32 34 3b 0a 20 20 20 20 50 52 41 47 4d 41 1024;. PRAGMA
09b0: 20 6a 6f 75 72 6e 61 6c 5f 73 69 7a 65 5f 6c 69 journal_size_li
09c0: 6d 69 74 3d 32 35 30 30 30 3b 0a 20 20 20 20 50 mit=25000;. P
09d0: 52 41 47 4d 41 20 6a 6f 75 72 6e 61 6c 5f 6d 6f RAGMA journal_mo
09e0: 64 65 3d 57 41 4c 3b 0a 20 20 20 20 50 52 41 47 de=WAL;. PRAG
09f0: 4d 41 20 77 61 6c 5f 61 75 74 6f 63 68 65 63 6b MA wal_autocheck
0a00: 70 6f 69 6e 74 3d 35 30 3b 20 20 2d 2d 20 35 30 point=50; -- 50
0a10: 20 70 61 67 65 73 0a 20 20 20 20 43 52 45 41 54 pages. CREAT
0a20: 45 20 54 41 42 4c 45 20 74 31 28 78 2c 20 79 20 E TABLE t1(x, y
0a30: 55 4e 49 51 55 45 29 3b 0a 20 20 20 20 49 4e 53 UNIQUE);. INS
0a40: 45 52 54 20 49 4e 54 4f 20 74 31 20 56 41 4c 55 ERT INTO t1 VALU
0a50: 45 53 28 31 2c 32 29 3b 0a 20 20 20 20 49 4e 53 ES(1,2);. INS
0a60: 45 52 54 20 49 4e 54 4f 20 74 31 20 56 41 4c 55 ERT INTO t1 VALU
0a70: 45 53 28 7a 65 72 6f 62 6c 6f 62 28 32 30 30 30 ES(zeroblob(2000
0a80: 30 30 29 2c 34 29 3b 0a 20 20 20 20 43 52 45 41 00),4);. CREA
0a90: 54 45 20 54 41 42 4c 45 20 74 32 28 7a 29 3b 0a TE TABLE t2(z);.
0aa0: 20 20 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 DELETE FROM
0ab0: 74 31 3b 0a 20 20 20 20 49 4e 53 45 52 54 20 49 t1;. INSERT I
0ac0: 4e 54 4f 20 74 32 20 56 41 4c 55 45 53 28 31 29 NTO t2 VALUES(1)
0ad0: 3b 0a 20 20 7d 0a 20 20 73 65 74 20 73 7a 20 5b ;. }. set sz [
0ae0: 66 69 6c 65 20 73 69 7a 65 20 74 65 73 74 2e 64 file size test.d
0af0: 62 2d 77 61 6c 5d 0a 7d 20 32 35 30 30 30 0a 0a b-wal].} 25000..
0b00: 0a 0a 0a 0a 66 69 6e 69 73 68 5f 74 65 73 74 0a ....finish_test.