3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
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.
10 #***********************************************************************
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.
18 set testdir [file dirname $argv0]
19 source $testdir/tester.tcl
21 # Table constraints should be separated by commas, but they do not have
26 CREATE TABLE t1(a,b,c, PRIMARY KEY(a) UNIQUE (a) CONSTRAINT one);
27 INSERT INTO t1 VALUES(1,2,3);
32 catchsql {INSERT INTO t1 VALUES(1,3,4);}
33 } {1 {UNIQUE constraint failed: t1.a}}
37 CREATE TABLE t1(a,b,c,
38 CONSTRAINT one PRIMARY KEY(a) CONSTRAINT two CHECK(b<10) UNIQUE(b)
41 INSERT INTO t1 VALUES(1,2,3);
46 catchsql {INSERT INTO t1 VALUES(10,11,12);}
47 } {1 {CHECK constraint failed: two}}
51 CREATE TABLE t1(a,b,c,
52 UNIQUE(a) CONSTRAINT one,
53 PRIMARY KEY(b,c) CONSTRAINT two
55 INSERT INTO t1 VALUES(1,2,3);
59 catchsql {INSERT INTO t1 VALUES(1,3,4)}
60 } {1 {UNIQUE constraint failed: t1.a}}
62 catchsql {INSERT INTO t1 VALUES(10,2,3)}
63 } {1 {UNIQUE constraint failed: t1.b, t1.c}}