1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/index3.test Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,58 @@
1.4 +# 2005 February 14
1.5 +#
1.6 +# The author disclaims copyright to this source code. In place of
1.7 +# a legal notice, here is a blessing:
1.8 +#
1.9 +# May you do good and not evil.
1.10 +# May you find forgiveness for yourself and forgive others.
1.11 +# May you share freely, never taking more than you give.
1.12 +#
1.13 +#***********************************************************************
1.14 +# This file implements regression tests for SQLite library. The
1.15 +# focus of this file is testing the CREATE INDEX statement.
1.16 +#
1.17 +# $Id: index3.test,v 1.3 2008/03/19 13:03:34 drh Exp $
1.18 +
1.19 +
1.20 +set testdir [file dirname $argv0]
1.21 +source $testdir/tester.tcl
1.22 +
1.23 +# Ticket #1115. Make sure that when a UNIQUE index is created on a
1.24 +# non-unique column (or columns) that it fails and that it leaves no
1.25 +# residue behind.
1.26 +#
1.27 +do_test index3-1.1 {
1.28 + execsql {
1.29 + CREATE TABLE t1(a);
1.30 + INSERT INTO t1 VALUES(1);
1.31 + INSERT INTO t1 VALUES(1);
1.32 + SELECT * FROM t1;
1.33 + }
1.34 +} {1 1}
1.35 +do_test index3-1.2 {
1.36 + catchsql {
1.37 + BEGIN;
1.38 + CREATE UNIQUE INDEX i1 ON t1(a);
1.39 + }
1.40 +} {1 {indexed columns are not unique}}
1.41 +do_test index3-1.3 {
1.42 + catchsql COMMIT;
1.43 +} {0 {}}
1.44 +integrity_check index3-1.4
1.45 +
1.46 +# This test corrupts the database file so it must be the last test
1.47 +# in the series.
1.48 +#
1.49 +do_test index3-99.1 {
1.50 + execsql {
1.51 + PRAGMA writable_schema=on;
1.52 + UPDATE sqlite_master SET sql='nonsense';
1.53 + }
1.54 + db close
1.55 + sqlite3 db test.db
1.56 + catchsql {
1.57 + DROP INDEX i1;
1.58 + }
1.59 +} {1 {malformed database schema (t1) - near "nonsense": syntax error}}
1.60 +
1.61 +finish_test