Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Further changes to constraint parsing to support legacy syntax. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
38bf90af1ede6ee64ef7be66392e895e |
User & Date: | drh 2012-05-08 11:17:33.934 |
References
2012-08-07
| ||
01:37 | Parser bug fix: Make sure the table constraints allowed by prior releases can still be parsed, even if they are technically not allowed by the syntax diagram. This is a cherry-pick of [a1c014d8a87c8940b3], [38bf90af1ede6ee64e], and [e536ac041815b118c4]. (Leaf check-in: 28aed847c6 user: drh tags: apple-osx-ml) | |
Context
2012-05-10
| ||
17:43 | Have the FTS auxiliary functions correctly handle terms that appear in non-matching branches of the FTS expression. Fix for [bdc6bbbb38]. (check-in: 4d3e1673b3 user: dan tags: trunk) | |
13:03 | Merge the table constraint parser fixes from trunk. (check-in: 12bb31dd6f user: drh tags: winrt) | |
12:17 | Merge in the windows AV-defense enhancements for open() and the table constraint parser fixes for legacy schemas, all from trunk. (check-in: 323570b8bd user: drh tags: sessions) | |
12:09 | Merge in the legacy table constraint parsing fixes from trunk. (check-in: e87702834e user: drh tags: apple-osx) | |
2012-05-08
| ||
11:17 | Further changes to constraint parsing to support legacy syntax. (check-in: 38bf90af1e user: drh tags: trunk) | |
2012-05-07
| ||
19:21 | Adjust the parser so that certain legacy schema constructs (that are not valid according to the syntax diagram) continue to be accepted, so that older databases that happen to use those constructs are still readable. This fixes an issue introduced by check-in [1b75f301affac6] (check-in: a1c014d8a8 user: drh tags: trunk) | |
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 |