Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: third_party/sqlite/sqlite-src-3080704/test/corrupt3.test

Issue 2363173002: [sqlite] Remove obsolete reference version 3.8.7.4. (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 # 2007 April 6
2 #
3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
5 #
6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give.
9 #
10 #***********************************************************************
11 # This file implements regression tests for SQLite library.
12 #
13 # This file implements tests to make sure SQLite does not crash or
14 # segfault if it sees a corrupt database file.
15 #
16 # $Id: corrupt3.test,v 1.2 2007/04/06 21:42:22 drh Exp $
17
18 set testdir [file dirname $argv0]
19 source $testdir/tester.tcl
20
21 # Do not use a codec for tests in this file, as the database file is
22 # manipulated directly using tcl scripts (using the [hexio_write] command).
23 #
24 do_not_use_codec
25
26 # These tests deal with corrupt database files
27 #
28 database_may_be_corrupt
29
30 # We must have the page_size pragma for these tests to work.
31 #
32 ifcapable !pager_pragmas||direct_read {
33 finish_test
34 return
35 }
36
37 # Create a database with an overflow page.
38 #
39 do_test corrupt3-1.1 {
40 set bigstring [string repeat 0123456789 200]
41 execsql {
42 PRAGMA auto_vacuum=OFF;
43 PRAGMA page_size=1024;
44 CREATE TABLE t1(x);
45 INSERT INTO t1 VALUES($bigstring);
46 }
47 file size test.db
48 } [expr {1024*3}]
49
50 # Verify that the file format is as we expect. The page size
51 # should be 1024 bytes. The only record should have a single
52 # overflow page. The overflow page is page 3. The pointer to
53 # the overflow page is on the last 4 bytes of page 2.
54 #
55 do_test corrupt3-1.2 {
56 hexio_get_int [hexio_read test.db 16 2]
57 } 1024 ;# The page size is 1024
58 do_test corrupt3-1.3 {
59 hexio_get_int [hexio_read test.db 20 1]
60 } 0 ;# Unused bytes per page is 0
61 do_test corrupt3-1.4 {
62 hexio_get_int [hexio_read test.db 2044 4]
63 } 3 ;# Overflow page is 3
64 do_test corrupt3-1.5 {
65 hexio_get_int [hexio_read test.db 2048 4]
66 } 0 ;# First chained overflow is 0
67
68 integrity_check corrupt3-1.6
69
70 # Make the overflow chain loop back on itself. See if the
71 # corruption is detected. (Actually, the last pointer in
72 # an overflow chain is ignored, so this is not an error.)
73 #
74 do_test corrupt3-1.7 {
75 db close
76 hexio_write test.db 2048 [hexio_render_int32 3]
77 sqlite3 db test.db
78 catchsql {
79 SELECT x FROM t1
80 }
81 } [list 0 $bigstring]
82 integrity_check corrupt3-1.8
83
84 # Change the pointer for the first page of the overflow
85 # change to be a non-existant page.
86 #
87 do_test corrupt3-1.9 {
88 db close
89 hexio_write test.db 2044 [hexio_render_int32 4]
90 sqlite3 db test.db
91 catchsql {
92 SELECT substr(x,1,10) FROM t1
93 }
94 } [list 0 0123456789]
95 do_test corrupt3-1.10 {
96 catchsql {
97 PRAGMA integrity_check
98 }
99 } {0 {{*** in database main ***
100 On tree page 2 cell 0: invalid page number 4
101 Page 3 is never used}}}
102 do_test corrupt3-1.11 {
103 db close
104 hexio_write test.db 2044 [hexio_render_int32 0]
105 sqlite3 db test.db
106 catchsql {
107 SELECT substr(x,1,10) FROM t1
108 }
109 } [list 1 {database disk image is malformed}]
110 do_test corrupt3-1.12 {
111 catchsql {
112 PRAGMA integrity_check
113 }
114 } {0 {{*** in database main ***
115 On tree page 2 cell 0: 1 of 1 pages missing from overflow list starting at 0
116 Page 3 is never used}}}
117
118 finish_test
OLDNEW
« no previous file with comments | « third_party/sqlite/sqlite-src-3080704/test/corrupt2.test ('k') | third_party/sqlite/sqlite-src-3080704/test/corrupt4.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698