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

Side by Side Diff: third_party/sqlite/src/test/index3.test

Issue 1610963002: Import SQLite 3.10.2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 unified diff | Download patch
« no previous file with comments | « third_party/sqlite/src/test/index2.test ('k') | third_party/sqlite/src/test/index5.test » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # 2005 February 14 1 # 2005-02-14
2 # 2 #
3 # The author disclaims copyright to this source code. In place of 3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing: 4 # a legal notice, here is a blessing:
5 # 5 #
6 # May you do good and not evil. 6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others. 7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give. 8 # May you share freely, never taking more than you give.
9 # 9 #
10 #*********************************************************************** 10 #***********************************************************************
11 # This file implements regression tests for SQLite library. The 11 # This file implements regression tests for SQLite library. The
12 # focus of this file is testing the CREATE INDEX statement. 12 # focus of this file is testing the CREATE INDEX statement.
13 # 13 #
14 # $Id: index3.test,v 1.3 2008/03/19 13:03:34 drh Exp $
15 14
16 15
17 set testdir [file dirname $argv0] 16 set testdir [file dirname $argv0]
18 source $testdir/tester.tcl 17 source $testdir/tester.tcl
19 18
20 # Ticket #1115. Make sure that when a UNIQUE index is created on a 19 # Ticket #1115. Make sure that when a UNIQUE index is created on a
21 # non-unique column (or columns) that it fails and that it leaves no 20 # non-unique column (or columns) that it fails and that it leaves no
22 # residue behind. 21 # residue behind.
23 # 22 #
24 do_test index3-1.1 { 23 do_test index3-1.1 {
25 execsql { 24 execsql {
26 CREATE TABLE t1(a); 25 CREATE TABLE t1(a);
27 INSERT INTO t1 VALUES(1); 26 INSERT INTO t1 VALUES(1);
28 INSERT INTO t1 VALUES(1); 27 INSERT INTO t1 VALUES(1);
29 SELECT * FROM t1; 28 SELECT * FROM t1;
30 } 29 }
31 } {1 1} 30 } {1 1}
32 do_test index3-1.2 { 31 do_test index3-1.2 {
33 catchsql { 32 catchsql {
34 BEGIN; 33 BEGIN;
35 CREATE UNIQUE INDEX i1 ON t1(a); 34 CREATE UNIQUE INDEX i1 ON t1(a);
36 } 35 }
37 } {1 {UNIQUE constraint failed: t1.a}} 36 } {1 {UNIQUE constraint failed: t1.a}}
38 do_test index3-1.3 { 37 do_test index3-1.3 {
39 catchsql COMMIT; 38 catchsql COMMIT;
40 } {0 {}} 39 } {0 {}}
41 integrity_check index3-1.4 40 integrity_check index3-1.4
42 41
42 # Backwards compatibility test:
43 #
44 # Verify that CREATE INDEX statements that use strings instead of
45 # identifiers for the the column names continue to work correctly.
46 # This is undocumented behavior retained for backwards compatiblity.
47 #
48 do_execsql_test index3-2.1 {
49 DROP TABLE t1;
50 CREATE TABLE t1(a, b, c, d, e,
51 PRIMARY KEY('a'), UNIQUE('b' COLLATE nocase DESC));
52 CREATE INDEX t1c ON t1('c');
53 CREATE INDEX t1d ON t1('d' COLLATE binary ASC);
54 WITH RECURSIVE c(x) AS (VALUES(1) UNION SELECT x+1 FROM c WHERE x<30)
55 INSERT INTO t1(a,b,c,d,e)
56 SELECT x, printf('ab%03xxy',x), x, x, x FROM c;
57 } {}
58 do_execsql_test index3-2.2 {
59 SELECT a FROM t1 WHERE b='ab005xy' COLLATE nocase;
60 } {5}
61 do_execsql_test index3-2.2eqp {
62 EXPLAIN QUERY PLAN
63 SELECT a FROM t1 WHERE b='ab005xy' COLLATE nocase;
64 } {/USING INDEX/}
65 do_execsql_test index3-2.3 {
66 SELECT name FROM sqlite_master WHERE tbl_name='t1' ORDER BY name
67 } {sqlite_autoindex_t1_1 sqlite_autoindex_t1_2 t1 t1c t1d}
68 do_execsql_test index3-2.4 {
69 CREATE TABLE t2a(a integer, b, PRIMARY KEY(a));
70 CREATE TABLE t2b("a" integer, b, PRIMARY KEY("a"));
71 CREATE TABLE t2c([a] integer, b, PRIMARY KEY([a]));
72 CREATE TABLE t2d('a' integer, b, PRIMARY KEY('a'));
73 }
74 do_execsql_test index3-2.5 {
75 SELECT name FROM sqlite_master WHERE tbl_name LIKE 't2_' ORDER BY name
76 } {t2a t2b t2c t2d}
77
78
79
80
81
43 # This test corrupts the database file so it must be the last test 82 # This test corrupts the database file so it must be the last test
44 # in the series. 83 # in the series.
45 # 84 #
46 do_test index3-99.1 { 85 do_test index3-99.1 {
47 execsql { 86 execsql {
48 PRAGMA writable_schema=on; 87 PRAGMA writable_schema=on;
49 UPDATE sqlite_master SET sql='nonsense'; 88 UPDATE sqlite_master SET sql='nonsense' WHERE name='t1d'
50 } 89 }
51 db close 90 db close
52 catch { sqlite3 db test.db } 91 catch { sqlite3 db test.db }
53 catchsql { DROP INDEX i1 } 92 catchsql { DROP INDEX t1c }
54 } {1 {malformed database schema (t1) - near "nonsense": syntax error}} 93 } {1 {malformed database schema (t1d)}}
55 94
56 finish_test 95 finish_test
OLDNEW
« no previous file with comments | « third_party/sqlite/src/test/index2.test ('k') | third_party/sqlite/src/test/index5.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698