Further changes to constraint parsing to support legacy syntax.

FossilOrigin-Name: 38bf90af1ede6ee64ef7be66392e895e60c9126e
This commit is contained in:
drh 2012-05-08 11:17:33 +00:00
parent 4dc330dd33
commit aeb281c2ea
4 changed files with 65 additions and 11 deletions

View File

@ -1,5 +1,5 @@
C Adjust\sthe\sparser\sso\sthat\scertain\slegacy\sschema\sconstructs\s(that\sare\snot\nvalid\saccording\sto\sthe\ssyntax\sdiagram)\scontinue\sto\sbe\saccepted,\sso\sthat\nolder\sdatabases\sthat\shappen\sto\suse\sthose\sconstructs\sare\sstill\sreadable.\nThis\sfixes\san\sissue\sintroduced\sby\scheck-in\s[1b75f301affac6]
D 2012-05-07T19:21:36.465
C Further\schanges\sto\sconstraint\sparsing\sto\ssupport\slegacy\ssyntax.
D 2012-05-08T11:17:33.934
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -163,7 +163,7 @@ F src/os_unix.c 424d46e0edab969293c2223f09923b2178171f47
F src/os_win.c 412d6434133c7c81dc48b7702f3ea5e61c309e5c
F src/pager.c bb5635dde0b152797836d1c72275284724bb563c
F src/pager.h ef1eaf8593e78f73885c1dfac27ad83bee23bdc5
F src/parse.y ad29af00e73d3afd84820f5738e072c506d8d77b
F src/parse.y de06f412a4b3a2978071215f657fd1cd70700444
F src/pcache.c f8043b433a57aba85384a531e3937a804432a346
F src/pcache.h 1b5dcc3dc8103d03e625b177023ee67764fa6b7c
F src/pcache1.c b30b1c35908346ecc43d8d9d17f2ddf6817f8f60
@ -667,6 +667,7 @@ F test/schema.test 8f7999be894260f151adf15c2c7540f1c6d6a481
F test/schema2.test 906408621ea881fdb496d878b1822572a34e32c5
F test/schema3.test 1bc1008e1f8cb5654b248c55f27249366eb7ed38
F test/schema4.test e6a66e20cc69f0e306667c08be7fda3d11707dc5
F test/schema5.test b583e6e24adef3dce804bed040f24dd5fe789159
F test/securedel.test 87a2561151af1f1e349071a89fdd77059f50113c
F test/select1.test deba017eed9daa5af33de868676c997e7eebb931
F test/select2.test 352480e0e9c66eda9c3044e412abdf5be0215b56
@ -995,7 +996,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
F tool/warnings-clang.sh a8a0a3babda96dfb1ff51adda3cbbf3dfb7266c2
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
P a4555a53eab3f5d2f142c78a6b71189544e80ae6
R b1ed928fe6d7cc7f56cb67cfef4cacc0
P a1c014d8a87c8940b3a037d8d8cc4d5678809802
R b6207703cdccfd3ac416f9da168138e7
U drh
Z a9d5fb0a817384840c4a8fbe0a536a67
Z c70e51594d9a44ff78a8a89d0fd856a7

View File

@ -1 +1 @@
a1c014d8a87c8940b3a037d8d8cc4d5678809802
38bf90af1ede6ee64ef7be66392e895e60c9126e

View File

@ -340,9 +340,10 @@ init_deferred_pred_opt(A) ::= INITIALLY DEFERRED. {A = 1;}
init_deferred_pred_opt(A) ::= INITIALLY IMMEDIATE. {A = 0;}
conslist_opt(A) ::= . {A.n = 0; A.z = 0;}
conslist_opt(A) ::= COMMA(X) conslist. {A = X;}
conslist ::= conslist COMMA cname tcons cname.
conslist ::= cname tcons cname.
conslist_opt(A) ::= COMMA(X) conslist cname. {A = X;}
conslist ::= conslist COMMA cname tcons.
conslist ::= conslist cname tcons.
conslist ::= cname tcons.
cname ::= . {pParse->constraintName.n = 0;}
cname ::= CONSTRAINT nm(X). {pParse->constraintName = X;}
tcons ::= PRIMARY KEY LP idxlist(X) autoinc(I) RP onconf(R).

52
test/schema5.test Normal file
View File

@ -0,0 +1,52 @@
# 2010 September 28
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
#
#***********************************************************************
#
# This file checks corner cases in the CREATE TABLE syntax to make
# sure that legacy syntax (syntax that is disallowed according to the
# syntax diagrams) is still accepted, so that older databases that use
# that syntax can still be read.
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# Table constraints should be separated by commas, but they do not have
# to be.
#
do_test schema5-1.1 {
db eval {
CREATE TABLE t1(a,b,c, PRIMARY KEY(a) UNIQUE (a) CONSTRAINT one);
INSERT INTO t1 VALUES(1,2,3);
SELECT * FROM t1;
}
} {1 2 3}
do_test schema5-1.2 {
catchsql {INSERT INTO t1 VALUES(1,3,4);}
} {1 {column a is not unique}}
do_test schema5-1.3 {
db eval {
DROP TABLE t1;
CREATE TABLE t1(a,b,c,
CONSTRAINT one PRIMARY KEY(a) CONSTRAINT two CHECK(b<10) UNIQUE(b)
CONSTRAINT three
);
INSERT INTO t1 VALUES(1,2,3);
SELECT * FROM t1;
}
} {1 2 3}
do_test schema5-1.4 {
catchsql {INSERT INTO t1 VALUES(10,11,12);}
} {1 {constraint two failed}}
finish_test