Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Merge the table constraint parser fixes from trunk. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | winrt |
Files: | files | file ages | folders |
SHA1: |
12bb31dd6f0d8544406710d6f02f0b7c |
User & Date: | drh 2012-05-10 13:03:28.296 |
Context
2012-05-17
| ||
21:04 | Merge updates from trunk. (check-in: 224c65e4a5 user: mistachkin tags: winrt) | |
2012-05-10
| ||
13:03 | Merge the table constraint parser fixes from trunk. (check-in: 12bb31dd6f user: drh tags: winrt) | |
2012-05-08
| ||
11:17 | Further changes to constraint parsing to support legacy syntax. (check-in: 38bf90af1e user: drh tags: trunk) | |
2012-05-07
| ||
22:29 | Merge parser adjustments from the trunk. (check-in: 0d8b920b2c user: mistachkin tags: winrt) | |
Changes
Changes to src/parse.y.
︙ | ︙ | |||
335 336 337 338 339 340 341 | defer_subclause(A) ::= NOT DEFERRABLE init_deferred_pred_opt. {A = 0;} defer_subclause(A) ::= DEFERRABLE init_deferred_pred_opt(X). {A = X;} %type init_deferred_pred_opt {int} init_deferred_pred_opt(A) ::= . {A = 0;} init_deferred_pred_opt(A) ::= INITIALLY DEFERRED. {A = 1;} init_deferred_pred_opt(A) ::= INITIALLY IMMEDIATE. {A = 0;} | | | | > | | 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 | defer_subclause(A) ::= NOT DEFERRABLE init_deferred_pred_opt. {A = 0;} defer_subclause(A) ::= DEFERRABLE init_deferred_pred_opt(X). {A = X;} %type init_deferred_pred_opt {int} init_deferred_pred_opt(A) ::= . {A = 0;} 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 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). {sqlite3AddPrimaryKey(pParse,X,R,I,0);} tcons ::= UNIQUE LP idxlist(X) RP onconf(R). {sqlite3CreateIndex(pParse,0,0,0,X,R,0,0,0,0);} tcons ::= CHECK LP expr(E) RP onconf. |
︙ | ︙ |
Added test/schema5.test.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 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 |