1
0
mirror of https://github.com/sqlite/sqlite.git synced 2026-01-06 08:01:16 +03:00

Add support for CREATE INDEX IF NOT EXISTS and DROP INDEX IF EXISTS. (CVS 2855)

FossilOrigin-Name: 551cdd6c309e75687abaeac5381b794cd5e4c10a
This commit is contained in:
drh
2006-01-04 15:54:36 +00:00
parent f93339decb
commit 4d91a701bd
7 changed files with 48 additions and 29 deletions

View File

@@ -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.39 2005/11/14 22:29:06 drh Exp $
# $Id: index.test,v 1.40 2006/01/04 15:54:37 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -185,6 +185,9 @@ do_test index-6.1 {
do_test index-6.1b {
execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}
} {index1 test1 test2}
do_test index-6.1c {
catchsql {CREATE INDEX IF NOT EXISTS index1 ON test1(f1)}
} {0 {}}
do_test index-6.2 {
set v [catch {execsql {CREATE INDEX test1 ON test2(g1)}} msg]
lappend v $msg
@@ -589,6 +592,17 @@ do_test index-17.2 {
DROP INDEX sqlite_autoindex_t7_1;
}
} {1 {index associated with UNIQUE or PRIMARY KEY constraint cannot be dropped}}
do_test index-17.3 {
catchsql {
DROP INDEX IF EXISTS sqlite_autoindex_t7_1;
}
} {1 {index associated with UNIQUE or PRIMARY KEY constraint cannot be dropped}}
do_test index-17.4 {
catchsql {
DROP INDEX IF EXISTS no_such_index;
}
} {0 {}}
# The following tests ensure that it is not possible to explicitly name
# a schema object with a name beginning with "sqlite_". Granted that is a