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

Unified Diff: third_party/sqlite/sqlite-src-3080704/test/unique2.test

Issue 949043002: Add //third_party/sqlite to dirs_to_snapshot, remove net_sql.patch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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
Index: third_party/sqlite/sqlite-src-3080704/test/unique2.test
diff --git a/third_party/sqlite/sqlite-src-3080704/test/unique2.test b/third_party/sqlite/sqlite-src-3080704/test/unique2.test
new file mode 100644
index 0000000000000000000000000000000000000000..6a320d4d7dfe0fa1b2769035d4a1cdee95724cc9
--- /dev/null
+++ b/third_party/sqlite/sqlite-src-3080704/test/unique2.test
@@ -0,0 +1,78 @@
+# 2014-07-30
+#
+# 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 CREATE UNIQUE INDEX statement
+# to verify that ticket 9a6daf340df99ba93c53bcf8fa83d9f28040d2a8
+# has been fixed:
+#
+# drh added on 2014-07-30 12:33:04:
+#
+# The CREATE UNIQUE INDEX on the third line below does not fail even
+# though the x column values are not all unique.
+#
+# CREATE TABLE t1(x NOT NULL);
+# INSERT INTO t1 VALUES(1),(2),(2),(3);
+# CREATE UNIQUE INDEX t1x ON t1(x);
+#
+# If the index is created before the INSERT, then uniqueness is enforced
+# at the point of the INSERT. Note that the NOT NULL on the indexed column
+# seems to be required in order to exhibit this bug.
+#
+# "PRAGMA integrity_check" does not detect the resulting malformed database.
+# That might be considered a separate issue.
+#
+# Bisecting shows that this problem was introduced by the addition of
+# WITHOUT ROWID support in version 3.8.2, specifically in check-in
+# [c80e229dd9c1230] on 2013-11-07. This problem was reported on the mailing
+# list by Pavel Pimenov. and primary keys, and the UNIQUE constraint
+# on table columns
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+foreach {id sql} {
+ 1 {CREATE TABLE t1(x TEXT PRIMARY KEY, y NOT NULL) WITHOUT ROWID}
+ 2 {CREATE TABLE t1(x TEXT PRIMARY KEY, y NOT NULL)}
+ 3 {CREATE TABLE t1(x TEXT PRIMARY KEY, y) WITHOUT ROWID}
+ 4 {CREATE TABLE t1(x TEXT PRIMARY KEY, y)}
+} {
+ do_test $id.1 {
+ db eval {DROP TABLE IF EXISTS t1}
+ db eval $sql
+ db eval {INSERT INTO t1(x,y) VALUES(1,1),(2,2),(3,2),(4,3)}
+ } {}
+ do_test $id.2 {
+ catchsql {CREATE UNIQUE INDEX t1y ON t1(y)}
+ } {1 {UNIQUE constraint failed: t1.y}}
+}
+
+foreach {id sql} {
+ 5 {CREATE TABLE t1(w,x,y NOT NULL,z NOT NULL,PRIMARY KEY(w,x)) WITHOUT ROWID}
+ 6 {CREATE TABLE t1(w,x,y NOT NULL,z NOT NULL,PRIMARY KEY(w,x))}
+ 7 {CREATE TABLE t1(w,x,y NOT NULL,z,PRIMARY KEY(w,x)) WITHOUT ROWID}
+ 8 {CREATE TABLE t1(w,x,y NOT NULL,z,PRIMARY KEY(w,x))}
+ 9 {CREATE TABLE t1(w,x,y,z NOT NULL,PRIMARY KEY(w,x)) WITHOUT ROWID}
+ 10 {CREATE TABLE t1(w,x,y,z NOT NULL,PRIMARY KEY(w,x))}
+ 11 {CREATE TABLE t1(w,x,y,z,PRIMARY KEY(w,x)) WITHOUT ROWID}
+ 12 {CREATE TABLE t1(w,x,y,z,PRIMARY KEY(w,x))}
+} {
+ do_test $id.1 {
+ db eval {DROP TABLE IF EXISTS t1}
+ db eval $sql
+ db eval {INSERT INTO t1(w,x,y,z) VALUES(1,2,3,4),(2,3,3,4)}
+ } {}
+ do_test $id.2 {
+ catchsql {CREATE UNIQUE INDEX t1yz ON t1(y,z)}
+ } {1 {UNIQUE constraint failed: t1.y, t1.z}}
+}
+
+finish_test
« no previous file with comments | « third_party/sqlite/sqlite-src-3080704/test/unique.test ('k') | third_party/sqlite/sqlite-src-3080704/test/unixexcl.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698