sl@0: # 2005 February 14 sl@0: # sl@0: # The author disclaims copyright to this source code. In place of sl@0: # a legal notice, here is a blessing: sl@0: # sl@0: # May you do good and not evil. sl@0: # May you find forgiveness for yourself and forgive others. sl@0: # May you share freely, never taking more than you give. sl@0: # sl@0: #*********************************************************************** sl@0: # This file implements regression tests for SQLite library. The sl@0: # focus of this file is testing the CREATE INDEX statement. sl@0: # sl@0: # $Id: index3.test,v 1.3 2008/03/19 13:03:34 drh Exp $ sl@0: sl@0: sl@0: set testdir [file dirname $argv0] sl@0: source $testdir/tester.tcl sl@0: sl@0: # Ticket #1115. Make sure that when a UNIQUE index is created on a sl@0: # non-unique column (or columns) that it fails and that it leaves no sl@0: # residue behind. sl@0: # sl@0: do_test index3-1.1 { sl@0: execsql { sl@0: CREATE TABLE t1(a); sl@0: INSERT INTO t1 VALUES(1); sl@0: INSERT INTO t1 VALUES(1); sl@0: SELECT * FROM t1; sl@0: } sl@0: } {1 1} sl@0: do_test index3-1.2 { sl@0: catchsql { sl@0: BEGIN; sl@0: CREATE UNIQUE INDEX i1 ON t1(a); sl@0: } sl@0: } {1 {indexed columns are not unique}} sl@0: do_test index3-1.3 { sl@0: catchsql COMMIT; sl@0: } {0 {}} sl@0: integrity_check index3-1.4 sl@0: sl@0: # This test corrupts the database file so it must be the last test sl@0: # in the series. sl@0: # sl@0: do_test index3-99.1 { sl@0: execsql { sl@0: PRAGMA writable_schema=on; sl@0: UPDATE sqlite_master SET sql='nonsense'; sl@0: } sl@0: db close sl@0: sqlite3 db test.db sl@0: catchsql { sl@0: DROP INDEX i1; sl@0: } sl@0: } {1 {malformed database schema (t1) - near "nonsense": syntax error}} sl@0: sl@0: finish_test