From: danielk1977 Date: Tue, 8 May 2007 17:54:43 +0000 (+0000) Subject: Add a few more tests to sqllimit1.test. (CVS 3954) X-Git-Tag: version-3.4.0~127 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7a15a4beefa5c2cfe3b272d9a361cafec4740537;p=thirdparty%2Fsqlite.git Add a few more tests to sqllimit1.test. (CVS 3954) FossilOrigin-Name: eeee6b71e5643511320cbe15bafa170cfd02877f --- diff --git a/manifest b/manifest index 1df6ab118a..12485d1284 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\stest\scase\sthat\suses\sa\strigger\sto\sinsert\smany\srows\sto\ssqllimits1.test.\s(CVS\s3953) -D 2007-05-08T16:13:45 +C Add\sa\sfew\smore\stests\sto\ssqllimit1.test.\s(CVS\s3954) +D 2007-05-08T17:54:44 F Makefile.in 87b200ad9970907f76df734d29dff3d294c10935 F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028 @@ -70,7 +70,7 @@ F src/complete.c 7d1a44be8f37de125fcafd3d3a018690b3799675 F src/date.c 263ef5b81b4ffdd80e8a830645798967bbbcfd05 F src/delete.c 5c0d89b3ef7d48fe1f5124bfe8341f982747fe29 F src/experimental.c 1b2d1a6cd62ecc39610e97670332ca073c50792b -F src/expr.c 2f0f9f89efe9170e5e6ca5d5e93a9d5896fff5ac +F src/expr.c d593bbac8ede96d9a8d1b67a05c948db84c46e99 F src/func.c 1598afc91529eed0307e9581f852779efbc8d12d F src/hash.c 67b23e14f0257b69a3e8aa663e4eeadc1a2b6fd5 F src/hash.h 1b3f7e2609141fd571f62199fc38687d262e9564 @@ -94,7 +94,7 @@ F src/os_win.c 3b6169038101d06c54b4f04662bfd44b6cf2f289 F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b F src/pager.c c5b32e741fb73930b6ec3d886ea680a3de3be5f7 F src/pager.h db31691786504625e7e25c8cde4f40779ba209d9 -F src/parse.y efbca804082366871a11f5f272c17672186961d2 +F src/parse.y fe7efcbf0ef1727cb2c08c1a10869b4ac9d5e71d F src/pragma.c b881b457170d4922893f59b1caaac98f8e4192e2 F src/prepare.c c932f4398c3bf66fa366ad676c6f7e8ac5eaf7f6 F src/printf.c 67de0dcb40ef3297f4a047b434b81585c0f7062d @@ -104,7 +104,7 @@ F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96 F src/shell.c d07ae326b3815d80f71c69b3c7584382e47f6447 F src/sqlite.h.in 664b8702c27dc742584788823c548491ac8935d6 F src/sqlite3ext.h 7d0d363ea7327e817ef0dfe1b7eee1f171b72890 -F src/sqliteInt.h 2933fb3d045f85c481453276ed737bd7e65364d5 +F src/sqliteInt.h 9d74ad5f9f4abf72aa681c571253459d0953bdd7 F src/table.c a8de75bcedf84d4060d804264b067ab3b1a3561d F src/tclsqlite.c f425c7583665ef78dd8397b2de0b8e0028e80ce2 F src/test1.c 73edd70920e462bbc20885fec66a48b5cace0edc @@ -340,7 +340,7 @@ F test/shared_err.test cc528f6e78665787e93d9ce3a782a2ce5179d821 F test/sort.test 0e4456e729e5a92a625907c63dcdedfbe72c5dc5 F test/speed1.test 22e1b27af0683ed44dcd2f93ed817a9c3e65084a F test/speed2.test 53177056baf6556dcbdcf032bbdfc41c1aa74ded -F test/sqllimits1.test b88ffc18cf8a4bcb6608cacaa692ede4b7511a2a +F test/sqllimits1.test 02a33a7f6c0064be4e5133327975ce5e69342a4f F test/subquery.test ae324ee928c5fb463a3ce08a8860d6e7f1ca5797 F test/subselect.test 974e87f8fc91c5f00dd565316d396a5a6c3106c4 F test/sync.test d05397b8f89f423dd6dba528692019ab036bc1c3 @@ -486,7 +486,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5 -P c8974603976ebc02edbc9ab271e87e57f8eb365e -R 14fd5bdefc5c8b6717aa13ebe2e75f62 +P 6368222558d00f968b49f862bfe672573e86fbcf +R 541b5ed0a61fd6eb94981d0681be1b3d U danielk1977 -Z f532c476b7aaba8d810fc10e1b62322d +Z 321f5051478036089eb587718ff52d9f diff --git a/manifest.uuid b/manifest.uuid index b1d76be22a..71a6aa679c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6368222558d00f968b49f862bfe672573e86fbcf \ No newline at end of file +eeee6b71e5643511320cbe15bafa170cfd02877f \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index 09bea6b779..9808af930a 100644 --- a/src/expr.c +++ b/src/expr.c @@ -12,7 +12,7 @@ ** This file contains routines used for analyzing expressions and ** for generating VDBE code that evaluates expressions in SQLite. ** -** $Id: expr.c,v 1.285 2007/04/18 17:07:58 drh Exp $ +** $Id: expr.c,v 1.286 2007/05/08 17:54:44 danielk1977 Exp $ */ #include "sqliteInt.h" #include @@ -653,6 +653,21 @@ no_mem: return 0; } +/* +** If the expression list pEList contains more than iLimit elements, +** leave an error message in pParse. +*/ +void sqlite3ExprListCheckLength( + Parse *pParse, + ExprList *pEList, + int iLimit, + const char *zObject +){ + if( pEList->nExpr>iLimit ){ + sqlite3ErrorMsg(pParse, "too many columns in %s", zObject); + } +} + /* ** Delete an entire expression list. */ diff --git a/src/parse.y b/src/parse.y index 4cfd154bc1..a7e07b9a75 100644 --- a/src/parse.y +++ b/src/parse.y @@ -14,7 +14,7 @@ ** the parser. Lemon will also generate a header file containing ** numeric codes for all of the tokens. ** -** @(#) $Id: parse.y,v 1.223 2007/05/08 13:58:28 drh Exp $ +** @(#) $Id: parse.y,v 1.224 2007/05/08 17:54:44 danielk1977 Exp $ */ // All token codes are small integers with #defines that begin with "TK_" @@ -573,8 +573,10 @@ where_opt(A) ::= WHERE expr(X). {A = X;} ////////////////////////// The UPDATE command //////////////////////////////// // -cmd ::= UPDATE orconf(R) fullname(X) SET setlist(Y) where_opt(Z). - {sqlite3Update(pParse,X,Y,Z,R);} +cmd ::= UPDATE orconf(R) fullname(X) SET setlist(Y) where_opt(Z). { + sqlite3ExprListCheckLength(pParse,Y,SQLITE_MAX_COLUMN,"set list"); + sqlite3Update(pParse,X,Y,Z,R); +} %type setlist {ExprList*} %destructor setlist {sqlite3ExprListDelete($$);} @@ -878,6 +880,7 @@ idxlist(A) ::= idxlist(X) COMMA idxitem(Y) collate(C) sortorder(Z). { if( p ) p->pColl = sqlite3LocateCollSeq(pParse, (char*)C.z, C.n); } A = sqlite3ExprListAppend(X, p, &Y); + sqlite3ExprListCheckLength(pParse, A, SQLITE_MAX_COLUMN, "index"); if( A ) A->a[A->nExpr-1].sortOrder = Z; } idxlist(A) ::= idxitem(Y) collate(C) sortorder(Z). { @@ -887,6 +890,7 @@ idxlist(A) ::= idxitem(Y) collate(C) sortorder(Z). { if( p ) p->pColl = sqlite3LocateCollSeq(pParse, (char*)C.z, C.n); } A = sqlite3ExprListAppend(0, p, &Y); + sqlite3ExprListCheckLength(pParse, A, SQLITE_MAX_COLUMN, "index"); if( A ) A->a[A->nExpr-1].sortOrder = Z; } idxitem(A) ::= nm(X). {A = X;} diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 36079f5b05..c1c5c07d94 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -11,7 +11,7 @@ ************************************************************************* ** Internal interface definitions for SQLite. ** -** @(#) $Id: sqliteInt.h,v 1.559 2007/05/08 01:08:49 drh Exp $ +** @(#) $Id: sqliteInt.h,v 1.560 2007/05/08 17:54:44 danielk1977 Exp $ */ #ifndef _SQLITEINT_H_ #define _SQLITEINT_H_ @@ -1885,6 +1885,7 @@ int sqlite3VtabBegin(sqlite3 *, sqlite3_vtab *); FuncDef *sqlite3VtabOverloadFunction(FuncDef*, int nArg, Expr*); void sqlite3InvalidFunction(sqlite3_context*,int,sqlite3_value**); int sqlite3Reprepare(Vdbe*); +void sqlite3ExprListCheckLength(Parse*, ExprList*, int, const char*); u32 sqlite3Get2byte(const u8*); u32 sqlite3Get4byte(const u8*); diff --git a/test/sqllimits1.test b/test/sqllimits1.test index 09ee6be810..812b3763f2 100644 --- a/test/sqllimits1.test +++ b/test/sqllimits1.test @@ -12,7 +12,7 @@ # This file contains tests to verify that the limits defined in # sqlite source file limits.h are enforced. # -# $Id: sqllimits1.test,v 1.2 2007/05/08 16:13:45 danielk1977 Exp $ +# $Id: sqllimits1.test,v 1.3 2007/05/08 17:54:44 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -63,9 +63,7 @@ do_test sqllimits-3.1 { } } {1000} do_test sqllimits-3.2 { - execsql { - CREATE TABLE trig (a INTEGER, b INTEGER); - } + execsql { CREATE TABLE trig (a INTEGER, b INTEGER); } # Set up a tree of triggers to fire when a row is inserted # into table "trig". @@ -138,5 +136,60 @@ do_test sqllimits1-3.6 { } } {0 7} + +#-------------------------------------------------------------------- +# Test cases sqllimits1-4.* test the SQLITE_MAX_COLUMN limit. +# +do_test sqllimits-1.4.1 { + set cols [list] + for {set i 0} {$i <= $SQLITE_MAX_COLUMN} {incr i} { + lappend cols "c$i" + } + catchsql "CREATE TABLE t([join $cols ,])" +} {1 {too many columns on t}} + +do_test sqllimits-1.4.2 { + set cols [list] + for {set i 0} {$i <= $SQLITE_MAX_COLUMN} {incr i} { + lappend cols "sql AS sql$i" + } + catchsql "SELECT [join $cols ,] FROM sqlite_master" +} {1 {too many columns in result set}} + +do_test sqllimits-1.4.3 { + set cols [list] + for {set i 0} {$i <= $SQLITE_MAX_COLUMN} {incr i} { + lappend cols "sql AS sql$i" + } + catchsql "SELECT sql4 FROM (SELECT [join $cols ,] FROM sqlite_master)" +} {1 {too many columns in result set}} + +do_test sqllimits-1.4.4 { + set cols [list] + for {set i 0} {$i <= $SQLITE_MAX_COLUMN} {incr i} { + lappend cols c + } + set sql1 "CREATE TABLE t1(c);" + set sql2 "CREATE INDEX i1 ON t1([join $cols ,]);" + catchsql "$sql1 ; $sql2" +} {1 {too many columns in index}} + +do_test sqllimits-1.4.5 { + catchsql "SELECT * FROM t1 GROUP BY [join $cols ,]" +} {1 {too many terms in GROUP BY clause}} + +do_test sqllimits-1.4.6 { + catchsql "SELECT * FROM t1 ORDER BY [join $cols ,]" +} {1 {too many terms in ORDER BY clause}} + +do_test sqllimits-1.4.7 { + set cols [list] + for {set i 0} {$i <= $SQLITE_MAX_COLUMN} {incr i} { + lappend cols "c = 1" + } + catchsql "UPDATE t1 SET [join $cols ,];" +} {1 {too many columns in set list}} + finish_test +