xref: /sqlite-3.40.0/test/corrupt5.test (revision 8a29dfde)
1# 2008 Jan 22
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: corrupt5.test,v 1.2 2008/03/19 13:03:34 drh Exp $
17
18set testdir [file dirname $argv0]
19source $testdir/tester.tcl
20
21# We must have the page_size pragma for these tests to work.
22#
23ifcapable !pager_pragmas {
24  finish_test
25  return
26}
27
28# Create a database with a freelist containing at least two pages.
29#
30do_test corrupt5-1.1 {
31  execsql {
32    CREATE TABLE t1(a,b,c);
33    CREATE INDEX i1 ON t1(a,b);
34    PRAGMA writable_schema=ON;
35    UPDATE sqlite_master SET name=NULL, sql=NULL WHERE name='i1';
36  }
37  db close
38  sqlite3 db test.db
39  catchsql {
40    SELECT * FROM t1
41  }
42} {1 {malformed database schema (?)}}
43
44finish_test
45