mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-30 19:03:16 +03:00
Enhance the "PRAGMA integrity_check" command to verify that all indices are
correctly constructed. New calls to integrity_check are made in the test suite. These changes are intended to prevent any future problems such as seen in ticket #334. (CVS 1024) FossilOrigin-Name: c9734c27074d2039a1896a8c6965c08d03711b13
This commit is contained in:
@ -12,7 +12,7 @@
|
||||
# focus of this script is testing the ATTACH and DETACH commands
|
||||
# and related functionality.
|
||||
#
|
||||
# $Id: attach.test,v 1.9 2003/06/04 15:53:02 drh Exp $
|
||||
# $Id: attach.test,v 1.10 2003/06/15 23:42:25 drh Exp $
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
@ -145,12 +145,13 @@ do_test attach-1.19 {
|
||||
ATTACH 'test.db' as db12;
|
||||
}
|
||||
} {1 {too many attached databases - max 10}}
|
||||
do_test attach-1.20 {
|
||||
do_test attach-1.20.1 {
|
||||
execsql {
|
||||
DETACH db5;
|
||||
}
|
||||
db_list db
|
||||
} {0 main 1 temp 2 db2 3 db3 4 db4 5 db11 6 db6 7 db7 8 db8 9 db9 10 db10}
|
||||
integrity_check attach-1.20.2
|
||||
do_test attach-1.21 {
|
||||
catchsql {
|
||||
ATTACH 'test.db' as db12;
|
||||
|
@ -13,7 +13,7 @@
|
||||
# This file implements tests for the conflict resolution extension
|
||||
# to SQLite.
|
||||
#
|
||||
# $Id: conflict.test,v 1.17 2003/05/16 02:30:27 drh Exp $
|
||||
# $Id: conflict.test,v 1.18 2003/06/15 23:42:25 drh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@ -689,4 +689,6 @@ do_test conflict-10.2 {
|
||||
execsql {SELECT * FROM t4}
|
||||
} {}
|
||||
|
||||
integrity_check conflict-99.0
|
||||
|
||||
finish_test
|
||||
|
@ -11,7 +11,7 @@
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this file is testing the DELETE FROM statement.
|
||||
#
|
||||
# $Id: delete.test,v 1.12 2003/05/04 20:42:56 drh Exp $
|
||||
# $Id: delete.test,v 1.13 2003/06/15 23:42:25 drh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@ -60,6 +60,8 @@ do_test delete-3.1.6 {
|
||||
do_test delete-3.1.7 {
|
||||
execsql {SELECT * FROM table1 ORDER BY f1}
|
||||
} {1 2 4 16}
|
||||
integrity_check delete-3.2
|
||||
|
||||
|
||||
# Semantic errors in the WHERE clause
|
||||
#
|
||||
@ -73,6 +75,7 @@ do_test delete-4.2 {
|
||||
set v [catch {execsql {DELETE FROM table2 WHERE xyzzy(f1+4)}} msg]
|
||||
lappend v $msg
|
||||
} {1 {no such function: xyzzy}}
|
||||
integrity_check delete-4.3
|
||||
|
||||
# Lots of deletes
|
||||
#
|
||||
@ -142,6 +145,8 @@ do_test delete-5.7 {
|
||||
execsql "DELETE FROM table1 WHERE f1!=48"
|
||||
execsql {SELECT f1 FROM table1 ORDER BY f1}
|
||||
} {48}
|
||||
integrity_check delete-5.8
|
||||
|
||||
|
||||
# Delete large quantities of data. We want to test the List overflow
|
||||
# mechanism in the vdbe.
|
||||
@ -192,6 +197,7 @@ do_test delete-6.10 {
|
||||
execsql {INSERT INTO table2 VALUES(2,3)}
|
||||
execsql {SELECT f1 FROM table2}
|
||||
} {2}
|
||||
integrity_check delete-6.11
|
||||
|
||||
do_test delete-7.1 {
|
||||
execsql {
|
||||
@ -240,6 +246,7 @@ do_test delete-7.6 {
|
||||
DELETE FROM t4;
|
||||
}
|
||||
} {4 4}
|
||||
integrity_check delete-7.7
|
||||
|
||||
# Make sure error messages are consistent when attempting to delete
|
||||
# from a read-only database. Ticket #304.
|
||||
@ -279,6 +286,6 @@ do_test delete-8.5 {
|
||||
do_test delete-8.6 {
|
||||
execsql {SELECT * FROM t3}
|
||||
} {123}
|
||||
|
||||
integrity_check delete-8.7
|
||||
|
||||
finish_test
|
||||
|
@ -11,7 +11,7 @@
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this file is testing the CREATE INDEX statement.
|
||||
#
|
||||
# $Id: index.test,v 1.22 2003/04/16 02:17:36 drh Exp $
|
||||
# $Id: index.test,v 1.23 2003/06/15 23:42:25 drh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@ -154,6 +154,7 @@ do_test index-4.13 {
|
||||
execsql {DROP TABLE test1}
|
||||
execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}
|
||||
} {}
|
||||
integrity_check index-4.14
|
||||
|
||||
# Do not allow indices to be added to sqlite_master
|
||||
#
|
||||
@ -199,6 +200,8 @@ do_test index-6.4 {
|
||||
SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name;
|
||||
}
|
||||
} {}
|
||||
integrity_check index-6.5
|
||||
|
||||
|
||||
# Create a primary key
|
||||
#
|
||||
@ -222,6 +225,7 @@ do_test index-7.4 {
|
||||
execsql {DROP table test1}
|
||||
execsql {SELECT name FROM sqlite_master WHERE type!='meta'}
|
||||
} {}
|
||||
integrity_check index-7.5
|
||||
|
||||
# Make sure we cannot drop a non-existant index.
|
||||
#
|
||||
@ -242,6 +246,7 @@ do_test index-9.2 {
|
||||
execsql {CREATE INDEX idx1 ON tab1(a)}
|
||||
execsql {SELECT name FROM sqlite_master WHERE tbl_name='tab1' ORDER BY name}
|
||||
} {idx1 tab1}
|
||||
integrity_check index-9.3
|
||||
|
||||
# Allow more than one entry with the same key.
|
||||
#
|
||||
@ -312,6 +317,7 @@ do_test index-10.8 {
|
||||
SELECT b FROM t1 ORDER BY b;
|
||||
}
|
||||
} {0}
|
||||
integrity_check index-10.9
|
||||
|
||||
# Automatically create an index when we specify a primary key.
|
||||
#
|
||||
@ -330,6 +336,8 @@ do_test index-11.1 {
|
||||
set sqlite_search_count 0
|
||||
concat [execsql {SELECT c FROM t3 WHERE b==10}] $sqlite_search_count
|
||||
} {0.10 3}
|
||||
integrity_check index-11.2
|
||||
|
||||
|
||||
# Numeric strings should compare as if they were numbers. So even if the
|
||||
# strings are not character-by-character the same, if they represent the
|
||||
@ -380,6 +388,7 @@ do_test index-12.7 {
|
||||
SELECT a FROM t4 WHERE a>-0.5 ORDER BY b
|
||||
}
|
||||
} {0.0 0.00 abc +1.0 0 00000}
|
||||
integrity_check index-12.8
|
||||
|
||||
# Make sure we cannot drop an automatically created index.
|
||||
#
|
||||
@ -414,6 +423,7 @@ do_test index-13.4 {
|
||||
SELECT * FROM t5;
|
||||
}
|
||||
} {1 2 3 a b c}
|
||||
integrity_check index-13.5
|
||||
|
||||
# Check the sort order of data in an index.
|
||||
#
|
||||
@ -479,6 +489,7 @@ do_test index-14.11 {
|
||||
SELECT c FROM t6 WHERE a<'';
|
||||
}
|
||||
} {3 5}
|
||||
integrity_check index-14.12
|
||||
|
||||
do_test index-15.1 {
|
||||
execsql {
|
||||
@ -502,5 +513,6 @@ do_test index-15.2 {
|
||||
SELECT b FROM t1 ORDER BY a;
|
||||
}
|
||||
} {8 5 2 1 3 6 11 9 10 4 7}
|
||||
integrity_check index-15.1
|
||||
|
||||
finish_test
|
||||
|
@ -11,7 +11,7 @@
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this file is testing the INSERT statement.
|
||||
#
|
||||
# $Id: insert.test,v 1.14 2003/06/04 16:24:40 drh Exp $
|
||||
# $Id: insert.test,v 1.15 2003/06/15 23:42:25 drh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@ -281,4 +281,6 @@ do_test insert-6.4 {
|
||||
}
|
||||
} {}
|
||||
|
||||
integrity_check insert-99.0
|
||||
|
||||
finish_test
|
||||
|
@ -13,7 +13,7 @@
|
||||
# This file implements tests for the special processing associated
|
||||
# with INTEGER PRIMARY KEY columns.
|
||||
#
|
||||
# $Id: intpkey.test,v 1.13 2003/03/07 19:50:08 drh Exp $
|
||||
# $Id: intpkey.test,v 1.14 2003/06/15 23:42:25 drh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@ -482,4 +482,6 @@ do_test intpkey-11.1 {
|
||||
}
|
||||
} {}
|
||||
|
||||
integrity_check intpkey-12.1
|
||||
|
||||
finish_test
|
||||
|
@ -11,7 +11,7 @@
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this script is in-memory database backend.
|
||||
#
|
||||
# $Id: memdb.test,v 1.4 2003/05/16 02:30:27 drh Exp $
|
||||
# $Id: memdb.test,v 1.5 2003/06/15 23:42:25 drh Exp $
|
||||
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
@ -116,7 +116,7 @@ do_test memdb-2.1 {
|
||||
execsql {
|
||||
PRAGMA integrity_check
|
||||
}
|
||||
} {ok ok}
|
||||
} {ok}
|
||||
|
||||
do_test memdb-3.1 {
|
||||
execsql {
|
||||
|
@ -12,7 +12,7 @@
|
||||
#
|
||||
# This file implements tests for the PRAGMA command.
|
||||
#
|
||||
# $Id: pragma.test,v 1.4 2003/02/15 23:09:17 drh Exp $
|
||||
# $Id: pragma.test,v 1.5 2003/06/15 23:42:25 drh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@ -227,7 +227,33 @@ do_test pragma-2.10 {
|
||||
SELECT d,e FROM t1 INTERSECT SELECT c,e FROM v1
|
||||
}
|
||||
} {WHATEVER BLOB}
|
||||
|
||||
|
||||
# Construct a corrupted index and make sure the integrity_check
|
||||
# pragma finds it.
|
||||
#
|
||||
do_test pragma-3.1 {
|
||||
execsql {
|
||||
BEGIN;
|
||||
CREATE TABLE t2(a,b,c);
|
||||
CREATE INDEX i2 ON t2(a);
|
||||
INSERT INTO t2 VALUES(11,2,3);
|
||||
INSERT INTO t2 VALUES(22,3,4);
|
||||
COMMIT;
|
||||
SELECT rowid, * from t2;
|
||||
}
|
||||
} {1 11 2 3 2 22 3 4}
|
||||
do_test pragma-3.2 {
|
||||
set rootpage [execsql {SELECT rootpage FROM sqlite_master WHERE name='i2'}]
|
||||
set db [btree_open test.db]
|
||||
btree_begin_transaction $db
|
||||
set c [btree_cursor $db $rootpage 1]
|
||||
btree_first $c
|
||||
btree_delete $c
|
||||
btree_commit $db
|
||||
btree_close $db
|
||||
execsql {PRAGMA integrity_check}
|
||||
} {{rowid 1 missing from index i2
|
||||
wrong # of entries in index i2
|
||||
}}
|
||||
|
||||
finish_test
|
||||
|
@ -11,7 +11,7 @@
|
||||
# This file implements some common TCL routines used for regression
|
||||
# testing the SQLite library
|
||||
#
|
||||
# $Id: tester.tcl,v 1.25 2003/03/01 19:45:35 drh Exp $
|
||||
# $Id: tester.tcl,v 1.26 2003/06/15 23:42:25 drh Exp $
|
||||
|
||||
# Make sure tclsqlite was compiled correctly. Abort now with an
|
||||
# error message if not.
|
||||
@ -247,5 +247,5 @@ proc forcedelete {filename} {
|
||||
proc integrity_check {name} {
|
||||
do_test $name {
|
||||
execsql {PRAGMA integrity_check}
|
||||
} {ok ok}
|
||||
} {ok}
|
||||
}
|
||||
|
@ -307,5 +307,6 @@ do_test trigger-4.4 {
|
||||
};
|
||||
} {3 4 7 8}
|
||||
|
||||
integrity_check trigger-5.1
|
||||
|
||||
finish_test
|
||||
|
@ -186,7 +186,7 @@ foreach tbl_defn {
|
||||
execsql {
|
||||
PRAGMA integrity_check;
|
||||
}
|
||||
} {ok ok}
|
||||
} {ok}
|
||||
}
|
||||
catchsql {
|
||||
DROP TABLE rlog;
|
||||
@ -308,7 +308,7 @@ foreach tr_program {
|
||||
execsql {
|
||||
PRAGMA integrity_check;
|
||||
}
|
||||
} {ok ok}
|
||||
} {ok}
|
||||
|
||||
}
|
||||
}
|
||||
@ -384,7 +384,7 @@ do_test trigger2-3.3 {
|
||||
execsql {
|
||||
PRAGMA integrity_check;
|
||||
}
|
||||
} {ok ok}
|
||||
} {ok}
|
||||
|
||||
# Simple cascaded trigger
|
||||
execsql {
|
||||
@ -714,6 +714,6 @@ do_test trigger2-8.6 {
|
||||
|
||||
do_test trigger2-9.9 {
|
||||
execsql {PRAGMA integrity_check}
|
||||
} {ok ok}
|
||||
} {ok}
|
||||
|
||||
finish_test
|
||||
|
@ -157,6 +157,8 @@ do_test trigger3-7.3 {
|
||||
}
|
||||
} {1 {View abort}}
|
||||
|
||||
integrity_check trigger3-8.1
|
||||
|
||||
catchsql { DROP TABLE tbl; }
|
||||
catchsql { DROP TABLE tbl2; }
|
||||
catchsql { DROP VIEW tbl_view; }
|
||||
|
@ -122,4 +122,6 @@ do_test trigger4-3.7 {
|
||||
}
|
||||
} {7 99}
|
||||
|
||||
integrity_check trigger4-4.1
|
||||
|
||||
finish_test
|
||||
|
@ -12,7 +12,7 @@
|
||||
# focus of this file is testing the CREATE UNIQUE INDEX statement,
|
||||
# and primary keys, and the UNIQUE constraint on table columns
|
||||
#
|
||||
# $Id: unique.test,v 1.5 2003/01/29 18:46:54 drh Exp $
|
||||
# $Id: unique.test,v 1.6 2003/06/15 23:42:25 drh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@ -73,6 +73,7 @@ do_test unique-1.8 {
|
||||
SELECT * FROM t1 ORDER BY a;
|
||||
}
|
||||
} {1 2 3 3 4 5}
|
||||
integrity_check unique-1.9
|
||||
|
||||
do_test unique-2.0 {
|
||||
execsql {
|
||||
@ -129,6 +130,7 @@ do_test unique-2.9 {
|
||||
CREATE INDEX i2 ON t2(a);
|
||||
}
|
||||
} {0 {}}
|
||||
integrity_check unique-2.10
|
||||
|
||||
# Test the UNIQUE keyword as used on two or more fields.
|
||||
#
|
||||
@ -161,6 +163,7 @@ do_test unique-3.4 {
|
||||
SELECT * FROM t3 ORDER BY a,b,c,d;
|
||||
}
|
||||
} {1 {uniqueness constraint failed}}
|
||||
integrity_check unique-3.5
|
||||
|
||||
# Make sure NULLs are distinct as far as the UNIQUE tests are
|
||||
# concerned.
|
||||
@ -193,6 +196,6 @@ do_test unique-4.5 {
|
||||
SELECT * FROM t4
|
||||
}
|
||||
} {1 2 3 {} 2 {} {} 3 4 2 2 {}}
|
||||
|
||||
integrity_check unique-4.6
|
||||
|
||||
finish_test
|
||||
|
@ -11,7 +11,7 @@
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this file is testing the UPDATE statement.
|
||||
#
|
||||
# $Id: update.test,v 1.12 2003/02/15 23:09:17 drh Exp $
|
||||
# $Id: update.test,v 1.13 2003/06/15 23:42:25 drh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@ -496,4 +496,6 @@ do_test update-11.2 {
|
||||
}
|
||||
} {1 15 2 8}
|
||||
|
||||
integrity_check update-12.1
|
||||
|
||||
finish_test
|
||||
|
@ -11,7 +11,7 @@
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this file is testing the use of indices in WHERE clases.
|
||||
#
|
||||
# $Id: where.test,v 1.16 2003/04/19 17:27:25 drh Exp $
|
||||
# $Id: where.test,v 1.17 2003/06/15 23:42:25 drh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@ -737,5 +737,6 @@ do_test where-10.4 {
|
||||
}
|
||||
} {50}
|
||||
|
||||
integrity_check {where-99.0}
|
||||
|
||||
finish_test
|
||||
|
Reference in New Issue
Block a user