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

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

Issue 901033002: Import SQLite 3.8.7.4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Chromium changes to support SQLite 3.8.7.4. 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 unified diff | Download patch
OLDNEW
1 # 2001 September 27 1 # 2001 September 27
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 #***********************************************************************
(...skipping 29 matching lines...) Expand all
40 } {0 {}} 40 } {0 {}}
41 do_test unique-1.2 { 41 do_test unique-1.2 {
42 catchsql { 42 catchsql {
43 INSERT INTO t1(a,b,c) VALUES(1,2,3) 43 INSERT INTO t1(a,b,c) VALUES(1,2,3)
44 } 44 }
45 } {0 {}} 45 } {0 {}}
46 do_test unique-1.3 { 46 do_test unique-1.3 {
47 catchsql { 47 catchsql {
48 INSERT INTO t1(a,b,c) VALUES(1,3,4) 48 INSERT INTO t1(a,b,c) VALUES(1,3,4)
49 } 49 }
50 } {1 {column a is not unique}} 50 } {1 {UNIQUE constraint failed: t1.a}}
51 verify_ex_errcode unique-1.3b SQLITE_CONSTRAINT_PRIMARYKEY
51 do_test unique-1.4 { 52 do_test unique-1.4 {
52 execsql { 53 execsql {
53 SELECT * FROM t1 ORDER BY a; 54 SELECT * FROM t1 ORDER BY a;
54 } 55 }
55 } {1 2 3} 56 } {1 2 3}
56 do_test unique-1.5 { 57 do_test unique-1.5 {
57 catchsql { 58 catchsql {
58 INSERT INTO t1(a,b,c) VALUES(3,2,4) 59 INSERT INTO t1(a,b,c) VALUES(3,2,4)
59 } 60 }
60 } {1 {column b is not unique}} 61 } {1 {UNIQUE constraint failed: t1.b}}
62 verify_ex_errcode unique-1.5b SQLITE_CONSTRAINT_UNIQUE
61 do_test unique-1.6 { 63 do_test unique-1.6 {
62 execsql { 64 execsql {
63 SELECT * FROM t1 ORDER BY a; 65 SELECT * FROM t1 ORDER BY a;
64 } 66 }
65 } {1 2 3} 67 } {1 2 3}
66 do_test unique-1.7 { 68 do_test unique-1.7 {
67 catchsql { 69 catchsql {
68 INSERT INTO t1(a,b,c) VALUES(3,4,5) 70 INSERT INTO t1(a,b,c) VALUES(3,4,5)
69 } 71 }
70 } {0 {}} 72 } {0 {}}
(...skipping 20 matching lines...) Expand all
91 } {0 {}} 93 } {0 {}}
92 do_test unique-2.2 { 94 do_test unique-2.2 {
93 catchsql { 95 catchsql {
94 SELECT * FROM t2 ORDER BY a 96 SELECT * FROM t2 ORDER BY a
95 } 97 }
96 } {0 {1 2 3 4}} 98 } {0 {1 2 3 4}}
97 do_test unique-2.3 { 99 do_test unique-2.3 {
98 catchsql { 100 catchsql {
99 INSERT INTO t2 VALUES(1,5); 101 INSERT INTO t2 VALUES(1,5);
100 } 102 }
101 } {1 {column a is not unique}} 103 } {1 {UNIQUE constraint failed: t2.a}}
104 verify_ex_errcode unique-2.3b SQLITE_CONSTRAINT_UNIQUE
102 do_test unique-2.4 { 105 do_test unique-2.4 {
103 catchsql { 106 catchsql {
104 SELECT * FROM t2 ORDER BY a 107 SELECT * FROM t2 ORDER BY a
105 } 108 }
106 } {0 {1 2 3 4}} 109 } {0 {1 2 3 4}}
107 do_test unique-2.5 { 110 do_test unique-2.5 {
108 catchsql { 111 catchsql {
109 DROP INDEX i2; 112 DROP INDEX i2;
110 SELECT * FROM t2 ORDER BY a; 113 SELECT * FROM t2 ORDER BY a;
111 } 114 }
112 } {0 {1 2 3 4}} 115 } {0 {1 2 3 4}}
113 do_test unique-2.6 { 116 do_test unique-2.6 {
114 catchsql { 117 catchsql {
115 INSERT INTO t2 VALUES(1,5) 118 INSERT INTO t2 VALUES(1,5)
116 } 119 }
117 } {0 {}} 120 } {0 {}}
118 do_test unique-2.7 { 121 do_test unique-2.7 {
119 catchsql { 122 catchsql {
120 SELECT * FROM t2 ORDER BY a, b; 123 SELECT * FROM t2 ORDER BY a, b;
121 } 124 }
122 } {0 {1 2 1 5 3 4}} 125 } {0 {1 2 1 5 3 4}}
123 do_test unique-2.8 { 126 do_test unique-2.8 {
124 catchsql { 127 catchsql {
125 CREATE UNIQUE INDEX i2 ON t2(a); 128 CREATE UNIQUE INDEX i2 ON t2(a);
126 } 129 }
127 } {1 {indexed columns are not unique}} 130 } {1 {UNIQUE constraint failed: t2.a}}
131 verify_ex_errcode unique-2.8b SQLITE_CONSTRAINT_UNIQUE
128 do_test unique-2.9 { 132 do_test unique-2.9 {
129 catchsql { 133 catchsql {
130 CREATE INDEX i2 ON t2(a); 134 CREATE INDEX i2 ON t2(a);
131 } 135 }
132 } {0 {}} 136 } {0 {}}
133 integrity_check unique-2.10 137 integrity_check unique-2.10
134 138
135 # Test the UNIQUE keyword as used on two or more fields. 139 # Test the UNIQUE keyword as used on two or more fields.
136 # 140 #
137 do_test unique-3.1 { 141 do_test unique-3.1 {
(...skipping 17 matching lines...) Expand all
155 catchsql { 159 catchsql {
156 INSERT INTO t3(a,b,c,d) VALUES(1,2,3,5); 160 INSERT INTO t3(a,b,c,d) VALUES(1,2,3,5);
157 SELECT * FROM t3 ORDER BY a,b,c,d; 161 SELECT * FROM t3 ORDER BY a,b,c,d;
158 } 162 }
159 } {0 {1 2 3 4 1 2 3 5}} 163 } {0 {1 2 3 4 1 2 3 5}}
160 do_test unique-3.4 { 164 do_test unique-3.4 {
161 catchsql { 165 catchsql {
162 INSERT INTO t3(a,b,c,d) VALUES(1,4,3,5); 166 INSERT INTO t3(a,b,c,d) VALUES(1,4,3,5);
163 SELECT * FROM t3 ORDER BY a,b,c,d; 167 SELECT * FROM t3 ORDER BY a,b,c,d;
164 } 168 }
165 } {1 {columns a, c, d are not unique}} 169 } {1 {UNIQUE constraint failed: t3.a, t3.c, t3.d}}
170 verify_ex_errcode unique-3.4b SQLITE_CONSTRAINT_UNIQUE
166 integrity_check unique-3.5 171 integrity_check unique-3.5
167 172
168 # Make sure NULLs are distinct as far as the UNIQUE tests are 173 # Make sure NULLs are distinct as far as the UNIQUE tests are
169 # concerned. 174 # concerned.
170 # 175 #
171 do_test unique-4.1 { 176 do_test unique-4.1 {
172 execsql { 177 execsql {
173 CREATE TABLE t4(a UNIQUE, b, c, UNIQUE(b,c)); 178 CREATE TABLE t4(a UNIQUE, b, c, UNIQUE(b,c));
174 INSERT INTO t4 VALUES(1,2,3); 179 INSERT INTO t4 VALUES(1,2,3);
175 INSERT INTO t4 VALUES(NULL, 2, NULL); 180 INSERT INTO t4 VALUES(NULL, 2, NULL);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 execsql {SELECT * FROM t4} 214 execsql {SELECT * FROM t4}
210 } {1 2 3 {} 2 {} {} 3 4 2 2 {} {} 2 {}} 215 } {1 2 3 {} 2 {} {} 3 4 2 2 {} {} 2 {}}
211 do_test unique-4.8 { 216 do_test unique-4.8 {
212 catchsql {CREATE UNIQUE INDEX i4a ON t4(a,b)} 217 catchsql {CREATE UNIQUE INDEX i4a ON t4(a,b)}
213 } {0 {}} 218 } {0 {}}
214 do_test unique-4.9 { 219 do_test unique-4.9 {
215 catchsql {CREATE UNIQUE INDEX i4b ON t4(a,b,c)} 220 catchsql {CREATE UNIQUE INDEX i4b ON t4(a,b,c)}
216 } {0 {}} 221 } {0 {}}
217 do_test unique-4.10 { 222 do_test unique-4.10 {
218 catchsql {CREATE UNIQUE INDEX i4c ON t4(b)} 223 catchsql {CREATE UNIQUE INDEX i4c ON t4(b)}
219 } {1 {indexed columns are not unique}} 224 } {1 {UNIQUE constraint failed: t4.b}}
225 verify_ex_errcode unique-4.10b SQLITE_CONSTRAINT_UNIQUE
220 integrity_check unique-4.99 226 integrity_check unique-4.99
221 227
222 # Test the error message generation logic. In particular, make sure we 228 # Test the error message generation logic. In particular, make sure we
223 # do not overflow the static buffer used to generate the error message. 229 # do not overflow the static buffer used to generate the error message.
224 # 230 #
225 do_test unique-5.1 { 231 do_test unique-5.1 {
226 execsql { 232 execsql {
227 CREATE TABLE t5( 233 CREATE TABLE t5(
228 first_column_with_long_name, 234 first_column_with_long_name,
229 second_column_with_long_name, 235 second_column_with_long_name,
(...skipping 11 matching lines...) Expand all
241 ) 247 )
242 ); 248 );
243 INSERT INTO t5 VALUES(1,2,3,4,5,6); 249 INSERT INTO t5 VALUES(1,2,3,4,5,6);
244 SELECT * FROM t5; 250 SELECT * FROM t5;
245 } 251 }
246 } {1 2 3 4 5 6} 252 } {1 2 3 4 5 6}
247 do_test unique-5.2 { 253 do_test unique-5.2 {
248 catchsql { 254 catchsql {
249 INSERT INTO t5 VALUES(1,2,3,4,5,6); 255 INSERT INTO t5 VALUES(1,2,3,4,5,6);
250 } 256 }
251 } {1 {columns first_column_with_long_name, second_column_with_long_name, third_c olumn_with_long_name, fourth_column_with_long_name, fifth_column_with_long_name, sixth_column_with_long_name are not unique}} 257 } {1 {UNIQUE constraint failed: t5.first_column_with_long_name, t5.second_column _with_long_name, t5.third_column_with_long_name, t5.fourth_column_with_long_name , t5.fifth_column_with_long_name, t5.sixth_column_with_long_name}}
258 verify_ex_errcode unique-5.2b SQLITE_CONSTRAINT_UNIQUE
259
252 260
253 finish_test 261 finish_test
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698