Run shell*.test modules with "make mdevtest".
[sqlite.git] / test / corruptL.test
blobcf38764415722241d353833b428d9c643f14f86c
1 # 2019-01-11
3 # The author disclaims copyright to this source code.  In place of
4 # a legal notice, here is a blessing:
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.
10 #***********************************************************************
13 set testdir [file dirname $argv0]
14 source $testdir/tester.tcl
15 set testprefix corruptL
17 database_may_be_corrupt
19 #-------------------------------------------------------------------------
20 reset_db
21 do_test 1.0 {
22   sqlite3 db {}
23   db deserialize [decode_hexdb {
24 | size 356352 pagesize 4096 filename crash-acaae0347204ae.db
25 | page 1 offset 0
26 |      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
27 |     16: 10 00 01 01 00 40 20 20 00 00 00 00 d0 00 00 00   .....@  ........
28 |     32: 40 00 ea 00 00 00 00 00 00 40 00 00 00 40 00 00   @........@...@..
29 |     96: 00 00 00 00 0d 00 00 00 04 0e 9c 00 0f ad 0f 4f   ...............O
30 |    112: 0e fc 0e 9c 00 00 00 00 00 00 00 00 00 00 00 00   ................
31 |   3728: 00 00 00 00 00 00 00 00 00 00 00 00 5e 04 07 17   ............^...
32 |   3744: 1f 1f 01 81 0b 74 61 62 6c 65 74 31 5f 70 61 72   .....tablet1_par
33 |   3760: 65 6e 74 74 31 5f 70 61 72 65 6e 74 04 43 52 45   entt1_parent.CRE
34 |   3776: 41 54 45 20 54 41 42 4c 45 20 22 74 31 5f 70 61   ATE TABLE .t1_pa
35 |   3792: 72 65 6e 74 22 28 6e 6f 64 65 6e 6f 20 49 4e 54   rent.(nodeno INT
36 |   3808: 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59   EGER PRIMARY KEY
37 |   3824: 2c 70 61 72 65 6e 74 6e 6f 64 65 29 51 03 06 17   ,parentnode)Q...
38 |   3840: 1b 1b 01 7b 74 61 62 6c 65 74 31 5f 6e 6f 64 65   ....tablet1_node
39 |   3856: 74 31 5f 6e 6f 64 65 03 43 52 45 41 54 45 20 54   t1_node.CREATE T
40 |   3872: 41 42 4c 45 20 22 74 31 5f 6e 6f 64 65 22 28 6e   ABLE .t1_node.(n
41 |   3888: 6f 64 65 6e 6f 20 49 4e 54 45 47 45 52 20 50 52   odeno INTEGER PR
42 |   3904: 49 4d 41 52 59 20 4b 45 59 2c 64 61 74 61 29 5c   IMARY KEY,data).
43 |   3920: 02 07 17 1d 1d 01 81 0b 74 61 62 6c 65 74 31 5f   ........tablet1_
44 |   3936: 72 6f 77 69 64 74 31 5f 72 6f 77 69 64 02 43 52   rowidt1_rowid.CR
45 |   3952: 45 41 54 45 20 54 41 42 4c 45 20 22 74 31 5f 72   EATE TABLE .t1_r
46 |   3968: 6f 77 69 64 22 28 72 6f 77 69 64 20 49 4e 54 45   owid.(rowid INTE
47 |   3984: 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c   GER PRIMARY KEY,
48 |   4000: 6e 6f 64 65 6e 6f 2c 61 30 2c 61 31 29 51 01 07   nodeno,a0,a1)Q..
49 |   4016: 17 11 11 08 81 0f 74 61 62 6c 65 74 31 74 31 43   ......tablet1t1C
50 |   4032: 52 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41   REATE VIRTUAL TA
51 |   4048: 42 4c 45 20 74 31 20 55 53 49 4e 47 20 72 74 72   BLE t1 USING rtr
52 |   4064: 65 65 28 69 64 2c 78 30 20 50 52 49 4d 41 52 59   ee(id,x0 PRIMARY
53 |   4080: 20 4b 45 59 2c 70 61 72 65 6e 74 6e 6f 64 65 29    KEY,parentnode)
54 | page 2 offset 4096
55 |      0: 51 03 06 17 1b 1b 01 7b 74 61 62 6c 65 74 31 5f   Q.......tablet1_
56 |     16: 6e 6f 64 65 74 31 5f 6e 6f 64 65 03 43 52 45 41   nodet1_node.CREA
57 |     32: 54 45 20 54 41 42 4c 45 20 22 74 31 5f 6e 6f 64   TE TABLE .t1_nod
58 |     48: 65 22 28 6e 6f 64 65 6e 6f 20 49 4e 54 45 47 45   e.(nodeno INTEGE
59 |     64: 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 64 61   R PRIMARY KEY,da
60 |     80: 74 61 29 5c 02 07 17 1d 1d 01 81 0b 74 61 62 6c   ta).........tabl
61 |     96: 65 74 31 5f 72 6f 77 69 64 74 31 5f 72 6f 77 69   et1_rowidt1_rowi
62 |    112: 64 02 43 52 45 41 54 45 20 54 41 42 4c 45 00 00   d.CREATE TABLE..
63 |    128: 01 0a 02 00 00 00 01 0e 0d 00 00 00 00 24 0e 0d   .............$..
64 |    144: 0c 1a 06 85 50 46 60 27 70 08 00 00 00 00 00 00   ....PF`'p.......
65 |   3824: 00 00 00 00 00 00 00 0d 0e 05 00 09 1d 00 74 6f   ..............to
66 |   3840: 79 20 68 61 6c 66 10 0d 05 00 09 23 00 62 6f 74   y half.....#.bot
67 |   3856: 74 6f 6d 20 68 61 6c 66 0f 0c 05 00 09 21 00 72   tom half.....!.r
68 |   3872: 69 67 68 74 20 68 61 6c 66 0e 0b 05 00 09 1f 00   ight half.......
69 |   3888: 6c 65 66 74 20 43 15 f6 e6 f6 46 50 34 35 24 54   left C....FP45$T
70 |   3904: 15 44 52 05 44 14 24 c4 52 02 27 43 15 f6 e6 f6   .DR.D.$.R.'C....
71 |   3920: 46 52 22 8e 6f 64 65 6e 6f 20 49 4e 54 45 47 45   FR..odeno INTEGE
72 |   3936: 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 64 61   R PRIMARY KEY,da
73 |   3952: 74 61 29 5c 02 07 17 1d 1d 01 81 0b 74 61 62 6c   ta).........tabl
74 |   3968: 65 74 31 5f 72 6f 74 74 6f 6d 20 65 64 67 65 0f   et1_rottom edge.
75 |   3984: 07 05 00 09 21 00 72 69 67 68 74 20 65 64 67 65   ....!.right edge
76 |   4000: 0e 06 05 00 09 1f 00 6c 65 66 74 20 65 64 67 65   .......left edge
77 |   4016: 0b 05 05 00 09 19 00 63 65 6e 74 65 72 17 04 05   .......center...
78 |   4032: 00 09 31 00 75 70 70 65 72 2d 72 69 67 68 74 20   ..1.upper-right 
79 |   4048: 63 6f 72 6e 65 72 17 03 05 00 09 31 00 6c 6f 77   corner.....1.low
80 |   4064: 65 72 2d 72 69 67 68 74 20 63 6f 72 6e 65 72 16   er-right corner.
81 |   4080: 02 05 00 09 2f 00 75 70 70 65 72 2d 6c 65 66 74   ..../.upper-left
82 | page 3 offset 8192
83 |      0: 20 63 6f 72 6e 65 72 16 01 05 00 09 2f 01 8c 6f    corner...../..o
84 |     16: 77 65 72 2d 6c 53 51 4c 69 74 65 20 66 6f 72 6d   wer-lSQLite form
85 |     32: 61 74 20 33 00 10 00 01 01 00 40 20 20 00 00 00   at 3......@  ...
86 |     48: 00 00 00 00 2f 00 00 0d eb 13 00 00 00 03 00 00   ..../...........
87 |     64: 00 04 00 00 00 00 00 00 00 06 00 00 00 01 00 00   ................
88 |     80: 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00   ................
89 | page 6 offset 20480
90 |    128: 00 00 00 00 00 00 00 00 97 3d 04 ae 7c 01 00 00   .........=..|...
91 |    624: 00 00 00 00 00 00 21 97 3d 04 ae 7c 01 00 00 00   ......!.=..|....
92 |   1120: 00 00 00 00 00 20 97 3d 04 ae 7c 01 00 00 00 00   ..... .=..|.....
93 |   1616: 00 00 00 00 1f 97 3d 04 ae 7c 01 00 00 00 00 00   ......=..|......
94 |   2112: 00 00 00 1e 97 3d 04 ae 7c 01 00 00 00 00 00 00   .....=..|.......
95 |   2608: 00 00 1d 97 d3 d0 4a e7 c0 00 00 00 00 00 00 00   ......J.........
96 |   3088: 00 00 00 00 00 00 00 00 00 00 00 00 01 f3 00 00   ................
97 |   3600: 23 97 3d 04 ae 7c 01 00 00 00 00 00 00 00 00 00   #.=..|..........
98 |   4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 26   ...............&
99 | page 8 offset 28672
100 |      0: 0d 00 00 00 01 04 30 00 04 30 00 00 00 00 00 00   ......0..0......
101 |   1072: 97 4d 1e 14 00 ae 7c 00 00 00 00 00 00 00 00 00   .M....|.........
102 |   1088: 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00   ................
103 |   4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03   ................
104 | page 10 offset 36864
105 |      0: 0d 00 00 00 01 04 30 00 04 30 00 00 00 00 00 00   ......0..0......
106 |   1072: 9a ee c1 80 fd 78 1f ce 1b ae eb b4 00 00 00 00   .....x..........
107 |   1088: 13 20 ff 20 00 70 00 00 00 60 50 00 00 00 11 e0   . . .p...`P.....
108 |   1104: 00 00 00 70 00 00 00 60 50 05 35 14 c6 97 46 52   ...p...`P.5...FR
109 |   1120: 06 66 f7 26 d6 17 42 03 30 01 00 00 10 10 04 02   .f.&..B.0.......
110 |   1136: 02 00 00 00 00 00 00 00 00 40 00 00 00 00 00 00   .........@......
111 |   1152: 00 00 00 00 00 40 00 00 00 40 00 00 00 00 00 00   .....@...@......
112 |   4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 05   ................
113 | page 12 offset 45056
114 |      0: 0d 00 00 00 01 04 30 00 04 30 e1 b4 30 97 4d 46   ......0..0..0.MF
115 |     16: 14 00 ae 7c 00 00 00 00 00 00 00 03 00 00 43 00   ...|..........C.
116 | page 47 offset 188416
117 |   2512: 00 00 00 00 00 00 00 00 be 00 00 00 00 00 00 00   ................
118 | page 87 offset 352256
119 |   2512: 00 00 00 00 00 00 00 00 aa 00 00 00 00 00 00 00   ................
120 | end crash-acaae0347204ae.db
121 }]} {}
123 do_catchsql_test 1.1 {
124   PRAGMA cell_size_check = off;
125   DROP INDEX t1x1;
126 } {1 {database disk image is malformed}}
128 do_catchsql_test 1.2 {
129   SELECT sum(s+length(b)) FROM t1 WHERE a IN (110,10,150) AND q IS NULL;
130 } {1 {database disk image is malformed}}
132 do_catchsql_test 1.3 {
133   REINDEX t1;
134 } {1 {database disk image is malformed}}
136 do_catchsql_test 1.4 {
137   PRAGMA integrity_check
138 } {1 {database disk image is malformed}}
141 #-------------------------------------------------------------------------
142 reset_db
143 do_test 2.0 {
144   sqlite3 db {}
145   db deserialize [decode_hexdb {
146 | size 20480 pagesize 4096 filename crash.txt.db
147 | page 1 offset 0
148 |      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
149 |     16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 05   .....@  ........
150 |     32: 00 00 00 00 00 00 00 00 00 00 00 05 00 00 00 04   ................
151 |     48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00   ................
152 |     96: 00 00 00 00 0d 00 00 00 05 0e 55 00 0f 74 0f 3c   ..........U..t.<
153 |    112: 0e f9 0e d1 0e 55 00 00 00 00 00 00 00 00 00 00   .....U..........
154 |   3664: 00 00 00 00 00 7a 05 07 15 11 11 08 81 63 76 69   .....z.......cvi
155 |   3680: 65 77 76 31 76 31 43 52 45 41 54 45 20 56 49 45   ewv1v1CREATE VIE
156 |   3696: 57 20 76 31 28 78 2c 79 29 20 41 53 0a 53 45 4c   W v1(x,y) AS.SEL
157 |   3712: 45 43 54 20 74 31 2e 62 2c 74 32 2e 62 20 46 52   ECT t1.b,t2.b FR
158 |   3728: 4f 4d 20 74 31 2c 74 32 20 57 48 45 52 45 20 74   OM t1,t2 WHERE t
159 |   3744: 31 2e 61 3d 74 32 2e 61 20 47 52 4f 55 50 20 42   1.a=t2.a GROUP B
160 |   3760: 59 20 31 20 48 41 56 49 4e 47 20 74 32 2e 63 20   Y 1 HAVING t2.c 
161 |   3776: 4e 4f 54 20 4e 55 4c 4c 0a 4c 49 4d 49 54 20 31   NOT NULL.LIMIT 1
162 |   3792: 30 26 04 06 17 11 11 01 39 74 61 62 6c 65 74 32   0&......9tablet2
163 |   3808: 74 32 05 43 52 45 41 54 45 20 54 41 42 4c 45 20   t2.CREATE TABLE 
164 |   3824: 74 32 28 61 2c 62 2c 63 29 41 03 06 17 15 11 01   t2(a,b,c)A......
165 |   3840: 6b 69 6e 64 65 78 74 31 78 31 74 31 04 43 52 45   kindext1x1t1.CRE
166 |   3856: 41 54 45 20 49 4e 44 45 58 20 73 31 78 31 20 4f   ATE INDEX s1x1 O
167 |   3872: 4e 20 74 31 28 64 29 20 57 48 45 52 45 20 65 65   N t1(d) WHERE ee
168 |   3888: 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 36 02 06 17    IS NOT NULL6...
169 |   3904: 17 11 01 53 69 6e 64 65 78 74 31 61 62 63 74 31   ...Sindext1abct1
170 |   3920: 03 43 52 45 41 54 45 20 49 4e 44 45 58 20 74 31   .CREATE INDEX t1
171 |   3936: 61 62 63 20 4f 4e 20 74 31 28 61 2c 62 2c 63 2b   abc ON t1(a,b,c+
172 |   3952: 64 2b 65 29 81 09 01 07 17 11 11 01 81 7d 74 61   d+e)..........ta
173 |   3968: 62 6c 65 74 31 74 31 02 43 52 45 41 54 45 20 54   blet1t1.CREATE T
174 |   3984: 41 42 4c 45 20 74 31 28 61 2c 62 2c 63 2c 64 2c   ABLE t1(a,b,c,d,
175 |   4000: 65 2c 66 2c 67 2c 68 2c 6a 2c 6a 6a 2c 6a 6a 6a   e,f,g,h,j,jj,jjj
176 |   4016: 2c 6b 2c 61 61 2c 62 62 2c 63 63 2c 64 64 2c 65   ,k,aa,bb,cc,dd,e
177 |   4032: 65 20 44 45 46 41 55 4c 54 20 33 2e 31 34 2c 0a   e DEFAULT 3.14,.
178 |   4048: 66 66 20 44 45 46 41 55 4c 54 28 27 68 69 63 63   ff DEFAULT('hicc
179 |   4064: 75 70 27 29 2c 67 67 20 4e 4f 54 20 4e 55 4c 4c   up'),gg NOT NULL
180 |   4080: 20 44 45 46 41 55 4c 54 28 66 61 6c 73 65 29 29    DEFAULT(false))
181 | page 2 offset 4096
182 |      0: 0d 00 00 00 0a 0e 7b 00 0f dc 0f b6 0f 8f 0f 68   ...............h
183 |     16: 0f 41 0f 1a 0e f3 0e cb 0e a3 0e 7b 00 00 00 00   .A..............
184 |   3696: 00 00 00 00 00 00 00 00 00 00 00 26 0a 14 01 01   ...........&....
185 |   3712: 02 08 00 00 00 00 00 00 00 00 00 00 00 00 07 19   ................
186 |   3728: 08 09 5a 00 b4 40 09 1e b8 51 eb 85 1f 68 69 63   ..Z..@...Q...hic
187 |   3744: 63 75 70 26 09 14 01 01 02 08 00 00 00 00 00 00   cup&............
188 |   3760: 00 00 00 00 00 00 07 19 08 08 50 00 a0 40 09 1e   ..........P..@..
189 |   3776: b8 51 eb 85 1f 68 69 63 63 75 70 26 08 14 01 01   .Q...hiccup&....
190 |   3792: 02 08 00 00 00 00 00 00 00 00 00 00 00 00 07 19   ................
191 |   3808: 08 07 46 00 8c 40 09 1e b8 51 eb 85 1f 68 69 63   ..F..@...Q...hic
192 |   3824: 63 75 70 25 07 14 01 01 01 08 00 00 00 00 00 00   cup%............
193 |   3840: 00 00 00 00 00 00 07 b9 08 06 3c 78 40 09 1e b8   ..........<x@...
194 |   3856: 51 eb 85 1f 68 69 63 63 75 70 25 06 14 01 00 01   Q...hiccup%.....
195 |   3872: 08 00 00 00 00 00 00 00 00 00 00 00 00 07 19 08   ................
196 |   3888: 05 32 64 40 09 1e b8 51 eb 85 1f 68 69 63 63 75   .2d@...Q...hiccu
197 |   3904: 70 25 05 14 01 01 01 08 00 00 00 00 00 00 00 00   p%..............
198 |   3920: 00 00 00 00 07 19 08 04 28 50 40 09 1e b8 51 eb   ........(P@...Q.
199 |   3936: 85 1f 68 69 63 63 75 70 25 04 14 01 01 01 08 00   ..hiccup%.......
200 |   3952: 00 00 00 00 00 00 00 00 00 00 00 07 19 08 03 1e   ................
201 |   3968: 3c 40 09 1e b8 51 eb 85 1f 68 69 63 63 75 70 25   <@...Q...hiccup%
202 |   3984: 03 14 01 01 01 08 00 00 00 00 00 00 00 00 00 00   ................
203 |   4000: 00 00 07 19 08 02 14 28 40 09 1e b8 51 eb 85 1f   .......(@...Q...
204 |   4016: 68 69 63 63 75 70 24 02 14 09 01 01 08 00 00 00   hiccup$.........
205 |   4032: 00 00 00 00 00 00 00 00 00 07 19 08 0a 14 40 09   ..............@.
206 |   4048: 1e b8 51 eb 85 1f 68 69 63 63 75 70 22 01 14 08   ..Q...hiccup....
207 |   4064: 08 08 07 ff ff ff ff ff ff 00 00 00 00 00 00 07   ................
208 |   4080: 19 08 40 09 1e b8 51 eb 85 1f 68 69 63 63 75 70   ..@...Q...hiccup
209 | page 3 offset 8192
210 |      0: 0a 00 00 00 0a 0f aa 00 0f fa 0f f2 0f e9 0f e0   ................
211 |     16: 0f d7 0f ce 0f c5 0f bc 0e b3 0f aa 00 00 00 00   ................
212 |   4000: 00 00 00 00 00 00 00 00 00 00 08 05 01 01 00 01   ................
213 |   4016: 09 5a 0a 08 05 01 01 00 01 08 50 09 08 05 01 01   .Z........P.....
214 |   4032: 00 01 07 46 08 08 05 01 01 00 01 06 3c 07 08 05   ...F........<...
215 |   4048: 01 01 00 01 05 32 06 08 05 01 01 00 01 04 28 05   .....2........(.
216 |   4064: 08 05 01 01 00 01 03 1e 04 08 05 01 01 00 01 02   ................
217 |   4080: 14 03 07 05 09 01 00 01 0a 02 05 05 08 08 00 09   ................
218 | page 4 offset 12288
219 |      0: 0a 00 00 00 0a 0f cf 00 0f fc 0f f7 0f f2 0f ed   ................
220 |     16: 0f e8 0f e3 0f de 0f d9 0f d4 0f cf 00 00 00 00   ................
221 |   4032: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04   ................
222 |   4048: 03 08 01 0a 04 03 08 01 09 04 03 08 01 08 04 03   ................
223 |   4064: 08 01 07 04 03 08 01 06 04 03 08 01 05 04 03 08   ................
224 |   4080: 01 04 04 03 08 01 13 04 03 08 01 02 03 03 08 09   ................
225 | page 5 offset 16384
226 |      0: 0d 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00   ................
227 | end crash.txt.db
228 }]} {}
230 do_execsql_test 2.1 {
231   PRAGMA writable_schema=ON; -- bypass improved sqlite_master consistency checking
232   INSERT INTO t1(b) VALUES(X'a0fee3669f9fddefc5cba913e4225d4b6ce2b04f26b87fad3ee6f9b7d90a1ea62a169bf41e5d32707a6ca5c3d05e4bde05c9d89eaaa8c50e74333d2e9fcd7dfe95528a3a016aac1102d825c5cd70cf99d8a88e0ea7f798d4334386518b7ad359beb168b93aba059a2a3bd93112d65b44c12b9904ea786b204d80531cdf0504bf9b203dbe927061974caf7b9f30cbc3397b61f802e732012a6663d41c3607d6f1c0dbcfd489adac05ca500c0b04439d894cd93a840159225ef73b627e178b9f84b3ffe66cf22a963a8368813ff7961fc47f573211ccec95e0220dcbb3bf429f4a50ba54d7a53784ac51bfef346e6ac8ae0d0e7c3175946e62ba2b');
235 do_catchsql_test 2.2 {
236   SELECT b,c FROM t1 ORDER BY a;
237 } {1 {database disk image is malformed}}
239 #-------------------------------------------------------------------------
240 reset_db
241 do_execsql_test 3.0 {
242   CREATE TABLE t1(a, b, c, d INTEGER PRIMARY KEY);
243   CREATE TABLE t2(a, b, c, d INTEGER PRIMARY KEY);
245   INSERT INTO t1(a, b, c, d) VALUES (1, 2, 3, 100), (4, 5, 6, 101);
246   INSERT INTO t2(a, b, c, d) VALUES (1, 100, 3, 1000), (4, 101, 6, 1001);
248   CREATE INDEX t1a ON t1(a);
249   CREATE INDEX t2a ON t2(a, b, c);
251   PRAGMA writable_schema = 1;
252   UPDATE sqlite_master SET sql = 'CREATE INDEX t2a ON t2(a)' WHERE name='t2a';
255 db close
256 sqlite3 db test.db
258 do_catchsql_test 3.1 {
259   INSERT INTO t1 SELECT * FROM t2;
260 } {1 {database disk image is malformed}}
262 #-------------------------------------------------------------------------
263 reset_db
264 do_test 4.0 {
265   sqlite3 db {}
266   db deserialize [decode_hexdb {
267 | size 4096 pagesize 512 filename crash-6b48ba69806134.db
268 | page 1 offset 0
269 |      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
270 |     16: 02 00 01 01 00 40 20 20 00 ff ff ff ff 00 00 07   .....@  ........
271 |     32: 00 00 00 00 00 00 00 00 00 00 00 08 00 00 00 04   ................
272 |     48: 00 00 00 00 00 00 00 05 00 eb 00 01 00 00 00 00   ................
273 |     80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0c   ................
274 |     96: 00 2e 2c 50 0d 00 00 00 06 01 06 00 01 da 01 b0   ..,P............
275 |    112: 05 56 01 86 01 2a 01 06 00 00 00 00 00 00 00 00   .V...*..........
276 |    128: 00 ff 00 00 ff ff ff e1 00 00 00 00 00 00 00 00   ................
277 |    144: 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00   ................
278 |    160: 00 00 00 00 00 00 00 00 f2 00 00 00 00 00 00 00   ................
279 |    176: 00 00 f9 ff ff ff ff ff ff ff 00 00 00 00 00 fb   ................
280 |    208: 00 00 00 00 00 00 00 00 1e 00 00 00 fe 00 00 00   ................
281 |    224: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ca 00   ................
282 |    256: 00 00 00 00 ef ff 22 07 06 17 11 11 01 31 74 61   .............1ta
283 |    272: 62 6c 65 74 38 38 74 04 43 52 45 41 54 45 20 54   blet88t.CREATE T
284 |    288: 41 42 4c 45 20 74 34 28 87 29 2a 06 06 17 13 11   ABLE t4(.)*.....
285 |    304: 01 3f 69 4f 64 65 78 74 33 78 74 33 05 43 52 45   .?iOdext3xt3.CRE
286 |    320: 41 54 45 20 49 6e 44 45 58 20 74 33 78 20 4f 4e   ATE InDEX t3x ON
287 |    336: 20 74 33 28 78 29 2e 04 06 17 15 11 01 45 69 6e    t3(x).......Ein
288 |    352: 64 65 2e 74 32 63 64 74 3d 05 43 52 45 41 54 45   de.t2cdt=.CREATE
289 |    368: 20 49 4e 44 45 58 20 74 32 63 64 20 4f 4e 20 74    INDEX t2cd ON t
290 |    384: 32 28 0a 0c 44 29 28 05 06 17 11 11 01 3d 74 61   2(..D)(......=ta
291 |    400: 62 6c 65 d4 33 74 33 04 43 52 45 41 54 45 20 54   ble.3t3.CREATE T
292 |    416: 41 42 4c 45 20 74 33 28 63 2c 78 2c 65 2c 66 29   ABLE t3(c,x,e,f)
293 |    432: 28 02 06 17 11 11 01 3d 74 61 62 6c 65 74 32 74   (......=tablet2t
294 |    448: 32 03 43 52 45 41 54 45 20 54 41 42 4c 45 20 74   2.CREATE TABLE t
295 |    464: 32 28 63 2c 64 2c 65 2c 66 29 24 01 06 17 11 11   2(c,d,e,f)$.....
296 |    480: 01 35 74 60 62 6c 65 74 31 74 31 02 43 52 45 41   .5t`blet1t1.CREA
297 |    496: 54 45 20 54 41 42 4c 45 20 74 30 28 61 2c 62 29   TE TABLE t0(a,b)
298 | page 2 offset 512
299 |      0: 0d 00 ff 11 04 01 cf 00 01 fa 01 f3 01 de 01 cf   ................
300 |     32: 00 00 08 00 00 00 00 00 00 00 00 00 00 00 00 13   ................
301 |     48: 00 00 00 00 00 00 00 00 00 00 00 01 00 20 00 00   ............. ..
302 |     64: 00 00 00 00 00 00 f8 ff ff ff 00 00 00 00 00 00   ................
303 |    160: 01 64 00 00 00 00 00 80 ff ff ff 00 00 00 00 00   .d..............
304 |    176: 00 00 00 00 00 00 00 00 1f 00 00 00 00 00 00 03   ................
305 |    192: 00 00 40 00 00 00 00 00 00 00 00 00 00 00 00 00   ..@.............
306 |    288: 00 00 00 00 00 00 ff ff ff e9 00 00 00 00 00 00   ................
307 |    336: 01 00 00 ff ff 00 00 00 00 00 00 00 00 00 00 00   ................
308 |    368: 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ...............
309 |    384: 00 de ff 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
310 |    464: 00 00 00 00 00 13 76 65 6e 65 69 67 68 74 13 03   ......veneight..
311 |    480: 03 40 07 07 14 00 54 45 20 49 4e 44 45 58 20 74   .@....TE INDEX t
312 |    496: 32 63 64 20 4f 4e 20 74 32 28 0a 0c 44 09 01 02   2cd ON t2(..D...
313 | page 3 offset 1024
314 |      0: 0d 00 00 00 48 01 54 00 01 f7 01 ec 01 c5 01 aa   ....H.T.........
315 |     16: 30 34 28 87 29 2a 06 06 17 13 11 01 3f 69 4f 64   04(.)*......?iOd
316 |     32: 65 79 74 33 78 74 33 6d 6d 6d 6d 6d 6d 7d 6d 6d   eyt3xt3mmmmmm.mm
317 |     48: 6d 41 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d   mAmmmmmmmmmmmmmm
318 |     64: 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d 66 6d 6d 6d 6d   mmmmmmmmmmmfmmmm
319 |     80: 6d 4e 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d   mNmmmmmmmmmmmmmm
320 |     96: 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d   mmmmmmmmmmmmmmmm
321 |    112: 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d 6d   mmmmmmmmmmmmmmmm
322 |    128: 6d 6d 6d 6d 6d 00 00 00 00 00 00 00 00 00 00 00   mmmmm...........
323 |    160: 80 00 00 00 00 00 00 03 00 00 00 ff e4 00 00 00   ................
324 |    208: 00 00 00 00 00 00 00 00 00 00 00 00 00 c5 00 00   ................
325 |    240: 14 00 00 00 00 00 00 00 00 00 00 00 08 00 00 00   ................
326 |    256: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0f ec   ................
327 |    304: 00 00 00 00 19 08 05 17 17 17 17 65 69 67 68 74   ...........eight
328 |    320: 65 69 67 68 74 73 65 00 00 00 00 00 00 00 00 00   eightse.........
329 |    336: 00 00 00 00 19 08 05 17 17 17 17 65 69 67 68 74   ...........eight
330 |    352: 65 69 67 68 74 73 65 01 65 6e 00 00 00 10 25 07   eightse.en....%.
331 |    368: 07 6e 25 07 07 07 40 18 00 00 00 00 00 00 40 18   .n%...@.......@.
332 |    384: 00 00 00 00 00 00 40 14 00 00 00 00 00 00 40 14   ......@.......@.
333 |    400: 00 00 00 00 00 00 09 06 05 01 01 01 01 04 04 03   ................
334 |    416: 03 07 05 05 01 01 09 09 02 02 19 04 05 17 17 17   ................
335 |    432: 17 10 65 76 65 6e 65 69 67 68 74 65 69 67 68 74   ..eveneighteight
336 |    448: 73 65 76 65 6e 25 03 05 07 07 07 07 40 14 00 00   seven%......@...
337 |    464: 00 00 00 00 40 18 00 00 00 00 00 00 40 18 00 00   ....@.......@...
338 |    480: 00 00 00 00 40 14 00 00 00 00 e8 f6 09 02 00 00   ....@...........
339 |    496: 00 00 00 00 00 00 00 00 00 00 64 00 00 00 00 02   ..........d.....
340 | page 4 offset 1536
341 |      0: 0d 00 00 00 00 02 00 00 00 00 00 00 00 00 00 fa   ................
342 |     16: 1f a1 07 00 00 00 00 00 01 00 00 00 00 00 00 00   ................
343 |     32: 00 00 00 00 00 00 00 00 00 00 00 00 00 73 69 6d   .............sim
344 |     48: 70 6c 65 00 00 00 00 00 00 00 00 00 00 00 00 00   ple.............
345 |     80: 00 00 00 00 00 10 00 00 00 00 00 00 01 00 00 00   ................
346 |     96: 00 00 00 00 00 00 00 00 00 00 00 00 00 fe ff ff   ................
347 |    112: ff 00 00 00 00 00 00 00 00 00 00 00 4a 00 00 00   ............J...
348 |    144: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00   ................
349 |    176: e5 ff ff ff 00 00 00 00 00 00 00 00 00 00 00 00   ................
350 |    208: 00 00 00 00 00 00 00 00 00 00 36 36 00 00 00 00   ..........66....
351 |    240: 00 00 00 6c 00 00 00 00 00 00 00 00 00 00 00 00   ...l............
352 |    256: 00 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
353 |    320: 00 00 00 00 00 00 00 00 01 00 00 02 00 80 00 00   ................
354 |    336: 00 00 00 00 00 19 08 05 17 17 17 17 65 69 67 68   ............eigh
355 |    352: 74 65 69 67 68 74 73 65 76 65 6e 73 65 76 65 6e   teightsevenseven
356 |    368: 25 07 05 07 07 07 07 40 18 00 00 00 00 00 00 40   %......@.......@
357 |    384: 18 00 20 00 00 00 40 00 14 00 00 00 00 00 00 40   .. ...@........@
358 |    400: 14 00 00 00 00 00 1c 09 06 05 01 01 01 01 04 04   ................
359 |    416: 03 03 07 05 05 01 01 00 00 00 00 00 00 00 00 00   ................
360 |    448: 74 73 65 76 65 6e 00 80 ff ff 00 00 00 00 00 aa   tseven..........
361 |    464: 00 9e 00 00 00 00 00 00 00 00 00 00 00 70 6f 72   .............por
362 |    480: 74 65 72 00 00 00 00 00 00 00 00 00 00 00 00 00   ter.............
363 |    496: 00 00 00 00 00 00 29 00 00 00 00 00 00 00 00 00   ......).........
364 | page 5 offset 2048
365 |      0: 0a 00 00 00 08 01 96 00 01 fa 01 c5 01 f2 01 bc   ................
366 |     16: 01 dc 01 a6 01 96 01 cc 00 00 00 00 00 00 00 00   ................
367 |    112: 00 00 00 09 00 00 00 00 01 00 00 00 00 00 00 00   ................
368 |    160: 74 72 69 67 62 ff ff ff ff fc 00 00 00 00 00 00   trigb...........
369 |    240: 00 00 00 00 00 00 00 00 00 00 ff 00 00 00 00 00   ................
370 |    256: e5 ff ff ff 00 00 54 00 00 00 00 00 00 00 00 00   ......T.........
371 |    304: 00 00 00 00 00 00 09 00 00 00 00 00 00 00 00 00   ................
372 |    400: 00 00 00 00 00 09 00 00 00 00 01 00 00 00 00 00   ................
373 |    448: 00 00 74 72 69 67 62 ff ff ff ff fc 00 00 07 05   ..trigb.........
374 |    464: 05 01 01 09 09 02 02 19 04 05 17 17 17 17 10 65   ...............e
375 |    480: 76 65 6e 65 69 67 68 74 65 40 18 00 00 00 00 01   veneighte@......
376 |    496: 02 03 07 04 01 01 01 03 04 02 05 04 09 01 ff fd   ................
377 | end crash-6b48ba69806134.db
378 }]} {}
380 set res {1 {database disk image is malformed}}
381 ifcapable oversize_cell_check {
382   set res {1 {no such table: t3}}
384 do_catchsql_test 4.1 {
385   PRAGMA writable_schema=ON; -- bypass improved sqlite_master consistency checking
386   INSERT INTO t3 SELECT * FROM t2;
387 } $res
389 #-------------------------------------------------------------------------
390 reset_db
391 do_test 5.0 {
392   sqlite3 db {}
393   db deserialize [decode_hexdb {
394 | size 192512 pagesize 4096 filename crash-9ae5502296c949.db
395 | page 1 offset 0
396 |      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
397 |     16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 2f   .....@  ......./
398 |     32: 00 00 00 1b 00 00 00 13 00 00 00 03 00 00 00 04   ................
399 |     48: 00 00 00 00 00 00 00 06 00 00 00 01 00 00 00 00   ................
400 |     64: 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00   ................
401 |     96: 00 00 00 00 0d 00 00 00 04 0e e2 00 0f 96 0f 44   ...............D
402 |    112: 0f 10 0e e2 00 00 00 00 00 00 00 00 00 00 00 00   ................
403 |   3808: 00 00 2c 04 06 17 15 11 01 41 69 6e 64 65 78 74   ..,......Aindext
404 |   3824: 31 78 32 74 31 06 43 52 45 41 54 45 20 49 4e 44   1x2t1.CREATE IND
405 |   3840: 45 58 20 74 31 78 32 20 4f 4e 20 74 31 28 62 29   EX t1x2 ON t1(b)
406 |   3856: 32 03 06 17 15 11 01 4d 69 6e 64 65 78 74 31 78   2......Mindext1x
407 |   3872: 31 74 31 05 43 52 45 41 54 45 20 49 4e 44 45 58   1t1.CREATE INDEX
408 |   3888: 20 74 31 78 31 20 4f 4e 20 74 31 28 67 2b 68 2c    t1x1 ON t1(g+h,
409 |   3904: 6a 2c 6b 29 50 02 06 17 2b 2b 01 59 74 61 62 6c   j,k)P...++.Ytabl
410 |   3920: 65 73 71 6c 69 74 65 5f 73 65 71 75 65 6e 63 65   esqlite_sequence
411 |   3936: 73 71 6c 69 74 65 5f 73 65 71 75 65 6e 63 65 04   sqlite_sequence.
412 |   3952: 43 52 45 41 54 45 20 54 41 42 4c 45 20 73 71 6c   CREATE TABLE sql
413 |   3968: 69 74 65 5f 73 65 71 75 65 6e 63 65 28 6e 61 6d   ite_sequence(nam
414 |   3984: 65 2c 73 65 71 29 68 01 07 17 11 11 01 81 3b 74   e,seq)h.......;t
415 |   4000: 61 62 6c 65 74 31 74 31 03 43 52 45 41 54 45 20   ablet1t1.CREATE 
416 |   4016: 54 41 42 4c 45 20 74 31 28 61 20 49 4e 54 45 47   TABLE t1(a INTEG
417 |   4032: 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 20 41   ER PRIMARY KEY A
418 |   4048: 55 54 4f 49 4e 43 52 45 4d 45 4e 54 2c 0a 62 2c   UTOINCREMENT,.b,
419 |   4064: 63 2c 64 2c 65 2c 66 2c 67 2c 68 2c 6a 2c 6b 2c   c,d,e,f,g,h,j,k,
420 |   4080: 6c 2c 6d 2c 6e 2c 6f 2c 70 2c 71 2c 72 2c 73 29   l,m,n,o,p,q,r,s)
421 | page 2 offset 4096
422 |      0: 01 00 00 00 00 01 00 00 00 00 01 00 00 00 00 01   ................
423 |     16: 00 00 00 00 02 10 00 00 00 05 00 00 00 03 02 00   ................
424 |     32: 00 00 00 05 00 00 00 03 02 00 00 00 00 05 00 00   ................
425 |     48: 00 03 02 00 00 00 00 05 00 00 00 03 02 00 00 00   ................
426 |     64: 00 05 00 00 00 03 02 00 00 00 00 05 00 00 00 03   ................
427 |     80: 02 00 00 00 00 05 00 00 00 03 02 00 00 00 00 05   ................
428 |     96: 00 00 00 03 02 00 00 00 00 05 00 00 00 03 05 00   ................
429 |    112: 00 00 03 03 00 00 00 23 02 00 00 00 00 03 00 00   .......#........
430 |    128: 00 23 02 00 00 00 00 03 00 00 00 23 02 00 00 00   .#.........#....
431 |    144: 00 03 00 00 00 23 02 00 00 00 00 03 00 00 00 23   .....#.........#
432 |    160: 05 00 00 00 06 05 00 00 00 06 02 00 00 00 00 03   ................
433 |    176: 00 00 00 06 02 00 00 00 00 03 00 00 00 24 02 00   .............$..
434 |    192: 00 00 00 03 00 00 00 24 02 00 00 00 00 03 00 00   .......$........
435 |    208: 00 24 02 00 00 00 00 02 00 00 00 00 03 00 00 00   .$..............
436 |    224: 24 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   $...............
437 | page 3 offset 8192
438 |      0: 05 00 00 00 09 0f d0 00 00 00 00 19 0f fb 0f f6   ................
439 |     16: 0f f1 0f ec 0f e7 0f e2 0f dc 0f d6 0f d0 0f a0   ................
440 |     32: 0f a0 0f a0 0f a0 0f a0 0f a0 0f a0 0f a0 0f a0   ................
441 |   1072: 00 97 4c 0a 14 00 ae 7c 00 00 00 00 00 00 00 00   ..L....|........
442 |   1088: 00 00 00 00 00 00 00 09 00 00 00 00 00 00 00 00   ................
443 |   4000: 0f ac 00 06 00 00 00 00 00 30 00 00 00 00 00 00   .........0......
444 |   4048: 00 00 00 16 81 2a 00 00 00 14 81 16 00 00 00 12   .....*..........
445 |   4064: 81 02 00 00 00 10 6e 00 00 00 0e 5a 00 00 00 0c   ......n....Z....
446 |   4080: 46 00 00 00 0a 32 00 00 00 08 1e 00 00 00 18 0a   F....2..........
447 | page 4 offset 12288
448 |      0: 0d 00 00 00 01 0f f7 00 0f f7 00 00 00 00 00 00   ................
449 |   4080: 00 00 00 00 00 00 00 07 01 03 11 02 74 31 00 be   ............t1..
450 | page 5 offset 16384
451 |      0: 0a 0f 7c 00 0a 0f 74 00 0f f9 0f eb 0f dd 0f cf   ..|...t.........
452 |     16: 0f c1 0f b3 0f a4 0f 94 0f 84 0f 74 0f 74 0f 74   ...........t.t.t
453 |     32: 0f 74 0f 74 0f 74 0f 74 0f 74 0f 74 0f 74 00 00   .t.t.t.t.t.t.t..
454 |   3952: 00 00 00 00 07 05 00 00 00 02 00 be 0f 8c 00 08   ................
455 |   3968: 00 00 00 00 07 05 00 00 00 02 00 aa 0f 9c 00 08   ................
456 |   3984: 00 00 00 00 07 05 00 00 00 02 00 96 0f ac 00 08   ................
457 |   4000: 00 00 00 00 07 05 00 00 00 02 00 82 0f ba 00 07   ................
458 |   4016: 00 00 00 06 05 00 00 00 01 6e 0f c8 00 07 00 00   .........n......
459 |   4032: 00 06 05 00 00 00 01 5a 0f d6 00 07 00 00 00 06   .......Z........
460 |   4048: 05 00 00 00 01 46 0f e4 00 07 00 00 00 06 05 00   .....F..........
461 |   4064: 00 00 01 32 0f f2 00 07 00 00 00 06 05 00 00 00   ...2............
462 |   4080: 01 1e 00 00 00 07 00 00 00 06 05 00 00 00 01 0a   ................
463 | page 6 offset 20480
464 |      0: 02 00 00 00 01 0e 0d 00 00 00 00 24 0e 0d 0c 1a   ...........$....
465 |     16: 06 55 04 66 02 77 00 88 00 00 00 00 00 00 00 00   .U.f.w..........
466 |    128: 00 00 00 00 00 00 00 00 97 3d 04 ae 7c 01 00 00   .........=..|...
467 |    624: 00 00 00 00 00 00 21 97 3d 04 ae 7c 01 00 00 00   ......!.=..|....
468 |   1120: 00 00 00 00 00 20 97 3d 04 ae 7c 01 00 00 00 00   ..... .=..|.....
469 |   1616: 00 00 00 00 1f 97 3d 04 ae 7c 01 00 00 00 00 00   ......=..|......
470 |   2112: 00 00 00 1e 97 3d 04 ae 7c 01 00 00 00 00 00 00   .....=..|.......
471 |   2608: 00 00 1d 97 3d 04 ae 7c 01 00 00 00 00 00 00 00   ....=..|........
472 |   3088: 00 00 00 00 00 00 00 00 00 00 00 00 01 f3 00 00   ................
473 |   3600: 23 97 3d 04 ae 7c 01 00 00 00 00 00 00 00 00 00   #.=..|..........
474 |   4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 26   ...............&
475 | page 8 offset 28672
476 |      0: 0d 00 00 00 01 04 30 00 04 30 00 00 00 00 00 00   ......0..0......
477 |   1072: 97 4d 1e 14 00 ae 7c 00 00 00 00 00 00 00 00 00   .M....|.........
478 |   1088: 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00   ................
479 |   4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03   ................
480 | page 10 offset 36864
481 |    256: 0d 00 00 00 01 04 30 00 04 30 00 00 00 00 00 00   ......0..0......
482 |   1072: 97 4d 32 14 00 ae 7c 00 00 00 00 00 00 00 00 00   .M2...|.........
483 |   1088: 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00   ................
484 |   4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 05   ................
485 | page 12 offset 45056
486 |      0: 0d 00 00 00 01 04 30 00 04 30 00 00 00 00 00 00   ......0..0......
487 |   1072: 97 4d 46 14 00 ae 7c 00 00 00 00 00 00 00 00 00   .MF...|.........
488 |   1088: 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00   ................
489 |   4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 07   ................
490 | page 14 offset 53248
491 |      0: 0d 00 00 00 01 04 30 00 04 30 00 00 00 00 00 00   ......0..0......
492 |   1072: 97 4d 5a 14 00 ae 7c 00 00 00 00 00 00 00 00 00   .MZ...|.........
493 |   1088: 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00   ................
494 |   4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 09   ................
495 | page 16 offset 61440
496 |      0: 0d 00 00 00 01 04 30 00 04 30 00 00 00 00 00 00   ......0..0......
497 |   1072: 97 4d 6e 14 00 ae 7c 00 00 00 00 00 00 00 00 00   .Mn...|.........
498 |   1088: 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00   ................
499 |   4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0b   ................
500 | page 18 offset 69632
501 |      0: 0d 00 00 00 01 04 2f 00 04 2f 00 00 00 00 00 00   ....../../......
502 |   1056: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 97   ................
503 |   1072: 4d 81 02 14 00 ae 7c 00 00 00 00 00 00 00 00 00   M.....|.........
504 |   1088: 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00   ................
505 |   4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0d   ................
506 | page 20 offset 77824
507 |      0: 0d 00 00 00 01 04 2f 00 04 2f 00 00 00 00 00 00   ....../../......
508 |   1056: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 97   ................
509 |   1072: 4d 81 16 14 00 ae 7c 00 00 00 00 00 00 00 00 00   M.....|.........
510 |   1088: 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00   ................
511 |   4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0f   ................
512 | page 22 offset 86016
513 |      0: 0d 00 00 00 01 04 2f 00 04 2f 00 00 00 00 00 00   ....../../......
514 |   1056: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 97   ................
515 |   1072: 4d 81 2a 14 00 ae 7c 00 00 00 00 00 00 00 00 00   M.*...|.........
516 |   1088: 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00   ................
517 |   4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 11   ................
518 | page 24 offset 94208
519 |      0: 0d 00 00 00 01 04 31 00 04 31 00 00 00 00 00 00   ......1..1......
520 |   1072: 00 97 4c 0a 14 00 ae 7c 00 00 00 00 00 00 00 00   ..L....|........
521 |   1088: 00 00 00 00 00 00 00 09 00 00 00 00 00 00 00 00   ................
522 | page 25 offset 98304
523 |      0: 0d 00 00 00 01 04 2f 00 04 2f 00 00 00 00 00 00   ....../../......
524 |   1056: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 97   ................
525 |   1072: 4d 81 3e 14 00 ae 7c 00 00 00 00 00 00 00 00 00   M.>...|.........
526 |   1088: 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00   ................
527 |   4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 13   ................
528 | page 26 offset 102400
529 |   2512: 00 00 00 00 00 00 00 0a 00 00 00 00 00 00 00 00   ................
530 | page 27 offset 106496
531 |      0: 00 00 00 00 00 00 00 12 00 00 00 07 00 00 00 1d   ................
532 |     16: 00 00 00 09 00 00 00 1f 00 00 00 0b 00 00 00 21   ...............!
533 |     32: 00 00 00 0d 00 00 00 25 00 00 00 0f 00 00 00 19   .......%........
534 |     48: 00 00 00 11 00 00 00 29 00 00 00 13 00 00 00 2b   .......).......+
535 |     64: 00 00 00 15 00 00 00 2d 00 00 00 2e 00 00 00 17   .......-........
536 | page 28 offset 110592
537 |   2512: 00 00 00 00 00 00 00 1e 00 00 00 00 00 00 00 00   ................
538 | page 30 offset 118784
539 |   2512: 00 00 00 00 00 00 00 32 00 00 00 00 00 00 00 00   .......2........
540 | page 32 offset 126976
541 |   2512: 00 00 00 00 00 00 00 46 00 00 00 00 00 00 00 00   .......F........
542 | page 34 offset 135168
543 |   2512: 00 00 00 00 00 00 00 5a 00 00 00 00 00 00 00 00   .......Z........
544 | page 35 offset 139264
545 |      0: 0a 08 44 00 05 02 77 00 0e 11 0a 33 06 55 02 77   ..D...w....3.U.w
546 |     16: 04 66 00 88 00 88 00 88 00 00 00 00 00 00 00 00   .f..............
547 |    128: 00 00 00 00 00 00 00 00 04 66 01 ef 00 00 00 00   .........f......
548 |    624: 00 00 00 00 00 00 00 97 3d 04 ae 7c 01 00 00 00   ........=..|....
549 |   1120: 00 00 00 00 00 20 97 3d 04 ae 7c 01 00 00 00 00   ..... .=..|.....
550 |   1616: 00 00 00 00 22 97 3d 04 ae 7c 01 00 00 00 00 00   ......=..|......
551 |   2112: 00 00 00 1e 0c 22 01 ef 00 00 00 00 00 00 00 00   ................
552 |   2608: 00 00 00 97 3d 04 ae 7c 01 00 00 00 00 00 00 00   ....=..|........
553 |   3104: 00 1c 00 00 01 ef 00 00 00 00 00 00 00 00 00 00   ................
554 |   3600: 00 97 3d 04 ae 7c 01 00 00 00 00 00 00 00 00 00   ..=..|..........
555 |   4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1a   ................
556 | page 36 offset 143360
557 |      0: 0a 08 44 00 04 02 77 00 06 55 02 77 04 66 0e 11   ..D...w..U.w.f..
558 |     16: 00 88 00 88 00 88 0e 11 00 00 00 00 00 00 00 00   ................
559 |    128: 00 00 00 00 00 00 00 00 04 76 01 ef 00 00 00 00   .........v......
560 |    624: 00 00 00 00 00 00 00 97 3e 04 ae 7c 02 00 00 00   ........>..|....
561 |   1120: 00 00 00 00 00 2a 97 3e 04 ae 7c 02 00 00 00 00   .....*.>..|.....
562 |   1616: 00 00 00 00 2c 97 3e 04 ae 7c 02 00 00 00 00 00   ....,.>..|......
563 |   2112: 00 00 00 28 00 00 05 cd 00 00 00 00 00 00 00 00   ...(............
564 |   3600: 00 97 3e 04 ae 7c 02 00 00 00 00 00 00 00 00 00   ..>..|..........
565 |   4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2f   .............../
566 | page 38 offset 151552
567 |   2512: 00 00 00 00 00 00 00 6e 00 00 00 00 00 00 00 00   .......n........
568 | page 40 offset 159744
569 |   2512: 00 00 00 00 00 00 00 00 82 00 00 00 00 00 00 00   ................
570 | page 42 offset 167936
571 |   2512: 00 00 00 00 00 00 00 00 96 00 00 00 00 00 00 00   ................
572 | page 44 offset 176128
573 |   2512: 00 00 00 00 00 00 00 00 aa 00 00 00 00 00 00 00   ................
574 | page 47 offset 188416
575 |   2512: 00 00 00 00 00 00 00 00 be 00 00 00 00 00 00 00   ................
576 | end crash-9ae5502296c949.db
577 }]} {}
579 do_catchsql_test 5.1 {
580   INSERT INTO t1(b) VALUES(zeroblob(40000));
581 } {1 {database disk image is malformed}}
583 do_catchsql_test 5.2 {
584   DROP INDEX t1x2;
585 } {0 {}}
587 do_catchsql_test 5.3 {
588   INSERT INTO t1(b) VALUES(zeroblob(40000));
589 } {1 {database disk image is malformed}}
591 #-------------------------------------------------------------------------
592 reset_db
593 do_test 6.0 {
594   sqlite3 db {}
595   db deserialize [decode_hexdb {
596 | size 20480 pagesize 4096 filename crash-d260f001fa015c.db
597 | page 1 offset 0
598 |      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
599 |     16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 05   .....@  ........
600 |     32: 00 00 00 00 00 ff ff f0 00 00 00 02 00 00 00 04   ................
601 |     48: 00 00 00 00 00 00 00 64 00 00 00 01 00 00 00 00   .......d........
602 |     96: 00 00 00 00 0d 0f f8 00 04 0e ce 00 0f 4c 0f d3   .............L..
603 |    112: 0e fa 0e ce 00 00 00 00 00 00 00 00 00 00 00 00   ................
604 |   3776: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2a 04   ..............*.
605 |   3792: 06 17 13 11 01 3f 69 6e 64 65 78 74 31 62 74 31   .....?indext1bt1
606 |   3808: 05 43 52 45 41 54 45 20 49 4e 44 45 58 20 74 31   .CREATE INDEX t1
607 |   3824: 62 20 4f 4e 20 74 31 28 62 29 50 03 06 17 2b 2b   b ON t1(b)P...++
608 |   3840: 01 59 74 61 62 6c 65 73 71 6c 69 74 65 5f 73 65   .Ytablesqlite_se
609 |   3856: 71 75 65 6e 63 65 73 71 6c 69 74 65 5f 73 65 71   quencesqlite_seq
610 |   3872: 75 65 6e 63 65 04 43 52 45 41 54 45 20 54 41 42   uence.CREATE TAB
611 |   3888: 4c 45 20 73 71 6c 69 74 65 5f 73 65 71 75 65 6e   LE sqlite_sequen
612 |   3904: 63 65 28 6e 61 6d 65 2c 73 65 71 29 81 04 01 07   ce(name,seq)....
613 |   3920: 17 11 11 01 81 73 74 61 62 6c 65 74 31 74 31 02   .....stablet1t1.
614 |   3936: 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31 28   CREATE TABLE t1(
615 |   3952: 61 20 52 45 41 4c 20 4e 4f 54 20 4e 55 4c 4c 20   a REAL NOT NULL 
616 |   3968: 44 45 46 41 55 4c 54 28 32 35 2b 33 32 29 2c 62   DEFAULT(25+32),b
617 |   3984: 20 46 4c 4f 41 54 2c 63 20 44 4f 55 42 4c 45 20    FLOAT,c DOUBLE 
618 |   4000: 55 4e 49 51 55 45 2c 0a 64 20 43 4c 4f 42 2c 65   UNIQUE,.d CLOB,e
619 |   4016: 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59    INTEGER PRIMARY
620 |   4032: 20 4b 45 59 20 41 55 54 4f 49 4e 43 52 45 4d 45    KEY AUTOINCREME
621 |   4048: 4e 54 29 23 02 06 17 37 11 01 00 69 6e 64 65 78   NT)#...7...index
622 |   4064: 73 71 6c 69 74 65 5f 61 75 74 6f 69 6e 64 65 78   sqlite_autoindex
623 |   4080: 5f 74 31 5f 31 74 31 05 00 00 00 08 00 00 00 00   _t1_1t1.........
624 | page 2 offset 4096
625 |      0: 0d 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00   ................
626 | page 3 offset 8192
627 |      0: 0a 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00   ................
628 | page 4 offset 12288
629 |      0: 0d 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00   ................
630 | page 5 offset 16384
631 |      0: 0a 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00   ................
632 | end crash-d260f001fa015c.db
633 }]} {}
635 do_catchsql_test 6.1 {
636   BEGIN;
637     INSERT INTO t1(b) VALUES(1);
638     INSERT INTO t1(b) VALUES(2);
639   COMMIT;
640 } {1 {malformed database schema (t1b) - invalid rootpage}}
642 #-------------------------------------------------------------------------
643 reset_db
644 do_test 7.0 {
645   sqlite3 db {}
646   db deserialize [decode_hexdb {
647 | size 20480 pagesize 4096 filename crash-8391315d75edff.db
648 | page 1 offset 0
649 |      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
650 |     16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 05   .....@  ........
651 |     32: 00 00 00 00 00 00 00 00 00 00 00 05 00 00 00 04   ................
652 |     48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00   ................
653 |     96: 00 00 00 00 0d 00 00 00 05 0e 55 00 0f 74 0f 3c   ..........U..t.<
654 |    112: 0e f9 0e d1 0e 55 00 00 00 00 00 00 00 00 00 00   .....U..........
655 |   3664: 00 00 00 00 00 7a 05 07 15 11 11 08 81 63 76 69   .....z.......cvi
656 |   3680: 65 77 76 31 76 31 43 52 45 41 54 45 20 56 49 45   ewv1v1CREATE VIE
657 |   3696: 57 20 76 31 28 78 2c 69 29 20 41 53 0a 53 45 4c   W v1(x,i) AS.SEL
658 |   3712: 45 43 54 20 74 31 2e 62 2c 74 32 2e 62 20 46 52   ECT t1.b,t2.b FR
659 |   3728: 4f 4d 20 74 31 2c 74 32 20 57 48 45 52 45 20 74   OM t1,t2 WHERE t
660 |   3744: 31 2e 61 3d 74 32 2e 61 20 47 52 4f 55 50 20 42   1.a=t2.a GROUP B
661 |   3760: 59 20 31 20 48 41 56 49 4e 47 20 74 32 2e 63 20   Y 1 HAVING t2.c 
662 |   3776: 4e 4f 54 20 4e 55 4c 4c 0a 4c 49 4d 49 54 20 31   NOT NULL.LIMIT 1
663 |   3792: 30 26 04 06 17 11 11 01 39 74 61 62 6c 65 74 32   0&......9tablet2
664 |   3808: 74 32 05 43 52 45 41 54 45 20 54 41 42 4c 45 20   t2.CREATE TABLE 
665 |   3824: 74 32 28 61 2c 62 2c 63 29 41 03 06 17 15 11 01   t2(a,b,c)A......
666 |   3840: 6b 69 6e 64 65 78 74 31 78 31 74 31 03 43 52 45   kindext1x1t1.CRE
667 |   3856: 41 54 45 20 49 4e 44 45 58 20 74 31 78 31 20 4f   ATE INDEX t1x1 O
668 |   3872: 4e 20 74 31 28 64 29 20 57 48 45 52 45 20 65 65   N t1(d) WHERE ee
669 |   3888: 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 36 02 06 17    IS NOT NULL6...
670 |   3904: 17 11 01 53 69 6e 64 65 78 74 31 61 62 63 74 31   ...Sindext1abct1
671 |   3920: 03 43 52 45 41 54 45 20 49 4e 44 45 58 20 74 31   .CREATE INDEX t1
672 |   3936: 61 62 63 20 4f 4e 20 74 31 28 61 2c 62 2c 63 2b   abc ON t1(a,b,c+
673 |   3952: 64 2b 65 29 81 09 01 07 17 11 11 01 81 7d 74 61   d+e)..........ta
674 |   3968: 62 6c 65 74 31 74 31 02 43 52 45 41 54 45 20 54   blet1t1.CREATE T
675 |   3984: 41 42 4c 45 20 74 31 28 61 2c 62 2c 63 2c 64 2c   ABLE t1(a,b,c,d,
676 |   4000: 65 2c 66 2c 67 2c 68 2c 6a 2c 6a 6a 2c 6a 6a 6a   e,f,g,h,j,jj,jjj
677 |   4016: 2c 6b 2c 61 61 2c 62 69 8c 63 63 2c 64 64 2c 65   ,k,aa,bi.cc,dd,e
678 |   4032: 65 20 44 45 46 41 55 4c 54 20 33 2e 31 34 2c 0a   e DEFAULT 3.14,.
679 |   4048: 66 66 20 44 45 46 41 55 4c 54 28 27 68 69 63 63   ff DEFAULT('hicc
680 |   4064: 75 70 27 29 2c 67 67 20 4e 4f 54 20 4e 55 4c 4c   up'),gg NOT NULL
681 |   4080: 20 44 45 46 41 55 4c 54 28 66 61 6c 73 65 29 29    DEFAULT(false))
682 | page 2 offset 4096
683 |      0: 0d 00 00 00 0a 0e 7b 00 0f dc 0f b6 0f 8f 0f 68   ...............h
684 |     16: 0f 41 0f 1a 0e f3 0e cb 0e a3 0e 22 00 00 00 00   .A..............
685 |   3696: 00 00 00 00 00 00 00 00 00 00 00 26 0a 14 01 01   ...........&....
686 |   3712: 02 08 00 00 00 00 00 00 00 00 00 00 00 00 07 19   ................
687 |   3728: 08 09 5a 00 b4 40 09 1e b8 51 eb 95 1f 68 69 63   ..Z..@...Q...hic
688 |   3744: 63 75 70 26 09 14 01 01 02 08 00 00 00 00 00 00   cup&............
689 |   3760: 00 00 00 00 00 00 07 19 08 08 50 00 a0 40 09 1e   ..........P..@..
690 |   3776: b8 51 eb 85 1f 68 69 63 63 74 70 26 08 14 01 01   .Q...hicctp&....
691 |   3792: 03 08 00 00 00 00 00 00 00 00 00 00 00 00 07 19   ................
692 |   3808: 08 07 46 00 8c 40 09 1e b8 51 eb 85 1f 68 69 63   ..F..@...Q...hic
693 |   3824: 63 75 70 25 07 14 01 01 01 08 00 00 00 00 00 00   cup%............
694 |   3840: 00 00 00 00 00 10 07 19 08 06 3c 78 40 09 1e b8   ..........<x@...
695 |   3856: 51 eb 85 1f 68 69 63 63 75 70 25 06 14 01 01 01   Q...hiccup%.....
696 |   3872: 08 00 00 00 00 00 00 00 00 00 00 00 00 07 19 08   ................
697 |   3888: 05 32 64 40 09 1e b8 51 eb 85 1f 68 69 63 63 75   .2d@...Q...hiccu
698 |   3904: 70 25 05 14 01 01 01 08 00 00 00 00 00 00 00 00   p%..............
699 |   3920: 00 00 00 00 07 19 08 04 28 50 40 09 1e b8 51 eb   ........(P@...Q.
700 |   3936: 85 1f 68 69 63 63 75 70 25 04 14 01 00 f1 08 00   ..hiccup%.......
701 |   3952: 00 00 00 00 00 00 00 00 00 00 00 07 19 08 03 1e   ................
702 |   3968: 3c 40 09 1e b8 51 eb 85 1f 68 69 63 63 75 70 25   <@...Q...hiccup%
703 |   3984: 03 14 01 01 01 08 00 00 00 00 00 00 00 00 00 00   ................
704 |   4000: 00 00 07 19 08 02 14 28 40 09 1e b8 51 eb 85 1f   .......(@...Q...
705 |   4016: 68 69 63 63 75 70 24 02 14 09 01 01 08 00 00 00   hiccup$.........
706 |   4032: 00 00 00 00 00 00 00 00 00 07 19 08 0a 14 40 09   ..............@.
707 |   4048: 1e b8 51 eb 85 1f 68 69 63 63 75 70 22 01 14 08   ..Q...hiccup....
708 |   4064: 08 08 08 00 00 00 00 00 00 00 00 00 00 00 00 07   ................
709 |   4080: 19 08 40 09 1e b8 51 eb 85 1f 68 69 63 63 75 70   ..@...Q...hiccup
710 | page 3 offset 8192
711 |      0: 0a 00 00 00 0a 0f aa 00 0f fa 0f f2 0f e9 0f e0   ................
712 |     16: 0f d7 0f ce 0f c5 0f bc 0f b3 0f aa 00 00 00 00   ................
713 |   4000: 00 00 00 00 00 00 00 00 00 00 08 05 01 01 00 01   ................
714 |   4016: 09 5a 0a d8 05 01 01 00 01 08 50 09 08 05 01 01   .Z........P.....
715 |   4032: 00 01 07 46 08 08 05 01 01 00 01 06 3c 07 08 05   ...F........<...
716 |   4048: 01 01 00 01 05 32 06 08 05 01 01 00 01 04 28 05   .....2........(.
717 |   4064: 08 05 01 02 60 01 03 1e 04 08 05 01 01 00 01 02   ....`...........
718 |   4080: 14 03 07 05 09 01 00 01 0a 02 05 05 08 08 00 09   ................
719 | page 4 offset 12288
720 |      0: 0a 00 00 00 0a 0f cf 00 0f fc 0f f7 0f f2 0f ed   ................
721 |     16: 0f e8 0f e3 0f de 0f d9 0f d4 0f cf 00 00 00 00   ................
722 |   4032: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04   ................
723 |   4048: 03 08 01 0a 04 03 08 01 09 04 03 08 01 08 04 03   ................
724 |   4064: 08 01 07 04 03 08 01 06 04 03 08 01 05 04 03 08   ................
725 |   4080: 01 04 04 03 08 01 03 04 03 08 01 02 03 03 08 09   ................
726 | page 5 offset 16384
727 |      0: 0d 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00   ................
728 | end crash-8391315d75edff.db
729 }]} {}
731 do_catchsql_test 7.1 {
732   SELECT * FROM sqlite_master;
733 } {1 {malformed database schema (t1x1) - invalid rootpage}}
735 #-------------------------------------------------------------------------
736 reset_db
737 do_test 8.0 {
738   sqlite3 db {}
739   db deserialize [decode_hexdb {
740 | size 2048 pagesize 512 filename a.db
741 | page 1 offset 0
742 |      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
743 |     16: 02 00 01 01 00 40 20 20 ff ff 00 0c 00 00 00 07   .....@  ........
744 |     32: 0b 00 00 00 00 00 00 00 00 00 00 08 9c 00 00 04   ................
745 |     48: 00 00 00 e0 09 00 00 01 00 00 00 01 00 00 00 00   ................
746 |     64: 00 00 00 00 f2 ff 00 00 00 00 00 00 00 00 00 00   ................
747 |     80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0c   ................
748 |     96: 00 2e 2c 50 0d 00 00 00 06 01 06 00 01 da 01 b0   ..,P............
749 |    112: 05 56 01 86 01 2a 01 06 00 00 00 00 00 06 00 00   .V...*..........
750 |    128: 00 ff 00 00 ff ff ff e1 00 00 00 00 00 00 00 00   ................
751 |    144: 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00   ................
752 |    160: 00 00 00 00 00 00 00 00 f2 00 00 00 00 00 00 00   ................
753 |    176: 00 00 f9 ff ff ff ff ff ff ff 00 00 00 5f 00 fb   ............._..
754 |    192: 00 00 00 00 00 00 00 00 00 e1 ff 00 00 00 00 00   ................
755 |    208: 00 00 10 00 00 00 00 00 1e 00 00 00 fe 00 00 00   ................
756 |    224: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ca 00   ................
757 |    240: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 35   ...............5
758 |    256: 00 00 00 00 ef ff 22 07 06 17 11 11 01 30 39 38   .............098
759 |    272: 62 6c 65 74 38 38 74 04 43 52 45 41 54 45 20 54   blet88t.CREATE T
760 |    288: 41 42 4c 45 20 74 34 28 87 29 2a 06 06 17 13 11   ABLE t4(.)*.....
761 |    304: 01 3f 69 4f 64 65 78 74 33 78 74 40 05 43 52 45   .?iOdext3xt@.CRE
762 |    320: 41 54 45 20 49 6e 44 45 58 20 74 33 78 20 4f 4e   ATE InDEX t3x ON
763 |    336: 20 74 33 28 78 29 2e 04 06 17 15 11 01 45 69 6e    t3(x).......Ein
764 |    352: 00 04 00 00 34 63 64 74 3d 05 43 52 45 41 54 45   ....4cdt=.CREATE
765 |    368: 20 49 4e 44 45 58 20 63 74 64 32 20 4f 4e 20 74    INDEX ctd2 ON t
766 |    384: 32 28 0a 0c 44 29 28 05 06 17 11 11 01 3d 74 6c   2(..D)(......=tl
767 |    400: 62 61 d4 65 33 74 33 04 43 52 45 41 54 45 20 54   ba.e3t3.CREATE T
768 |    416: 41 42 4c 45 20 74 33 28 63 2c 78 2c 65 2c 66 29   ABLE t3(c,x,e,f)
769 |    432: 28 02 06 17 11 11 01 3d 74 61 62 6c 65 74 32 74   (......=tablet2t
770 |    448: 32 03 43 52 45 41 54 45 20 54 41 42 4c 45 20 74   2.CREATE TABLE t
771 |    464: 32 28 63 2c 64 2c 65 2c 66 29 24 01 06 17 11 11   2(c,d,e,f)$.....
772 |    480: 01 35 74 60 62 6c 65 74 31 74 31 02 43 52 45 41   .5t`blet1t1.CREA
773 |    496: 54 45 20 54 41 42 4c 45 20 74 30 28 61 2c 62 29   TE TABLE t0(a,b)
774 | page 2 offset 512
775 |      0: 0d 00 ff 11 04 01 cf 80 01 fa 01 09 00 de 01 cf   ................
776 |     16: 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00   ................
777 |     32: 00 00 08 00 00 00 00 00 00 11 00 00 00 00 00 13   ................
778 |     48: 00 00 00 00 00 00 00 00 00 00 00 01 00 e0 ff ff   ................
779 |     64: ff d2 ff ff ff 00 f8 ff ff ff 00 00 00 00 00 00   ................
780 |     80: 00 ff ff 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
781 |     96: 00 00 00 00 ff de 00 00 00 00 00 00 00 00 00 00   ................
782 |    112: 00 00 00 00 00 00 00 00 00 00 00 00 00 40 00 00   .............@..
783 |    128: 2a 00 00 00 00 00 00 00 00 f7 00 00 00 00 00 00   *...............
784 |    144: 00 00 00 00 00 21 00 00 00 00 00 00 00 00 00 00   .....!..........
785 |    160: 01 64 00 00 00 00 04 80 ff ff ff 00 00 00 00 00   .d..............
786 |    176: 00 00 00 00 00 00 00 00 1f 00 00 00 00 00 00 00   ................
787 |    192: 00 00 40 00 00 00 00 00 00 00 00 00 00 00 00 00   ..@.............
788 |    208: b5 00 00 00 00 00 00 40 00 00 00 00 00 00 00 00   .......@........
789 |    224: 00 00 00 f6 00 ee ff ff ff 00 00 00 00 00 00 00   ................
790 |    272: f2 00 00 00 00 00 00 00 00 00 f9 ff ff ff ff ff   ................
791 |    288: ff ff 00 00 00 5f 00 fb 00 00 00 00 00 00 00 00   ....._..........
792 |    320: 1e 00 00 00 fe 00 00 00 00 00 00 00 00 00 00 00   ................
793 |    336: 00 00 00 00 00 00 ca 00 00 00 00 00 00 00 ff ec   ................
794 |    352: 00 00 00 00 00 00 00 32 00 00 00 00 ef ff 22 07   .......2........
795 |    368: 06 17 11 11 01 30 74 61 62 6c 65 74 38 38 74 04   .....0tablet88t.
796 |    384: 43 52 45 41 54 45 20 54 41 42 4c 45 20 8c cb d7   CREATE TABLE ...
797 |    400: 78 d6 d5 f9 f9 17 13 11 01 3f 69 4f 64 65 78 74   x........?iOdext
798 |    416: 33 78 74 33 05 43 52 45 41 54 45 26 49 6e 44 45   3xt3.CREATE&InDE
799 |    432: 58 20 74 33 78 00 00 00 00 00 00 00 00 00 00 00   X t3x...........
800 |    464: 00 00 00 00 00 13 76 65 6e 65 69 67 68 74 13 03   ......veneight..
801 |    480: 03 40 07 07 15 00 54 45 20 49 4e 44 45 58 20 74   .@....TE INDEX t
802 |    496: 31 63 64 20 4f 4e 20 74 ce d7 f5 f0 44 09 01 02   1cd ON t....D...
803 | page 3 offset 1024
804 |      0: 0d 00 00 00 48 01 54 00 01 f6 e2 ec 01 c5 01 aa   ....H.T.........
805 |     16: 30 34 28 87 29 32 06 f5 16 13 11 01 8e 61 24 64   04(.)2.......a$d
806 |     32: 65 78 74 37 78 1f 33 6d 6d 6d 6d 6d 00 00 04 06   ext7x.3mmmmm....
807 |     48: 6d 41 6d 6d 6e 6d 6d 00 00 02 00 6d 6d 6d 6d 6d   mAmmnmm....mmmmm
808 |     64: 15 11 01 45 45 45 45 45 45 45 45 45 45 45 45 45   ...EEEEEEEEEEEEE
809 |     80: 45 45 45 45 45 45 45 45 45 45 45 00 45 63 74 64   EEEEEEEEEEE.Ectd
810 |     96: 34 20 4f 4e 20 61 62 6c 5d 74 38 38 74 04 43 52   4 ON abl]t88t.CR
811 |    112: 45 41 54 45 20 54 41 42 4c 45 20 74 34 28 87 29   EATE TABLE t4(.)
812 |    128: 2a 06 06 13 13 01 00 00 00 4f 64 6e 78 74 33 44   *........Odnxt3D
813 |    144: 74 13 05 43 52 45 41 54 45 20 49 6e 44 45 00 00   t..CREATE InDE..
814 |    160: 00 00 00 00 00 00 00 f9 ff ff ff ff ff ff ff 00   ................
815 |    176: 00 00 5f 00 fb 00 00 2d 00 00 00 00 00 00 00 00   .._....-........
816 |    192: 00 00 00 00 00 00 00 00 00 00 00 00 00 1e 00 00   ................
817 |    208: 00 fe 00 00 00 00 17 15 11 01 45 69 6e 64 65 2e   ..........Einde.
818 |    224: 5b 38 63 64 74 3d 05 43 52 45 41 54 45 20 49 4e   [8cdt=.CREATE IN
819 |    240: 44 45 58 20 63 20 64 32 20 4f 4e 20 74 32 28 0a   DEX c d2 ON t2(.
820 |    256: 0c 44 32 05 00 10 00 00 11 11 3d 74 6c 62 61 d4   .D2.......=tlba.
821 |    272: 65 33 74 33 04 43 52 45 41 54 45 20 54 41 42 4c   e3t3.CREATE TABL
822 |    288: 45 20 74 36 ff ff 7f ff 43 52 45 41 54 45 20 49   E t6....CREATE I
823 |    304: 73 71 6c 69 74 65 5f 73 65 71 75 65 6e 63 65 28   sqlite_sequence(
824 |    320: 0a 0c 44 29 28 05 06 17 11 11 01 3d 74 6c 62 61   ..D)(......=tlba
825 |    336: 20 00 00 00 33 04 43 52 45 41 54 45 20 54 41 42    ...3.CREATE TAB
826 |    352: 4c 45 20 74 33 28 63 2c 78 2c 65 2c 66 29 28 02   LE t3(c,x,e,f)(.
827 |    368: 06 00 00 7f ff 40 41 54 45 20 49 6e 44 45 58 20   .....@ATE InDEX 
828 |    384: 74 33 78 20 4f 4e 20 74 31 28 78 29 2e 04 06 17   t3x ON t1(x)....
829 |    400: 15 11 01 45 69 6e 64 65 2e 74 34 63 64 74 3d 05   ...Einde.t4cdt=.
830 |    416: 00 00 00 00 00 00 00 00 00 00 00 4d 00 00 00 00   ...........M....
831 |    432: 01 00 00 00 00 00 00 05 00 00 10 00 00 00 00 00   ................
832 |    448: 00 01 00 00 00 00 01 00 00 00 00 07 40 14 00 00   ............@...
833 |    464: 00 00 21 00 40 18 00 00 00 00 00 00 40 1c 00 00   ..!.@.......@...
834 |    480: 00 00 ff ff ff 00 00 00 5f 00 fb 00 00 2d 00 00   ........_....-..
835 |    496: 00 00 00 1e 00 00 00 fe 00 00 64 00 00 ff fb 02   ..........d.....
836 | page 4 offset 1536
837 |      0: 0d 00 39 00 00 02 00 00 00 00 00 00 00 00 00 00   ..9.............
838 | end a.db
839 }]} {}
841 set res {1 {database disk image is malformed}}
842 ifcapable oversize_cell_check {
843   set res {1 {no such table: t3}}
845 do_catchsql_test 8.1 {
846   PRAGMA writable_schema=ON; -- bypass improved sqlite_master consistency checking
847   INSERT INTO t3 SELECT * FROM t2;
848 } $res
850 #-------------------------------------------------------------------------
851 reset_db
852 do_test 9.0 {
853   sqlite3 db {}
854   db deserialize [decode_hexdb {
855 | size 8192 pagesize 4096 filename crash-ab10597e4e1c32.db
856 | page 1 offset 0
857 |      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
858 |     16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 00   .....@  ........
859 |     96: 00 00 00 00 0d 00 00 00 01 0f d6 00 0f d6 00 00   ................
860 |   4048: 00 00 00 00 00 00 28 01 06 17 11 11 01 3d 74 61   ......(......=ta
861 |   4064: 62 6c 65 74 31 74 31 02 43 52 45 41 54 45 20 54   blet1t1.CREATE T
862 |   4080: 41 42 4c 45 20 74 31 28 61 2c 62 2c 63 2c 64 29   ABLE t1(a,b,c,d)
863 | page 2 offset 4096
864 |      0: 0d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
865 | end crash-ab10597e4e1c32.db
866 }]} {}
868 do_execsql_test 9.1 {
869   SAVEPOINT one;
871 do_catchsql_test 9.3 {
872   INSERT INTO t1(b,c) VALUES(5,6);
873 } {1 {database disk image is malformed}}
874 do_execsql_test 9.3 {
875   ROLLBACK TO one;
878 #-------------------------------------------------------------------------
879 reset_db
880 do_test 10.0 {
881   sqlite3 db {}
882   db deserialize [decode_hexdb {
883 | size 180224 pagesize 4096 filename crash-41390d95d613b6.db
884 | page 1 offset 0
885 |      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
886 |     16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 00   .....@  ........
887 |     96: 00 00 00 00 0d 00 00 00 04 0e e2 00 0f 96 0f 44   ...............D
888 |    112: 0f 10 0e e2 00 00 00 00 00 00 00 00 00 00 00 00   ................
889 |   3808: 00 00 2c 14 06 17 15 11 01 41 69 6e 64 65 78 74   ..,......Aindext
890 |   3824: 41 78 33 74 31 06 43 52 45 41 54 45 20 49 4e 44   Ax3t1.CREATE IND
891 |   3840: 45 58 20 74 31 78 32 20 4f 4e 20 74 31 28 62 29   EX t1x2 ON t1(b)
892 |   3856: 32 03 06 17 15 11 01 4d 69 6e 64 65 78 74 31 88   2......Mindext1.
893 |   3872: 31 74 31 05 43 52 45 41 54 45 20 49 4e 44 45 58   1t1.CREATE INDEX
894 |   3888: 20 74 31 78 31 20 4f 4e 20 74 31 28 67 2b 68 2c    t1x1 ON t1(g+h,
895 |   3904: 6a 2d 6b 29 50 02 06 17 2b 2b 01 59 74 61 62 6c   j-k)P...++.Ytabl
896 |   3920: 65 73 71 6c 69 74 65 5e 73 65 71 74 65 6e 63 65   esqlite^seqtence
897 |   3936: 73 71 6c 69 74 65 5f 73 65 71 75 65 6e 63 65 04   sqlite_sequence.
898 |   3952: 43 52 45 41 54 45 20 54 41 42 4c 45 20 73 71 6c   CREATE TABLE sql
899 |   3968: 69 74 65 5f 73 65 71 75 65 6e 63 65 28 6e 61 6d   ite_sequence(nam
900 |   3984: 65 2c 73 65 71 29 68 00 07 17 11 11 01 81 3b 74   e,seq)h.......;t
901 |   4000: 61 62 6c 65 74 31 74 31 03 43 52 45 41 54 45 20   ablet1t1.CREATE 
902 |   4016: 54 41 42 4c 45 20 74 31 28 61 20 49 4e 54 45 47   TABLE t1(a INTEG
903 |   4032: 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 20 41   ER PRIMARY KEY A
904 |   4048: 55 54 4f 49 4e 43 52 45 4d 45 4e 54 2c 0a 62 2c   UTOINCREMENT,.b,
905 |   4064: 63 2c 64 2c 65 2c 66 2c 67 2c 68 2c 6a 2c 6b 2c   c,d,e,f,g,h,j,k,
906 |   4080: 6c 2c 6d 2c 6e 2c 6f 2c 70 2c 71 2c 72 2c 73 29   l,m,n,o,p,q,r,s)
907 | page 2 offset 4096
908 |      0: 01 00 00 00 00 01 00 00 10 00 01 00 00 00 00 01   ................
909 |     16: 00 00 00 00 02 00 0f f0 00 15 00 00 00 03 02 00   ................
910 |     32: 00 00 d9 05 00 00 00 03 02 00 00 00 00 05 00 00   ................
911 |     48: 10 03 02 00 00 00 00 05 00 00 00 03 02 00 00 00   ................
912 |     64: 00 05 00 00 00 02 62 00 00 00 00 05 00 00 00 03   ......b.........
913 |     80: 02 00 00 00 00 05 00 00 00 03 02 00 00 00 00 05   ................
914 |     96: 00 00 00 03 02 00 00 00 00 05 00 00 00 03 05 00   ................
915 |    112: 00 00 03 03 01 00 00 23 02 00 00 4f 00 02 00 00   .......#...O....
916 |    128: 10 25 02 00 00 00 00 03 00 00 00 23 02 00 00 00   .%.........#....
917 |    144: 00 03 00 00 00 23 02 00 00 00 00 03 00 00 00 23   .....#.........#
918 |    160: 05 00 08 90 06 05 00 00 00 06 01 ff 00 00 00 03   ................
919 |    176: 00 00 00 06 02 00 00 00 00 02 ff 00 00 00 00 00   ................
920 | page 3 offset 8192
921 |      0: 05 00 00 00 09 0f d0 00 00 00 00 19 0f fb 0f f6   ................
922 |     16: 0f f1 10 ec ec e7 0f e2 0f dc 0f d6 0f 00 00 00   ................
923 |   1072: 00 97 4c 0a 24 00 ae 00 00 00 00 00 00 00 00 00   ..L.$...........
924 |   4048: 00 00 00 16 83 39 ff ff ff 14 81 16 00 00 00 12   .....9..........
925 |   4064: 81 02 00 00 00 10 6e 00 00 00 0e 5a 00 00 00 0c   ......n....Z....
926 |   4080: 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   F...............
927 | page 4 offset 12288
928 |   1072: 97 4d 32 14 00 ae 00 00 00 00 00 00 00 00 00 00   .M2.............
929 |   4080: 00 00 00 00 00 00 00 07 01 03 11 02 74 31 00 bd   ............t1..
930 | page 5 offset 16384
931 |      0: fa 0f 7c 00 0a 0f 74 00 0f f9 0f eb 0f dd 0f cf   ..|...t.........
932 |     16: 0f c1 0f b3 0f a4 0e 94 0f 84 0f 74 0f 74 0f 74   ...........t.t.t
933 |     32: 0f 74 0f 64 0f 00 00 00 00 00 00 00 00 00 00 00   .t.d............
934 |   3952: 00 00 00 00 07 05 00 00 00 02 00 be 0f 8c 10 07   ................
935 |   3968: ff ff 00 00 07 05 00 00 00 02 00 aa 0f 9b f0 08   ................
936 |   3984: c8 00 00 00 37 06 00 00 00 01 00 96 0f ac 00 08   ....7...........
937 |   4000: 00 00 00 b3 07 15 00 10 00 02 00 82 0f ba 00 07   ................
938 |   4016: 00 00 00 06 05 00 00 00 01 6e 0f c8 00 07 00 00   .........n......
939 |   4032: 00 06 05 00 00 00 01 5a 03 f6 00 07 00 00 00 06   .......Z........
940 |   4048: 05 00 00 00 01 46 0f e4 00 07 00 00 10 06 05 00   .....F..........
941 |   4064: 00 00 01 32 10 02 00 07 00 00 00 07 05 00 00 00   ...2............
942 |   4080: 01 1d ff ff ff 07 10 00 00 06 05 00 00 00 01 0a   ................
943 | page 6 offset 20480
944 |    624: 00 00 00 00 00 21 97 00 00 00 00 00 00 00 00 00   .....!..........
945 |   1120: 00 00 00 00 00 24 57 3e 00 00 00 00 00 00 00 00   .....$W>........
946 |   1616: 00 00 00 00 1f 97 00 00 00 00 00 00 00 00 00 00   ................
947 |   2112: 00 00 00 1e 97 3d 00 00 00 00 00 00 00 00 00 00   .....=..........
948 |   2608: 00 1d 97 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
949 | page 8 offset 28672
950 |   1184: 00 00 00 00 00 00 00 00 00 97 4d 1e 13 ff ae 7c   ..........M....|
951 |   4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 90   ................
952 | page 9 offset 32768
953 |    256: 0d 01 c0 00 01 04 30 00 04 30 00 00 00 00 00 00   ......0..0......
954 | page 10 offset 36864
955 |      0: 0d 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
956 |   4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 05   ................
957 | page 12 offset 45056
958 |      0: 0d 00 00 00 01 04 30 00 00 00 00 00 00 00 00 00   ......0.........
959 | page 14 offset 53248
960 |      0: 0d 00 00 00 01 04 30 00 04 30 00 00 00 00 00 00   ......0..0......
961 |   1072: 96 4d 5a 14 00 00 00 00 00 00 00 00 00 00 00 00   .MZ.............
962 | page 16 offset 61440
963 |      0: 0d 00 00 00 01 04 30 00 04 30 00 00 00 00 00 00   ......0..0......
964 |   1072: 97 4d 6e 14 00 ae 7b ff ff ff ff 00 00 00 00 00   .Mn.............
965 | page 18 offset 69632
966 |   1056: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 97   ................
967 |   1072: 4d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   M...............
968 |   4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0d   ................
969 | page 20 offset 77824
970 |   1056: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 97   ................
971 |   1072: 4d 81 16 14 00 ae 00 00 00 00 00 00 00 00 00 00   M...............
972 |   4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0f   ................
973 | page 22 offset 86016
974 |      0: 0d 00 00 00 01 04 2f 00 04 2f 01 00 00 00 00 00   ....../../......
975 |   1056: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 97   ................
976 |   1072: 4d 81 2a 14 00 00 00 00 00 00 00 00 00 00 00 00   M.*.............
977 | page 24 offset 94208
978 |   1072: 00 97 4c 0a 14 00 ae 7c 00 00 00 00 00 00 00 00   ..L....|........
979 | page 25 offset 98304
980 |   1056: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 97   ................
981 |   1072: 4d 81 3e 14 00 ae 7c 00 00 18 ff 00 00 00 00 00   M.>...|.........
982 | page 27 offset 106496
983 |      0: 00 00 00 00 00 00 00 12 00 00 00 07 00 00 00 1d   ................
984 |     16: 00 00 00 09 00 00 00 1f 00 00 00 0b 00 00 00 21   ...............!
985 |     32: 00 00 00 0d 00 10 00 25 00 00 00 0f 00 00 00 27   .......%.......'
986 |     48: 00 00 00 11 00 00 00 00 00 00 00 00 00 00 00 00   ................
987 | page 32 offset 126976
988 |   2512: 00 00 00 00 00 00 00 45 21 00 00 00 00 00 00 00   .......E!.......
989 | page 35 offset 139264
990 |      0: 00 0a 08 44 00 05 02 77 00 0e 11 0a 92 00 00 00   ...D...w........
991 |   1120: 00 00 00 00 00 20 97 00 00 00 00 00 00 00 00 00   ..... ..........
992 |   1616: 00 00 00 00 22 00 00 00 00 00 00 00 00 00 00 00   ................
993 |   2608: 00 00 00 97 3d 04 00 00 00 00 00 00 00 00 00 00   ....=...........
994 |   3104: 00 1c 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
995 |   3600: 00 97 3d 04 ae 7c 00 00 00 00 00 00 00 00 00 00   ..=..|..........
996 |   4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1a   ................
997 | page 36 offset 143360
998 |      0: 0a 08 44 00 04 02 00 00 00 00 00 00 00 00 00 00   ..D.............
999 |   1120: 00 00 00 00 00 2a 97 3e 04 00 00 00 00 00 00 00   .....*.>........
1000 |   1616: 00 00 00 00 2c 97 3e 00 00 00 00 00 00 00 00 00   ....,.>.........
1001 |   2112: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 38   ...............8
1002 |   2128: 00 00 05 cd 00 00 00 00 00 00 00 00 00 00 00 00   ................
1003 |   3600: 00 97 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
1004 | page 38 offset 151552
1005 |   2464: 00 00 00 00 00 00 00 00 00 6e 00 00 00 00 00 00   .........n......
1006 | page 40 offset 159744
1007 |   2512: 00 00 00 00 00 00 00 00 82 00 00 00 00 00 00 00   ................
1008 | page 42 offset 167936
1009 |   2512: 00 00 00 00 00 00 00 96 00 00 00 00 00 00 00 00   ................
1010 | page 44 offset 176128
1011 |   2512: 00 00 00 00 00 00 00 00 aa 00 00 00 00 00 00 00   ................
1012 | end crash-41390d95d613b6.db
1013 }]} {}
1015 do_catchsql_test 10.1 {
1016   PRAGMA writable_schema=ON; -- bypass improved sqlite_master consistency checking
1017   SELECT * FROM t1 WHERE a<='2019-05-09' ORDER BY a DESC;
1018 } {1 {database disk image is malformed}}
1021 #-------------------------------------------------------------------------
1022 reset_db
1023 do_test 11.0 {
1024   sqlite3 db {}
1025   db deserialize [decode_hexdb {
1026 | size 595 pagesize 512 filename x.db
1027 | page 1 offset 0
1028 |      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
1029 |     16: 02 00 00 01 00 40 20 20 00 01 00 0c 00 00 00 07   .....@  ........
1030 |     32: 00 00 00 05 07 a1 1f fa 00 00 00 08 00 00 00 04   ................
1031 |     48: 00 00 01 00 00 49 00 00 00 00 00 05 00 00 00 00   .....I..........
1032 |     80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1c   ................
1033 |     96: 00 2e 2c 50 0d 00 00 00 06 01 06 00 01 da 01 b0   ..,P............
1034 |    112: 01 56 01 86 01 2a 01 06 00 00 62 00 00 00 00 00   .V...*....b.....
1035 |    128: 00 ed e2 78 74 64 33 ff 43 52 45 41 54 45 20 49   ...xtd3.CREATE I
1036 |    144: 4e 44 45 58 20 74 33 78 20 4f 4e 20 74 33 28 38   NDEX t3x ON t3(8
1037 |    160: 29 2e 04 06 17 15 11 01 45 69 6e 64 65 68 74 32   ).......Eindeht2
1038 |    176: 63 64 74 31 e5 43 52 45 41 54 45 20 49 4e 44 45   cdt1.CREATE INDE
1039 |    192: 58 20 74 32 63 c4 20 4f 4e 20 74 32 28 63 2c 64   X t2c. ON t2(c,d
1040 |    208: 29 28 05 06 17 01 11 11 3d 74 61 6c 36 74 62 74   )(......=tal6tbt
1041 |    224: 65 32 04 43 52 45 41 54 45 20 54 41 42 4c 45 20   e2.CREATE TABLE 
1042 |    240: 74 00 04 00 00 00 00 00 00 00 00 00 00 00 00 00   t...............
1043 |    256: 00 00 00 00 00 00 22 07 06 17 11 11 01 30 e8 03   .............0..
1044 |    272: 62 6c 65 74 34 74 35 02 43 52 45 41 54 45 20 54   blet4t5.CREATE T
1045 |    288: 41 42 4c 45 20 74 34 28 94 29 2a 06 06 17 13 11   ABLE t4(.)*.....
1046 |    304: 01 3f 69 33 74 6e 65 78 78 74 64 33 ff 43 52 45   .?i3tnexxtd3.CRE
1047 |    320: 41 54 45 20 49 4e 44 45 58 20 74 33 78 20 4f 4e   ATE INDEX t3x ON
1048 |    336: 20 74 31 28 38 29 2e 04 06 17 15 11 01 45 69 6e    t1(8).......Ein
1049 |    352: 64 65 68 74 32 63 64 74 31 e5 43 52 45 41 54 45   deht2cdt1.CREATE
1050 |    368: 20 49 4e 44 45 58 20 74 32 63 c4 20 4f 4e 20 74    INDEX t2c. ON t
1051 |    384: 32 28 63 2c 64 29 28 05 06 17 01 11 11 3d 74 61   2(c,d)(......=ta
1052 |    400: 6c 32 74 62 74 65 32 04 43 52 45 41 54 45 20 54   l2tbte2.CREATE T
1053 |    416: 41 42 4c 45 20 74 33 28 63 2c 78 2c 65 2c 66 29   ABLE t3(c,x,e,f)
1054 |    432: 28 02 06 17 11 11 01 3d 74 61 9e 93 65 74 32 74   (......=ta..et2t
1055 |    448: 32 03 43 52 45 41 54 45 20 54 41 42 4c 45 20 74   2.CREATE TABLE t
1056 |    464: 32 28 63 2c 64 2c 65 2c 66 29 24 01 06 17 11 11   2(c,d,e,f)$.....
1057 |    480: 01 35 55 61 62 6c 88 74 31 74 31 02 43 52 45 41   .5Uabl.t1t1.CREA
1058 |    496: 54 45 20 54 41 42 4c 45 20 74 31 28 61 2c 62 29   TE TABLE t1(a,b)
1059 | page 2 offset 512
1060 |      0: 0d 00 00 00 0d 25 00 01 cf 00 01 fa 01 f3 01 de   .....%..........
1061 |     16: 01 00 00 00 fd 00 00 0d 00 00 00 00 45 20 54 41   ............E TA
1062 |     32: 42 4c 45 20 74 34 28 94 29 2a 06 06 17 13 11 01   BLE t4(.)*......
1063 |     48: 3f 69 33 74 6e 65 78 78 74 64 33 ff 43 52 45 a0   ?i3tnexxtd3.CRE.
1064 |     64: a0 a0 a0 a0 a0 a0 a0 a0 a0 a0 a0 a0 74 13 11 01   ............t...
1065 |     80: 49 45 74 00 00 00 00 00 00 00 00 00 00 00 00 00   IEt.............
1066 | end x.db
1067 }]} {}
1069 do_catchsql_test 11.1 {
1070   PRAGMA writable_schema=ON; -- bypass improved sqlite_master consistency checking
1071   DELETE FROM t3 WHERE x IN (SELECT x FROM t4);
1072 } {1 {database disk image is malformed}}
1074 #-------------------------------------------------------------------------
1075 reset_db
1076 do_test 12.0 {
1077   sqlite3 db {}
1078   db deserialize [decode_hexdb {
1079 | size 12288 pagesize 4096 filename crash-e6d070858a3a85.db
1080 | page 1 offset 0
1081 |      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
1082 |     16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 00   .....@  ........
1083 |     96: 00 00 00 00 0d 00 00 00 02 0f 8f 00 0f bf 0f 8f   ................
1084 |   3968: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2e   ................
1085 |   3984: 02 06 17 15 11 01 45 69 6e 64 65 78 74 31 63 62   ......Eindext1cb
1086 |   4000: 74 31 03 43 52 45 41 54 45 20 49 4e 44 45 58 20   t1.CREATE INDEX 
1087 |   4016: 74 31 63 62 20 4f 4e 20 74 31 28 63 2c 62 29 3f   t1cb ON t1(c,b)?
1088 |   4032: 01 06 17 11 11 01 6b 74 61 62 6c 65 74 31 74 31   ......ktablet1t1
1089 |   4048: 02 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31   .CREATE TABLE t1
1090 |   4064: 28 61 20 49 4e 54 2c 20 62 20 49 4e 54 2c 20 43   (a INT, b INT, C
1091 |   4080: 20 49 4e 54 20 44 45 46 41 55 4c 54 20 31 36 29    INT DEFAULT 16)
1092 | page 2 offset 4096
1093 |      0: 0d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
1094 |   4000: 00 00 00 00 00 00 00 00 07 0b 04 01 01 01 63 63   ..............cc
1095 |   4016: 11 05 0a 04 00 00 01 11 05 09 04 08 08 01 0f 05   ................
1096 |   4032: 08 04 00 00 01 01 56 07 04 01 08 01 07 10 07 06   ......V.........
1097 |   4048: 14 01 01 01 06 08 10 06 05 04 f5 00 01 05 10 07   ................
1098 |   4064: 04 04 01 01 01 04 03 10 06 03 04 01 09 01 03 10   ................
1099 |   4080: 06 02 04 01 00 01 02 10 06 01 04 09 01 01 02 10   ................
1100 | page 3 offset 8192
1101 |      0: 0a 00 00 00 0b 0f b0 00 0f f9 0f f2 0f eb 0f e4   ................
1102 |     16: 0f dd 0f d6 0f 9f 0f c7 0f be 00 00 00 00 00 00   ................
1103 |   4016: 07 04 01 01 01 11 e2 0b 06 04 91 00 01 11 0a 07   ................
1104 |   4032: 04 01 01 01 10 08 06 07 04 01 01 01 10 04 04 06   ................
1105 |   4048: 04 01 01 09 10 02 06 04 01 0a 01 10 00 00 00 00   ................
1106 | end crash-e6d070858a3a85.db
1107 }]} {}
1109 do_catchsql_test 12.1 {
1110   SELECT CAST((SELECT b FROM t1 WHERE 16=c) AS int) FROM t1 WHERE 16=c;
1111 } {1 {database disk image is malformed}}
1113 #-------------------------------------------------------------------------
1114 reset_db
1115 do_test 13.0 {
1116   sqlite3 db {}
1117   db deserialize [decode_hexdb {
1118 | size 8192 pagesize 4096 filename crash-81dd2952aef34f.db
1119 | page 1 offset 0
1120 |      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
1121 |     16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 02   .....@  ........
1122 |     32: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 04   ................
1123 |     48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00   ................
1124 |     96: 00 00 00 00 0d 00 00 00 01 0f c4 00 0f c4 00 00   ................
1125 |   4032: 00 00 00 00 3a 11 06 17 11 11 01 61 74 61 62 6c   ....:......atabl
1126 |   4048: 65 74 31 74 31 02 43 52 45 41 54 45 20 54 41 42   et1t1.CREATE TAB
1127 |   4064: 4c 45 20 74 31 28 61 20 49 4e 54 45 47 45 52 20   LE t1(a INTEGER 
1128 |   4080: 50 52 49 4d 41 52 59 20 4b 45 59 2c 62 2c 63 29   PRIMARY KEY,b,c)
1129 | page 2 offset 4096
1130 |      0: 0d 07 70 00 02 0f eb 00 0f fa 00 00 00 00 00 00   ..p.............
1131 |   4064: 00 00 00 00 00 00 00 00 00 00 00 05 bf ff ff ff   ................
1132 |   4080: ff ff ff ff ff 04 00 01 00 02 04 01 00 00 00 00   ................
1133 | end crash-81dd2952aef34f.db
1134 }]} {}
1136 do_catchsql_test 13.1 {
1137   WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x-2019 FROM c WHERE x<2)
1138     INSERT INTO t1(b,c) SELECT last_insert_rowid(), x FROM c;
1139 } {1 {database disk image is malformed}}
1141 #-------------------------------------------------------------------------
1142 reset_db
1143 do_test 14.0 {
1144   sqlite3 db {}
1145   db deserialize [decode_hexdb {
1146 | size 512 pagesize 65536 filename clusterfuzz-testcase-minimized-sqlite3_dbfuzz2_fuzzer-4806406219825152
1147 | page 1 offset 0
1148 |      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
1149 |     16: 00 01 02 01 00 40 20 20 00 63 2e 78 00 00 00 07   .....@  .c.x....
1150 |     32: 00 00 00 00 00 00 00 00 00 00 00 08 00 00 00 04   ................
1151 |     48: 00 00 00 00 00 00 01 00 35 05 43 00 04 00 00 00   ........5.C.....
1152 |     80: 00 00 00 00 00 00 00 00 08 00 00 00 00 00 00 0c   ................
1153 |     96: 00 2e 2c 50 0d 00 00 00 03 00 00 00 01 da 01 b0   ..,P............
1154 |    112: 01 56 01 86 01 2a 01 02 00 00 00 00 00 00 00 1c   .V...*..........
1155 |    128: 00 38 80 b2 e6 0e 00 00 00 00 00 00 00 00 00 10   .8..............
1156 |    144: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01   ................
1157 |    160: 00 00 00 00 00 00 00 00 00 00 00 00 45 20 54 41   ............E TA
1158 |    256: 00 00 00 00 00 00 22 07 06 17 11 11 01 35 74 61   .............5ta
1159 |    272: 62 6c 00 10 00 00 34 07 43 52 54 45 20 54 41 42   bl....4.CRTE TAB
1160 |    288: 4c 45 20 74 33 28 63 2e 78 2c 65 2c 66 15 28 3a   LE t3(c.x,e,f.(:
1161 |    304: 06 17 11 11 01 65 78 8c cc 87 85 35 05 43 72 45   .....ex....5.CrE
1162 |    320: 41 54 48 20 49 4e 44 45 58 20 74 33 78 20 4f 4e   ATH INDEX t3x ON
1163 |    336: 20 74 33 28 78 39 2e 04 06 17 15 11 01 45 69 6e    t3(x9.......Ein
1164 |    352: 64 65 78 74 32 63 64 74 32 05 43 52 45 41 54 45   dext2cdt2.CREATE
1165 |    368: 20 49 4e 44 45 58 20 74 32 63 64 20 4f 4e 20 74    INDEX t2cd ON t
1166 |    384: 32 28 63 2a 44 29 28 05 fa e8 ee ed 01 3d 74 63   2(c*D)(......=tc
1167 |    400: 62 6c 65 74 33 74 33 07 43 52 45 41 54 45 20 54   blet3t3.CREATE T
1168 |    416: 41 42 4c 45 20 74 33 28 63 2e 78 2c 65 2c 66 15   ABLE t3(c.x,e,f.
1169 |    432: 28 3a 06 17 11 11 01 3d 74 61 62 6c 65 74 32 74   (:.....=tablet2t
1170 |    448: 32 03 43 52 45 41 54 45 20 54 41 42 4c 45 20 74   2.CREATE TABLE t
1171 |    464: 32 28 63 2c 64 2c 65 2c 66 29 24 01 06 17 11 11   2(c,d,e,f)$.....
1172 |    480: 01 35 74 61 62 6c 65 74 31 74 31 02 43 52 45 41   .5tablet1t1.CREA
1173 |    496: 54 45 20 54 41 42 4c 45 20 74 31 28 61 2c 63 29   TE TABLE t1(a,c)
1174 | end clusterfuzz-testcase-minimized-sqlite3_dbfuzz2_fuzzer-4806406219825152
1175 }]} {}
1177 extra_schema_checks 0
1178 do_catchsql_test 14.1 {
1179   PRAGMA integrity_check;
1180 } {1 {database disk image is malformed}}
1182 # If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
1183 ifcapable altertable {
1184   do_catchsql_test 14.2 {
1185     ALTER TABLE t1 RENAME TO alkjalkjdfiiiwuer987lkjwer82mx97sf98788s9789s; 
1186   } {1 {database disk image is malformed}}
1188 extra_schema_checks 1
1190 #-------------------------------------------------------------------------
1191 reset_db
1192 do_test 15.0 {
1193   sqlite3 db {}
1194   db deserialize [decode_hexdb {
1195 | size 28672 pagesize 4096 filename crash-3afa1ca9e9c1bd.db
1196 | page 1 offset 0
1197 |      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
1198 |     16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 07   .....@  ........
1199 |     32: 00 00 00 00 00 00 00 00 00 00 00 06 00 00 00 04   ................
1200 |     48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00   ................
1201 |     96: 00 00 00 00 0d 00 00 00 06 0e 88 00 0f b8 0f 6d   ...............m
1202 |    112: 0f 3a 0f 0b 0e d5 0e 88 01 00 00 00 00 00 00 00   .:..............
1203 |   3712: 00 00 00 00 00 00 00 00 4b 06 06 17 25 25 01 5b   ........K...%%.[
1204 |   3728: 74 61 62 6c 65 73 71 6c 69 74 65 5f 73 74 61 74   tablesqlite_stat
1205 |   3744: 31 73 71 6c 69 74 65 5f 73 74 61 74 31 07 43 52   1sqlite_stat1.CR
1206 |   3760: 45 41 54 45 20 54 41 42 4c 45 20 73 71 6c 69 74   EATE TABLE sqlit
1207 |   3776: 65 5f 73 74 61 74 31 28 74 62 6c 2c 69 64 78 2c   e_stat1(tbl,idx,
1208 |   3792: 73 74 61 74 29 34 05 06 17 13 11 01 53 69 6e 64   stat)4......Sind
1209 |   3808: 65 78 63 31 63 63 31 06 43 52 45 41 54 45 20 55   exc1cc1.CREATE U
1210 |   3824: 4e 49 51 55 45 20 49 4e 44 45 58 20 63 31 63 20   NIQUE INDEX c1c 
1211 |   3840: 4f 4e 20 63 31 28 63 2c 20 62 29 2d 04 06 17 13   ON c1(c, b)-....
1212 |   3856: 11 01 45 69 6e 64 65 78 63 31 64 63 31 05 43 52   ..Eindexc1dc1.CR
1213 |   3872: 45 41 54 45 20 49 4e 44 45 58 20 63 31 64 20 4f   EATE INDEX c1d O
1214 |   3888: 4e 20 63 31 28 64 2c 20 62 29 31 03 06 17 13 11   N c1(d, b)1.....
1215 |   3904: 01 4d 69 6e 64 65 78 62 31 63 62 31 05 43 52 45   .Mindexb1cb1.CRE
1216 |   3920: 41 54 45 20 55 4e 49 51 55 45 20 49 4e 44 45 58   ATE UNIQUE INDEX
1217 |   3936: 20 62 31 63 20 4f 4e 20 62 31 28 63 29 49 02 06    b1c ON b1(c)I..
1218 |   3952: 17 11 11 0f 7f 74 61 62 6c 65 63 31 63 31 03 43   .....tablec1c1.C
1219 |   3968: 52 45 41 54 45 20 54 41 42 4c 45 20 63 31 28 61   REATE TABLE c1(a
1220 |   3984: 20 49 4e 54 20 50 52 49 4d 41 52 59 20 4b 45 59    INT PRIMARY KEY
1221 |   4000: 2c 20 62 2c 20 63 2c 20 64 29 20 57 49 54 48 4f   , b, c, d) WITHO
1222 |   4016: 55 54 20 52 4f 57 49 44 46 01 06 17 11 11 01 79   UT ROWIDF......y
1223 |   4032: 74 61 62 6c 65 62 31 62 31 02 43 52 45 41 54 45   tableb1b1.CREATE
1224 |   4048: 20 54 41 42 4c 45 20 62 31 28 61 20 49 4e 54 20    TABLE b1(a INT 
1225 |   4064: 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 2c 20   PRIMARY KEY, b, 
1226 |   4080: 63 29 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44   c) WITHOUT ROWID
1227 | page 2 offset 4096
1228 |      0: 0a 00 00 00 07 0f ca 00 0f fa 0f f2 0f ea 0f e2   ................
1229 |     16: 0f da 00 00 00 01 00 00 00 00 00 00 00 00 00 00   ................
1230 |   4032: 00 00 00 00 00 00 00 00 00 00 07 04 01 0f 01 06   ................
1231 |   4048: 67 07 07 04 01 0f 01 06 66 06 07 04 01 0f 01 05   g.......f.......
1232 |   4064: 65 05 07 04 01 0f 01 04 64 04 07 04 01 0f 01 03   e.......d.......
1233 |   4080: 63 03 07 04 01 0f 01 02 62 0f 05 04 09 0f 09 61   c.......b......a
1234 | page 3 offset 8192
1235 |      0: 0a 00 00 00 07 0f bd 00 0f f9 0f ef 0f e5 0f db   ................
1236 |     16: 0f d1 0f c7 0f bd 00 00 00 00 01 00 00 00 00 00   ................
1237 |   4016: 00 00 00 00 00 00 00 00 00 00 00 00 00 09 05 01   ................
1238 |   4032: 0f 01 01 07 61 07 07 09 05 01 0f 01 01 06 61 06   ....a.........a.
1239 |   4048: 06 09 05 01 0f 01 01 05 61 05 05 09 05 01 0f 01   ........a.......
1240 |   4064: 01 04 61 04 04 09 05 01 0f 01 01 03 61 03 03 09   ..a.........a...
1241 |   4080: 05 01 0f 01 01 02 61 0f 02 06 05 09 0f 09 09 61   ......a........a
1242 | page 4 offset 12288
1243 |      0: 0a 00 00 00 07 0f d8 00 0f fc 0f f0 0f ea 0f e4   ................
1244 |     16: 0f de 0f d8 0f f6 00 00 00 00 00 00 00 00 00 00   ................
1245 |   4048: 00 00 00 00 00 00 00 00 05 03 01 01 07 07 05 03   ................
1246 |   4064: 01 01 06 06 05 03 01 01 05 05 05 03 01 01 04 04   ................
1247 |   4080: 05 03 01 01 03 03 05 03 01 01 0f 02 03 03 09 09   ................
1248 | page 5 offset 16384
1249 |      0: 0a 00 00 00 07 0f ca 00 0f fa 0f f2 0f ea 0f 00   ................
1250 |   4032: 00 00 00 00 00 00 00 00 00 00 07 04 01 0f 01 07   ................
1251 |   4048: 61 07 07 04 01 0f 01 06 61 06 07 04 01 0f 01 05   a.......a.......
1252 |   4064: 61 05 07 04 01 1f 01 04 61 04 07 04 01 0f 01 03   a.......a.......
1253 |   4080: 61 03 07 04 01 0f 01 02 61 02 05 04 09 0f 09 61   a.......a......a
1254 | page 6 offset 20480
1255 |      0: 0a 00 00 00 07 0f ca 00 0f fa 0f ea 0f e2 00 00   ................
1256 |   4032: 00 00 00 00 00 00 00 00 00 00 07 04 01 0f 01 07   ................
1257 |   4048: 61 07 07 04 01 0f 01 06 61 06 07 04 01 0f 01 05   a.......a.......
1258 |   4064: 61 05 07 04 01 0f 01 04 61 04 07 04 01 0f 01 03   a.......a.......
1259 |   4080: 61 03 07 04 01 0f 01 0f 61 02 05 04 09 0f 09 61   a.......a......a
1260 | page 7 offset 24576
1261 |      0: 0d 00 00 00 05 0f 1c 00 0f f0 0f e0 0f d3 0f c5   ................
1262 |     16: 0f b8 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
1263 |   4016: 00 00 00 00 00 00 00 00 0b 05 04 11 11 13 62 31   ..............b1
1264 |   4032: 62 31 37 20 31 0c 04 04 11 13 13 62 31 62 31 63   b17 1......b1b1c
1265 |   4048: 37 20 31 0b 03 04 11 11 13 63 31 63 31 37 20 31   7 1......c1c17 1
1266 |   4064: 0e 02 04 11 13 07 63 31 63 31 64 37 20 31 20 31   ......c1c1d7 1 1
1267 |   4080: 0e 01 04 11 13 17 63 31 63 31 63 37 20 31 00 00   ......c1c1c7 1..
1268 | end crash-3afa1ca9e9c1bd.db
1269 }]} {}
1271 extra_schema_checks 0
1272 optimization_control db one-pass off
1273 do_catchsql_test 15.1 {
1274   PRAGMA cell_size_check = 0;
1275   UPDATE c1 SET c= NOT EXISTS(SELECT 1 FROM c1 ORDER BY (SELECT 1 FROM c1 ORDER BY a)) +10 WHERE d BETWEEN 4 AND 7;
1276 } {1 {database disk image is malformed}}
1277 extra_schema_checks 1
1278 do_execsql_test 15.2 {
1279   PRAGMA integrity_check;
1280 } {/in database main/}
1282 #-------------------------------------------------------------------------
1283 reset_db
1284 do_execsql_test 16.0 {
1285   CREATE TABLE t1(w, x, y, z, UNIQUE(w, x), UNIQUE(y, z));
1286   INSERT INTO t1 VALUES(1, 1, 1, 1);
1288   CREATE TABLE t1idx(x, y, i INTEGER, PRIMARY KEY(x)) WITHOUT ROWID;
1289   INSERT INTO t1idx VALUES(10, NULL, 5);
1291   PRAGMA writable_schema = 1;
1292   UPDATE sqlite_master SET rootpage = (
1293     SELECT rootpage FROM sqlite_master WHERE name='t1idx'
1294   ) WHERE type = 'index';
1297 extra_schema_checks 0
1298 db close
1299 sqlite3 db test.db
1300 extra_schema_checks 1
1302 do_catchsql_test 16.1 {
1303   PRAGMA writable_schema = ON;
1304   INSERT INTO t1(rowid, w, x, y, z) VALUES(5, 10, 11, 10, NULL);
1305 } {1 {database disk image is malformed}}
1307 #-------------------------------------------------------------------------
1308 # Test that corruption is reported from within a checkpoint if the 
1309 # expected final size of the database (according to the last commit
1310 # frame in the wal file) is greater than the combined initial sizes 
1311 # of the database and wal file.
1313 if {[wal_is_capable]} {
1314   reset_db
1315   do_execsql_test 17.0 {
1316     CREATE TABLE t1(o INTEGER PRIMARY KEY, t UNIQUE);
1317     INSERT INTO t1(t) VALUES(randomblob(123));
1318     INSERT INTO t1(t) SELECT randomblob(123) FROM t1;
1319     INSERT INTO t1(t) SELECT randomblob(123) FROM t1;
1320     INSERT INTO t1(t) SELECT randomblob(123) FROM t1;
1321     INSERT INTO t1(t) SELECT randomblob(123) FROM t1;
1322     INSERT INTO t1(t) SELECT randomblob(123) FROM t1;
1323     INSERT INTO t1(t) SELECT randomblob(123) FROM t1;
1324     INSERT INTO t1(t) SELECT randomblob(123) FROM t1;
1325     INSERT INTO t1(t) SELECT randomblob(123) FROM t1;
1326     INSERT INTO t1(t) SELECT randomblob(123) FROM t1;
1327   
1328     PRAGMA journal_mode = wal;
1329     INSERT INTO t1 VALUES(-1, 'b');
1330   } {wal}
1331   
1332   do_test 17.1 {
1333     set fd [open test.db r+]
1334     chan truncate $fd 2048
1335     file size test.db
1336   } {2048}
1337   
1338   do_catchsql_test 17.2 {
1339     PRAGMA wal_checkpoint
1340   } {1 {database disk image is malformed}}
1341   
1342   do_test 17.3 {
1343     close $fd
1344   } {}
1347 #-------------------------------------------------------------------------
1348 reset_db
1349 do_test 18.0 {
1350   sqlite3 db {}
1351   db deserialize [decode_hexdb {
1352 .open --hexdb
1353 | size 12288 pagesize 4096 filename crash-40d5739835cbdb.db
1354 | page 1 offset 0
1355 |      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
1356 |     16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 00   .....@  ........
1357 |     96: 00 00 00 00 0d 00 00 00 02 0f 4e 00 0f a2 0f 4e   ..........N....N
1358 |   3904: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 52 02   ..............R.
1359 |   3920: 07 17 11 11 01 81 0f 74 61 62 6c 65 74 32 74 32   .......tablet2t2
1360 |   3936: 03 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 32   .CREATE TABLE t2
1361 |   3952: 28 61 20 49 4e 54 2c 20 62 20 49 4e 54 45 47 45   (a INT, b INTEGE
1362 |   3968: 52 2c 20 50 52 49 4d 41 52 59 20 4b 45 59 28 61   R, PRIMARY KEY(a
1363 |   3984: 2c 62 29 29 20 57 49 54 48 4f 55 54 20 52 4f 57   ,b)) WITHOUT ROW
1364 |   4000: 49 44 5c 01 07 16 11 11 01 81 23 74 61 62 6c 65   ID........#table
1365 |   4016: 74 31 74 31 02 43 52 45 41 54 45 20 54 41 42 4c   t1t1.CREATE TABL
1366 |   4032: 45 20 74 31 28 61 20 49 4e 54 20 50 52 49 4d 41   E t1(a INT PRIMA
1367 |   4048: 52 59 20 4b 45 59 2c 20 62 20 54 45 58 54 2c 20   RY KEY, b TEXT, 
1368 |   4064: 63 20 54 45 58 54 2c 20 64 20 49 4e 54 45 47 45   c TEXT, d INTEGE
1369 |   4080: 52 29 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44   R) WITHOUT ROWID
1370 | page 2 offset 4096
1371 |      0: 0a 00 00 00 06 0f a7 00 0f f4 0f e5 0f d5 0f c5   ................
1372 |     16: 0f b6 0f 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
1373 |   4000: 00 00 00 00 00 00 00 0f 05 01 15 13 01 06 65 7f   ..............e.
1374 |   4016: 25 6e 73 69 78 06 0e 05 01 13 15 03 b5 6f 64 64   %nsix........odd
1375 |   4032: 66 69 76 65 05 0f 05 01 15 15 01 04 65 76 65 61   five........evea
1376 |   4048: e6 6f 75 82 04 0f 05 01 13 17 01 03 6f 64 64 74   .ou.........oddt
1377 |   4064: 68 72 61 15 03 0e 05 01 15 12 01 02 64 76 64 6e   hra.........dvdn
1378 |   4080: 74 77 6f 02 00 00 00 00 00 00 00 00 00 00 00 00   two.............
1379 | page 3 offset 8192
1380 |   2816: 00 00 00 00 00 00 00 00 00 00 00 06 03 02 01 00   ................
1381 |   2832: c8 07 06 03 02 01 00 c7 11 06 03 02 01 02 a6 52   ...............R
1382 |   2848: 06 d5 02 01 10 c5 1b 06 03 02 00 ef c4 53 06 03   .............S..
1383 |   2864: 02 01 00 c3 22 06 04 02 01 00 c2 26 06 03 02 01   ...........&....
1384 |   2880: 00 c2 1e 02 b3 02 01 00 c0 3a 06 03 3c 01 00 bf   .........:..<...
1385 |   2896: 2c 06 03 02 01 00 be 27 00 83 02 01 01 bd 15 06   ,......'........
1386 |   2912: 03 02 01 00 bc 21 06 03 02 01 00 bb 54 16 13 02   .....!......T...
1387 |   2928: 01 09 9a 0a 06 03 02 01 00 b9 53 06 03 02 01 00   ..........S.....
1388 |   2944: b8 52 06 13 02 01 00 b7 1e 06 03 02 01 00 b6 34   .R.............4
1389 |   2960: 06 13 02 01 00 b5 3a 05 f3 12 01 00 b4 45 05 03   ......:......E..
1390 |   2976: 02 00 00 b4 6f 06 03 02 01 00 b2 03 06 03 02 01   ....o...........
1391 |   2992: 00 b1 63 06 03 02 01 00 b0 24 06 03 02 01 00 9f   ..c......$......
1392 |   3008: ac 06 03 02 01 00 a2 2f 07 03 02 01 01 ad 21 06   ......./......!.
1393 |   3024: 03 02 01 fb cd 5b 06 c0 01 f1 00 ab 23 06 03 02   .....[......#...
1394 |   3040: 01 00 aa 5b 06 03 02 01 00 a3 ce 06 02 03 01 00   ...[............
1395 |   3056: a8 0e 06 03 02 01 00 a7 0c 06 02 f1 01 00 a6 0d   ................
1396 |   3072: 06 03 02 01 00 95 25 06 03 02 01 00 a4 17 06 03   ......%.........
1397 |   3088: 02 01 00 a3 09 06 03 02 01 00 a2 51 06 03 02 02   ...........Q....
1398 |   3104: 00 a1 40 06 01 e2 00 00 a0 4b 06 13 02 00 00 9e   ..@......K......
1399 |   3120: 5d 06 03 02 01 10 9e 81 06 03 02 01 00 9d 42 06   ].............B.
1400 |   3136: 03 69 01 00 9c 48 06 03 02 01 00 9b 48 06 03 01   .i...H......H...
1401 |   3152: 01 00 9a 09 06 03 02 01 00 99 2f 06 03 02 01 00   ........../.....
1402 |   3168: 98 3a 06 03 02 01 00 97 24 06 03 02 01 00 96 4a   .:......$......J
1403 |   3184: 06 03 02 11 00 f9 50 02 93 02 01 00 94 2f 06 03   ......P....../..
1404 |   3200: 02 11 04 93 1a 06 03 01 04 e0 92 1a 06 03 02 01   ................
1405 |   3216: 00 91 27 06 03 02 01 00 90 23 06 03 02 01 00 8f   ..'......#......
1406 |   3232: 3b 06 03 02 01 00 8e 46 06 16 02 01 00 8d 1d 07   ;......F........
1407 |   3248: 23 12 01 00 8c 5a 06 03 02 01 00 8a 39 06 03 02   #....Z......9...
1408 |   3264: 00 ff 84 b5 06 03 02 01 00 89 07 06 03 02 11 00   ................
1409 |   3280: 88 02 06 03 02 01 00 87 19 06 03 02 01 00 86 4d   ...............M
1410 |   3296: 06 13 12 00 00 85 4b 06 03 02 01 00 84 37 06 13   ......K......7..
1411 |   3312: 02 01 00 83 2c 06 03 02 01 00 81 60 06 13 02 11   ....,......`....
1412 |   3328: 00 81 3b 06 03 02 01 0a b0 5a 06 03 01 01 7f 22   ..;......Z......
1413 |   3344: 05 03 01 01 7e 21 05 03 01 01 7d 0b 15 03 01 02   ....~!..........
1414 |   3360: 7b 08 05 03 06 91 7b 22 05 03 01 01 7a 58 05 03   ............zX..
1415 |   3376: 01 01 7a 4f 05 03 01 01 78 49 05 03 01 01 77 16   ..zO....xI....w.
1416 |   3392: 05 03 01 01 76 5f 05 03 01 01 75 0f 05 03 01 01   ....v_....u.....
1417 |   3408: 74 2f 05 03 01 01 3f 1f 05 03 01 02 72 14 05 03   t/....?.....r...
1418 |   3424: 00 f1 71 08 05 03 01 01 70 0c 05 03 01 47 7f 29   ..q.....p....G.)
1419 |   3440: 05 03 01 01 6e 57 05 03 01 01 6d 33 05 13 00 f1   ....nW....m3....
1420 |   3456: 6c 0b 05 03 01 01 6b 49 05 03 01 01 69 05 05 03   l.....kI....i...
1421 |   3472: 01 02 ed 23 00 00 01 00 00 00 00 00 00 00 00 00   ...#............
1422 | end crash-40d5739835cbdb.db
1423 }]} {}
1425 ifcapable json1 {
1426 do_catchsql_test 18.1 {
1427   SELECT 
1428     json_group_array(c) OVER win4 
1429   FROM t1
1430     WINDOW win4 AS (
1431         ORDER BY a COLLATE nocase RANGE BETWEEN 1.0 PRECEDING AND CURRENT ROW
1432     )
1433 } {1 {JSON cannot hold BLOB values}}
1434 } ;# ifcapable json1
1436 #-------------------------------------------------------------------------
1437 reset_db
1438 do_test 19.0 {
1439   sqlite3 db {}
1440   db deserialize [decode_hexdb {
1441 .open --hexdb
1442 | size 20480 pagesize 4096 filename crash-f022eb0ce64d27.db
1443 | page 1 offset 0
1444 |      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
1445 |     16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 05   .....@  ........
1446 |     32: 00 00 00 00 00 00 00 00 00 00 00 02 00 00 00 04   ................
1447 |     48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00   ................
1448 |     96: 00 00 00 00 0d 0f f8 00 04 0e d2 00 0f 08 0f d3   ................
1449 |    112: 0f ae 0e d2 00 00 00 00 00 00 00 00 00 00 00 00   ................
1450 |   3792: 00 00 34 04 06 17 0f 11 01 57 69 6e 64 65 78 61   ..4......Windexa
1451 |   3808: 74 31 05 43 52 45 41 54 45 20 55 4e 49 51 55 45   t1.CREATE UNIQUE
1452 |   3824: 20 49 4e 44 45 58 20 61 20 4f 4e 20 74 31 28 61    INDEX a ON t1(a
1453 |   3840: 2c 20 30 20 7c 20 61 29 81 23 01 07 17 11 11 01   , 0 | a).#......
1454 |   3856: 82 31 74 61 62 6c 65 74 31 74 31 02 43 52 45 41   .1tablet1t1.CREA
1455 |   3872: 54 45 20 54 41 42 4c 45 20 74 31 28 0a 20 20 20   TE TABLE t1(.   
1456 |   3888: 20 67 63 62 20 41 53 20 28 62 2a 31 29 2c 0a 20    gcb AS (b*1),. 
1457 |   3904: 20 20 20 61 20 49 34 54 45 47 45 52 20 50 52 49      a I4TEGER PRI
1458 |   3920: 4d 41 52 59 20 4b 45 59 2c 0a 20 20 20 20 67 63   MARY KEY,.    gc
1459 |   3936: 63 20 41 53 20 28 74 32 2b 30 29 2c 0a 20 20 20   c AS (t2+0),.   
1460 |   3952: 20 62 20 55 4e 49 51 55 45 2c 0a 20 20 20 20 67    b UNIQUE,.    g
1461 |   3968: 63 61 20 41 53 20 28 31 2a 61 2b 30 29 2c 0a 20   ca AS (1*a+0),. 
1462 |   3984: 20 20 20 74 32 20 55 4e 49 51 55 45 0a 20 20 29      t2 UNIQUE.  )
1463 |   4000: 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44 23 03    WITHOUT ROWID#.
1464 |   4016: 06 17 37 11 01 00 69 6e 64 65 78 73 71 6c 69 74   ..7...indexsqlit
1465 |   4032: 65 5f 61 75 74 6f 69 6e 64 65 78 5f 74 31 5f 33   e_autoindex_t1_3
1466 |   4048: 74 31 02 23 02 06 17 37 11 01 00 69 6e 64 65 78   t1.#...7...index
1467 |   4064: 73 71 6c 69 74 65 5f 61 75 74 6f 69 6e 64 65 78   sqlite_autoindex
1468 |   4080: 5f 74 31 5f 32 74 31 02 00 00 00 08 00 00 00 00   _t1_2t1.........
1469 | page 2 offset 4096
1470 |      0: 0a 00 00 00 05 0f d8 00 0f f8 0f f8 9f e8 0f e0   ................
1471 |     16: 0f d8 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
1472 |   4048: 00 00 00 00 00 00 00 00 07 04 01 02 00 0f 13 88   ................
1473 |   4064: 07 04 01 02 00 0e 0f a0 07 04 01 02 00 0d 0b b8   ................
1474 |   4080: 07 04 01 02 00 0c 07 d0 07 04 01 02 00 0b 03 e8   ................
1475 | page 5 offset 16384
1476 |      0: 0a 00 00 00 05 0f e2 00 0f fa 0f f4 0f ee 0f e8   ................
1477 |     16: 0f e2 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
1478 |   4064: 00 00 05 03 01 01 0f 0f 05 03 01 01 0e 0e 05 03   ................
1479 |   4080: 01 01 0d 0d 05 03 01 01 0c 0c 05 03 01 01 0b 0b   ................
1480 | end crash-f022eb0ce64d27.db
1481 }]} {}
1483 do_execsql_test 19.1 {
1484   PRAGMA writable_schema=ON;
1486 do_catchsql_test 19.2 {
1487   UPDATE t1 SET a=1;
1488 } {1 {database disk image is malformed}}
1490 reset_db
1491 do_execsql_test 19.3 {
1492   CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c INTEGER, d TEXT);
1493   CREATE INDEX i1 ON t1((NULL));
1494   INSERT INTO t1 VALUES(1, NULL, 1, 'text value');
1495   PRAGMA writable_schema = on;
1496   UPDATE sqlite_schema SET 
1497       sql = 'CREATE INDEX i1 ON t1(b, c, d)', 
1498       tbl_name = 't1', 
1499       type='index' 
1500   WHERE name='i1';
1502 db close
1503 sqlite3 db test.db
1504 do_catchsql_test 19.4 {
1505   PRAGMA integrity_check;
1506 } {1 {database disk image is malformed}}
1508 finish_test