| OLD | NEW |
| (Empty) |
| 1 # 2010 September 28 | |
| 2 # | |
| 3 # The author disclaims copyright to this source code. In place of | |
| 4 # a legal notice, here is a blessing: | |
| 5 # | |
| 6 # May you do good and not evil. | |
| 7 # May you find forgiveness for yourself and forgive others. | |
| 8 # May you share freely, never taking more than you give. | |
| 9 # | |
| 10 #*********************************************************************** | |
| 11 # | |
| 12 # This file checks corner cases in the CREATE TABLE syntax to make | |
| 13 # sure that legacy syntax (syntax that is disallowed according to the | |
| 14 # syntax diagrams) is still accepted, so that older databases that use | |
| 15 # that syntax can still be read. | |
| 16 # | |
| 17 | |
| 18 set testdir [file dirname $argv0] | |
| 19 source $testdir/tester.tcl | |
| 20 | |
| 21 # Table constraints should be separated by commas, but they do not have | |
| 22 # to be. | |
| 23 # | |
| 24 do_test schema5-1.1 { | |
| 25 db eval { | |
| 26 CREATE TABLE t1(a,b,c, PRIMARY KEY(a) UNIQUE (a) CONSTRAINT one); | |
| 27 INSERT INTO t1 VALUES(1,2,3); | |
| 28 SELECT * FROM t1; | |
| 29 } | |
| 30 } {1 2 3} | |
| 31 do_test schema5-1.2 { | |
| 32 catchsql {INSERT INTO t1 VALUES(1,3,4);} | |
| 33 } {1 {UNIQUE constraint failed: t1.a}} | |
| 34 do_test schema5-1.3 { | |
| 35 db eval { | |
| 36 DROP TABLE t1; | |
| 37 CREATE TABLE t1(a,b,c, | |
| 38 CONSTRAINT one PRIMARY KEY(a) CONSTRAINT two CHECK(b<10) UNIQUE(b) | |
| 39 CONSTRAINT three | |
| 40 ); | |
| 41 INSERT INTO t1 VALUES(1,2,3); | |
| 42 SELECT * FROM t1; | |
| 43 } | |
| 44 } {1 2 3} | |
| 45 do_test schema5-1.4 { | |
| 46 catchsql {INSERT INTO t1 VALUES(10,11,12);} | |
| 47 } {1 {CHECK constraint failed: two}} | |
| 48 do_test schema5-1.5 { | |
| 49 db eval { | |
| 50 DROP TABLE t1; | |
| 51 CREATE TABLE t1(a,b,c, | |
| 52 UNIQUE(a) CONSTRAINT one, | |
| 53 PRIMARY KEY(b,c) CONSTRAINT two | |
| 54 ); | |
| 55 INSERT INTO t1 VALUES(1,2,3); | |
| 56 } | |
| 57 } {} | |
| 58 do_test schema5-1.6 { | |
| 59 catchsql {INSERT INTO t1 VALUES(1,3,4)} | |
| 60 } {1 {UNIQUE constraint failed: t1.a}} | |
| 61 do_test schema5-1.7 { | |
| 62 catchsql {INSERT INTO t1 VALUES(10,2,3)} | |
| 63 } {1 {UNIQUE constraint failed: t1.b, t1.c}} | |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 finish_test | |
| OLD | NEW |