OLD | NEW |
1 # 2013-10-30 | 1 # 2013-10-30 |
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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 | 270 |
271 do_execsql_test 5.6 { | 271 do_execsql_test 5.6 { |
272 CREATE INDEX i46 ON t46(c); | 272 CREATE INDEX i46 ON t46(c); |
273 } | 273 } |
274 | 274 |
275 foreach {tn cnt where eqp} $queries { | 275 foreach {tn cnt where eqp} $queries { |
276 do_execsql_test 5.7.$tn.1 "SELECT count(*) FROM t46 WHERE $where" $cnt | 276 do_execsql_test 5.7.$tn.1 "SELECT count(*) FROM t46 WHERE $where" $cnt |
277 do_eqp_test 5.7.$tn.2 "SELECT count(*) FROM t46 WHERE $where" $eqp | 277 do_eqp_test 5.7.$tn.2 "SELECT count(*) FROM t46 WHERE $where" $eqp |
278 } | 278 } |
279 | 279 |
| 280 #------------------------------------------------------------------------- |
| 281 # Check that redundant UNIQUE constraints do not cause a problem. |
| 282 # |
| 283 do_execsql_test 6.0 { |
| 284 CREATE TABLE t47(a, b UNIQUE PRIMARY KEY) WITHOUT ROWID; |
| 285 CREATE INDEX i47 ON t47(a); |
| 286 INSERT INTO t47 VALUES(1, 2); |
| 287 INSERT INTO t47 VALUES(2, 4); |
| 288 INSERT INTO t47 VALUES(3, 6); |
| 289 INSERT INTO t47 VALUES(4, 8); |
| 290 |
| 291 VACUUM; |
| 292 PRAGMA integrity_check; |
| 293 SELECT name FROM sqlite_master WHERE tbl_name = 't47'; |
| 294 } {ok t47 i47} |
| 295 |
| 296 do_execsql_test 6.1 { |
| 297 CREATE TABLE t48( |
| 298 a UNIQUE UNIQUE, |
| 299 b UNIQUE, |
| 300 PRIMARY KEY(a), |
| 301 UNIQUE(a) |
| 302 ) WITHOUT ROWID; |
| 303 INSERT INTO t48 VALUES('a', 'b'), ('c', 'd'), ('e', 'f'); |
| 304 VACUUM; |
| 305 PRAGMA integrity_check; |
| 306 SELECT name FROM sqlite_master WHERE tbl_name = 't48'; |
| 307 } { |
| 308 ok t48 sqlite_autoindex_t48_2 |
| 309 } |
| 310 |
| 311 # 2015-05-28: CHECK constraints can refer to the rowid in a |
| 312 # rowid table, but not in a WITHOUT ROWID table. |
| 313 # |
| 314 do_execsql_test 7.1 { |
| 315 CREATE TABLE t70a( |
| 316 a INT CHECK( rowid!=33 ), |
| 317 b TEXT PRIMARY KEY |
| 318 ); |
| 319 INSERT INTO t70a(a,b) VALUES(99,'hello'); |
| 320 } {} |
| 321 do_catchsql_test 7.2 { |
| 322 INSERT INTO t70a(rowid,a,b) VALUES(33,99,'xyzzy'); |
| 323 } {1 {CHECK constraint failed: t70a}} |
| 324 do_catchsql_test 7.3 { |
| 325 CREATE TABLE t70b( |
| 326 a INT CHECK( rowid!=33 ), |
| 327 b TEXT PRIMARY KEY |
| 328 ) WITHOUT ROWID; |
| 329 } {1 {no such column: rowid}} |
| 330 |
280 | 331 |
281 finish_test | 332 finish_test |
OLD | NEW |