SQLite

Check-in [7bd20a20a0]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Avoid running tests that use sqlite_dbpage with SQLITE_OMIT_VIRTUAL_TABLE builds.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 7bd20a20a0f422765a6e469d1a1b67b95c4a441931688e04a2b1b491a5238528
User & Date: dan 2017-10-22 07:57:29.038
Context
2017-10-22
08:02
Fix test cases in dbpage.test so that they work with SQLITE_DEFAULT_AUTOVACUUM=1 builds. (check-in: 0fcf1e61ef user: dan tags: trunk)
07:58
Avoid running tests that use sqlite_dbpage with SQLITE_OMIT_VIRTUAL_TABLE builds. (check-in: 6dde8d6154 user: dan tags: branch-3.21)
07:57
Avoid running tests that use sqlite_dbpage with SQLITE_OMIT_VIRTUAL_TABLE builds. (check-in: 7bd20a20a0 user: dan tags: trunk)
2017-10-21
14:17
Catch and avoid a 16-bit integer overflow on the number of columns in a common table expression. This fixes a problem found by OSS-Fuzz. The test case is in TH3. (check-in: 6ee8cb6ae5 user: drh tags: trunk)
Changes
Side-by-Side Diff Ignore Whitespace Patch
Changes to test/corruptK.test.
105
106
107
108
109
110
111


112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218













































































































219
220
221
222
105
106
107
108
109
110
111
112
113











































































































114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226







+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+





do_catchsql_test 2.3 {
  INSERT INTO t1 VALUES(randomblob(900));
} {1 {database disk image is malformed}}

#-------------------------------------------------------------------------

ifcapable vtab {

proc hex2blob {hex} {
  # Split on newlines:
  set bytes [list]
  foreach l [split $hex "\n"] {
    if {[string is space $l]} continue
    set L [list]
    foreach b [split $l] {
      if {[string is xdigit $b] && [string length $b]==2} { 
        lappend L [expr "0x$b"]
      }
    }
    if {[llength $L]!=16} {
      error "Badly formed hex (1)"
    }
    set bytes [concat $bytes $L]
  }

  binary format c* $bytes
}

reset_db
db func hex2blob hex2blob

do_execsql_test 3.1 {
  PRAGMA page_size=1024;
  CREATE TABLE t1(a, b, c);
  CREATE TABLE t2(a, b, c);
  CREATE TABLE t3(a, b, c);
  CREATE TABLE t4(a, b, c);
  CREATE TABLE t5(a, b, c);
}

do_execsql_test 3.2 {
  UPDATE sqlite_dbpage SET data = hex2blob('
 000: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
 010: 04 00 01 01 20 40 20 20 00 00 3e d9 00 00 00 06 .... @  ..>.....
 020: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 04 ................
 030: 0f 00 00 00 00 00 00 00 00 00 00 01 00 00 83 00 ................
 040: 00 00 00 00 00 00 00 00 00 00 00 00 00 38 00 00 .............8..
 050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3e d9 ..............>.
 060: 00 2d e6 07 0d 00 00 00 01 03 a0 00 03 e0 00 00 .-..............
 070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
 080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
 090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
 0a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
 0b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
 0c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
 0d0: 00 00 00 00 00 c1 00 00 00 00 00 00 00 00 00 00 ................
 0e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
 0f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
 100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
 110: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
 120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
 130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
 140: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
 150: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
 160: 00 83 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
 170: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
 180: 00 00 00 00 00 00 00 00 00 00 07 00 30 00 00 00 ............0...
 190: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
 1a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
 1b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
 1c0: 02 00 00 00 00 00 00 00 00 00 00 02 00 00 00 00 ................
 1d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
 1e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
 1f0: 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
 200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
 210: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
 220: 00 00 0e 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
 230: 0c 00 00 00 00 00 00 60 00 00 00 06 00 00 c3 00 .......`........
 240: 00 06 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
 250: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
 260: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
 270: 00 00 00 18 00 00 00 00 00 00 00 00 00 00 00 00 ................
 280: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
 290: 04 00 0e 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
 2a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
 2b0: 00 00 00 00 83 00 8c 00 00 00 00 00 00 00 00 00 ................
 2c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
 2d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
 2e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
 2f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
 300: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
 310: 00 78 00 00 00 00 00 00 00 00 00 00 00 00 70 00 .x............p.
 320: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
 330: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
 340: 00 00 00 04 00 00 00 00 00 00 00 00 00 00 00 00 ................
 350: 00 00 00 00 00 68 00 00 00 00 00 00 00 00 00 00 .....h..........
 360: 00 00 00 00 00 03 00 00 00 00 00 00 00 00 00 00 ................
 370: 00 00 00 00 00 00 00 00 00 00 00 00 00 08 00 00 ................
 380: 00 00 00 00 70 00 00 00 00 00 00 00 00 00 00 00 ....p...........
 390: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
 3a0: 5e 01 07 17 1b 1b 01 81 13 74 61 62 6c 65 73 65 ^........tablese
 3b0: 6e 73 6f 32 73 73 65 6e 73 6f 72 73 02 43 52 45 nso2ssensors.CRE
 3c0: 41 54 45 20 54 41 42 4c 45 20 73 65 6e 73 6f 72 ATE TABLE sensor
 3d0: 73 20 0a 20 20 24 20 20 20 20 20 20 20 20 20 20 s .  $          
 3e0: b8 6e 61 6d 65 21 74 65 78 74 2c 20 79 61 6c 20 .name!text, yal 
 3f0: 72 65 61 6c 2c 20 74 69 6d 65 20 74 65 78 74 29 real, time text)
  ') WHERE pgno=1
}

db close
sqlite3 db test.db

do_catchsql_test 3.3 {
  PRAGMA integrity_check;
} {1 {database disk image is malformed}}
  proc hex2blob {hex} {
    # Split on newlines:
    set bytes [list]
    foreach l [split $hex "\n"] {
      if {[string is space $l]} continue
      set L [list]
      foreach b [split $l] {
        if {[string is xdigit $b] && [string length $b]==2} { 
          lappend L [expr "0x$b"]
        }
      }
      if {[llength $L]!=16} {
        error "Badly formed hex (1)"
      }
      set bytes [concat $bytes $L]
    }
  
    binary format c* $bytes
  }
  
  reset_db
  db func hex2blob hex2blob
  
  do_execsql_test 3.1 {
    PRAGMA page_size=1024;
    CREATE TABLE t1(a, b, c);
    CREATE TABLE t2(a, b, c);
    CREATE TABLE t3(a, b, c);
    CREATE TABLE t4(a, b, c);
    CREATE TABLE t5(a, b, c);
  }
  
  do_execsql_test 3.2 {
    UPDATE sqlite_dbpage SET data = hex2blob('
   000: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
   010: 04 00 01 01 20 40 20 20 00 00 3e d9 00 00 00 06 .... @  ..>.....
   020: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 04 ................
   030: 0f 00 00 00 00 00 00 00 00 00 00 01 00 00 83 00 ................
   040: 00 00 00 00 00 00 00 00 00 00 00 00 00 38 00 00 .............8..
   050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3e d9 ..............>.
   060: 00 2d e6 07 0d 00 00 00 01 03 a0 00 03 e0 00 00 .-..............
   070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
   080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
   090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
   0a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
   0b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
   0c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
   0d0: 00 00 00 00 00 c1 00 00 00 00 00 00 00 00 00 00 ................
   0e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
   0f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
   100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
   110: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
   120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
   130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
   140: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
   150: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
   160: 00 83 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
   170: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
   180: 00 00 00 00 00 00 00 00 00 00 07 00 30 00 00 00 ............0...
   190: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
   1a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
   1b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
   1c0: 02 00 00 00 00 00 00 00 00 00 00 02 00 00 00 00 ................
   1d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
   1e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
   1f0: 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
   200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
   210: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
   220: 00 00 0e 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
   230: 0c 00 00 00 00 00 00 60 00 00 00 06 00 00 c3 00 .......`........
   240: 00 06 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
   250: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
   260: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
   270: 00 00 00 18 00 00 00 00 00 00 00 00 00 00 00 00 ................
   280: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
   290: 04 00 0e 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
   2a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
   2b0: 00 00 00 00 83 00 8c 00 00 00 00 00 00 00 00 00 ................
   2c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
   2d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
   2e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
   2f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
   300: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
   310: 00 78 00 00 00 00 00 00 00 00 00 00 00 00 70 00 .x............p.
   320: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
   330: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
   340: 00 00 00 04 00 00 00 00 00 00 00 00 00 00 00 00 ................
   350: 00 00 00 00 00 68 00 00 00 00 00 00 00 00 00 00 .....h..........
   360: 00 00 00 00 00 03 00 00 00 00 00 00 00 00 00 00 ................
   370: 00 00 00 00 00 00 00 00 00 00 00 00 00 08 00 00 ................
   380: 00 00 00 00 70 00 00 00 00 00 00 00 00 00 00 00 ....p...........
   390: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
   3a0: 5e 01 07 17 1b 1b 01 81 13 74 61 62 6c 65 73 65 ^........tablese
   3b0: 6e 73 6f 32 73 73 65 6e 73 6f 72 73 02 43 52 45 nso2ssensors.CRE
   3c0: 41 54 45 20 54 41 42 4c 45 20 73 65 6e 73 6f 72 ATE TABLE sensor
   3d0: 73 20 0a 20 20 24 20 20 20 20 20 20 20 20 20 20 s .  $          
   3e0: b8 6e 61 6d 65 21 74 65 78 74 2c 20 79 61 6c 20 .name!text, yal 
   3f0: 72 65 61 6c 2c 20 74 69 6d 65 20 74 65 78 74 29 real, time text)
    ') WHERE pgno=1
  }
  
  db close
  sqlite3 db test.db
  
  do_catchsql_test 3.3 {
    PRAGMA integrity_check;
  } {1 {database disk image is malformed}}

} ;# ifcapable vtab



finish_test