Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Unified Diff: third_party/sqlite/src/test/exists.test

Issue 6990047: Import SQLite 3.7.6.3. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/sqlite/src/test/exclusive2.test ('k') | third_party/sqlite/src/test/expr.test » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/sqlite/src/test/exists.test
diff --git a/third_party/sqlite/src/test/exists.test b/third_party/sqlite/src/test/exists.test
new file mode 100644
index 0000000000000000000000000000000000000000..c7c14a2402e60bffd51747e6c503359c037997cc
--- /dev/null
+++ b/third_party/sqlite/src/test/exists.test
@@ -0,0 +1,198 @@
+# 2011 April 9
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the various schema modification statements
+# that feature "IF EXISTS" or "IF NOT EXISTS" clauses.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/lock_common.tcl
+
+
+foreach jm {rollback wal} {
+
+ set testprefix exists-$jm
+
+ # This block of tests is targeted at CREATE XXX IF NOT EXISTS statements.
+ #
+ do_multiclient_test tn {
+
+ # TABLE objects.
+ #
+ do_test 1.$tn.1.1 {
+ if {$jm == "wal"} { sql2 { PRAGMA journal_mode = WAL } }
+ sql2 { CREATE TABLE t1(x) }
+ sql1 { CREATE TABLE IF NOT EXISTS t1(a, b) }
+ sql2 { DROP TABLE t1 }
+ sql1 { CREATE TABLE IF NOT EXISTS t1(a, b) }
+ sql2 { SELECT name FROM sqlite_master WHERE type = 'table' }
+ } {t1}
+
+ do_test 1.$tn.1.2 {
+ sql2 { CREATE TABLE t2(x) }
+ sql1 { CREATE TABLE IF NOT EXISTS t2 AS SELECT * FROM t1 }
+ sql2 { DROP TABLE t2 }
+ sql1 { CREATE TABLE IF NOT EXISTS t2 AS SELECT * FROM t1 }
+ sql2 { SELECT name FROM sqlite_master WHERE type = 'table' }
+ } {t1 t2}
+
+
+ # INDEX objects.
+ #
+ do_test 1.$tn.2 {
+ sql2 { CREATE INDEX i1 ON t1(a) }
+ sql1 { CREATE INDEX IF NOT EXISTS i1 ON t1(a, b) }
+ sql2 { DROP INDEX i1 }
+ sql1 { CREATE INDEX IF NOT EXISTS i1 ON t1(a, b) }
+ sql2 { SELECT name FROM sqlite_master WHERE type = 'index' }
+ } {i1}
+
+ # VIEW objects.
+ #
+ do_test 1.$tn.3 {
+ sql2 { CREATE VIEW v1 AS SELECT * FROM t1 }
+ sql1 { CREATE VIEW IF NOT EXISTS v1 AS SELECT * FROM t1 }
+ sql2 { DROP VIEW v1 }
+ sql1 { CREATE VIEW IF NOT EXISTS v1 AS SELECT * FROM t1 }
+ sql2 { SELECT name FROM sqlite_master WHERE type = 'view' }
+ } {v1}
+
+ # TRIGGER objects.
+ #
+ do_test $tn.4 {
+ sql2 { CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN SELECT 1; END }
+ sql1 { CREATE TRIGGER IF NOT EXISTS tr1 AFTER INSERT ON t1 BEGIN SELECT 1; END }
+ sql2 { DROP TRIGGER tr1 }
+ sql1 { CREATE TRIGGER IF NOT EXISTS tr1 AFTER INSERT ON t1 BEGIN SELECT 1; END }
+ sql2 { SELECT name FROM sqlite_master WHERE type = 'trigger' }
+ } {tr1}
+ }
+
+ # This block of tests is targeted at DROP XXX IF EXISTS statements.
+ #
+ do_multiclient_test tn {
+
+ # TABLE objects.
+ #
+ do_test 2.$tn.1 {
+ if {$jm == "wal"} { sql1 { PRAGMA journal_mode = WAL } }
+ sql1 { DROP TABLE IF EXISTS t1 }
+ sql2 { CREATE TABLE t1(x) }
+ sql1 { DROP TABLE IF EXISTS t1 }
+ sql2 { SELECT name FROM sqlite_master WHERE type = 'table' }
+ } {}
+
+ # INDEX objects.
+ #
+ do_test 2.$tn.2 {
+ sql1 { CREATE TABLE t2(x) }
+ sql1 { DROP INDEX IF EXISTS i2 }
+ sql2 { CREATE INDEX i2 ON t2(x) }
+ sql1 { DROP INDEX IF EXISTS i2 }
+ sql2 { SELECT name FROM sqlite_master WHERE type = 'index' }
+ } {}
+
+ # VIEW objects.
+ #
+ do_test 2.$tn.3 {
+ sql1 { DROP VIEW IF EXISTS v1 }
+ sql2 { CREATE VIEW v1 AS SELECT * FROM t2 }
+ sql1 { DROP VIEW IF EXISTS v1 }
+ sql2 { SELECT name FROM sqlite_master WHERE type = 'view' }
+ } {}
+
+ # TRIGGER objects.
+ #
+ do_test 2.$tn.4 {
+ sql1 { DROP TRIGGER IF EXISTS tr1 }
+ sql2 { CREATE TRIGGER tr1 AFTER INSERT ON t2 BEGIN SELECT 1; END }
+ sql1 { DROP TRIGGER IF EXISTS tr1 }
+ sql2 { SELECT name FROM sqlite_master WHERE type = 'trigger' }
+ } {}
+ }
+
+ # This block of tests is targeted at DROP XXX IF EXISTS statements with
+ # attached databases.
+ #
+ do_multiclient_test tn {
+
+ forcedelete test.db2
+ do_test 3.$tn.0 {
+ sql1 { ATTACH 'test.db2' AS aux }
+ sql2 { ATTACH 'test.db2' AS aux }
+ } {}
+
+ # TABLE objects.
+ #
+ do_test 3.$tn.1.1 {
+ sql1 { DROP TABLE IF EXISTS aux.t1 }
+ sql2 { CREATE TABLE aux.t1(x) }
+ sql1 { DROP TABLE IF EXISTS aux.t1 }
+ sql2 { SELECT name FROM aux.sqlite_master WHERE type = 'table' }
+ } {}
+ do_test 3.$tn.1.2 {
+ sql1 { DROP TABLE IF EXISTS t1 }
+ sql2 { CREATE TABLE aux.t1(x) }
+ sql1 { DROP TABLE IF EXISTS t1 }
+ sql2 { SELECT name FROM aux.sqlite_master WHERE type = 'table' }
+ } {}
+
+ # INDEX objects.
+ #
+ do_test 3.$tn.2.1 {
+ sql1 { CREATE TABLE aux.t2(x) }
+ sql1 { DROP INDEX IF EXISTS aux.i2 }
+ sql2 { CREATE INDEX aux.i2 ON t2(x) }
+ sql1 { DROP INDEX IF EXISTS aux.i2 }
+ sql2 { SELECT name FROM aux.sqlite_master WHERE type = 'index' }
+ } {}
+ do_test 3.$tn.2.2 {
+ sql1 { DROP INDEX IF EXISTS i2 }
+ sql2 { CREATE INDEX aux.i2 ON t2(x) }
+ sql1 { DROP INDEX IF EXISTS i2 }
+ sql2 { SELECT name FROM aux.sqlite_master WHERE type = 'index' }
+ } {}
+
+ # VIEW objects.
+ #
+ do_test 3.$tn.3.1 {
+ sql1 { DROP VIEW IF EXISTS aux.v1 }
+ sql2 { CREATE VIEW aux.v1 AS SELECT * FROM t2 }
+ sql1 { DROP VIEW IF EXISTS aux.v1 }
+ sql2 { SELECT name FROM aux.sqlite_master WHERE type = 'view' }
+ } {}
+ do_test 3.$tn.3.2 {
+ sql1 { DROP VIEW IF EXISTS v1 }
+ sql2 { CREATE VIEW aux.v1 AS SELECT * FROM t2 }
+ sql1 { DROP VIEW IF EXISTS v1 }
+ sql2 { SELECT name FROM aux.sqlite_master WHERE type = 'view' }
+ } {}
+
+ # TRIGGER objects.
+ #
+ do_test 3.$tn.4.1 {
+ sql1 { DROP TRIGGER IF EXISTS aux.tr1 }
+ sql2 { CREATE TRIGGER aux.tr1 AFTER INSERT ON t2 BEGIN SELECT 1; END }
+ sql1 { DROP TRIGGER IF EXISTS aux.tr1 }
+ sql2 { SELECT name FROM aux.sqlite_master WHERE type = 'trigger' }
+ } {}
+ do_test 3.$tn.4.2 {
+ sql1 { DROP TRIGGER IF EXISTS tr1 }
+ sql2 { CREATE TRIGGER aux.tr1 AFTER INSERT ON t2 BEGIN SELECT 1; END }
+ sql1 { DROP TRIGGER IF EXISTS tr1 }
+ sql2 { SELECT name FROM aux.sqlite_master WHERE type = 'trigger' }
+ } {}
+ }
+}
+
+
+finish_test
« no previous file with comments | « third_party/sqlite/src/test/exclusive2.test ('k') | third_party/sqlite/src/test/expr.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698