From: drh Date: Thu, 8 Jun 2000 15:10:46 +0000 (+0000) Subject: :-) (CVS 81) X-Git-Tag: version-3.6.10~6019 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4cfa793437906e51f6b6a86ecb87a6d3a726a8e2;p=thirdparty%2Fsqlite.git :-) (CVS 81) FossilOrigin-Name: 61c381e7e6c85619b7b494417956fc209c5b7b84 --- diff --git a/manifest b/manifest index 71f5116089..c1cc5833ee 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C remove\sall\smemory\sleaks\s(CVS\s80) -D 2000-06-08T13:36:40 +C :-)\s(CVS\s81) +D 2000-06-08T15:10:47 F COPYRIGHT 74a8a6531a42e124df07ab5599aad63870fa0bd4 F Makefile.in 17ba1ccf8d2d40c627796bba8f72952365d6d644 F README 51f6a4e7408b34afa5bc1c0485f61b6a4efb6958 @@ -7,14 +7,14 @@ F configure 00a5b5c82147a576fa6e82d7c1b0d55c321d6d2c x F configure.in 6ccfd5fc80517f7cfe605a7fc7e0f62d962a233c F doc/lemon.html e233a3e97a779c7a87e1bc4528c664a58e49dd47 F src/build.c 925a785da2758269cb8773691e157ea5269178ba -F src/dbbe.c 9b191b16ff01ec5bc0af436558501d07938ba4f0 +F src/dbbe.c 4129779d7199c05200482046182f718a122f8c96 F src/dbbe.h a8a46f71238e0f09f3ec08fd9d1c8c7f4cdc49bf F src/delete.c c267b93f7ccb5493b677fa18201880267c699aa8 -F src/expr.c 8c79de4d19081fe81765dac47bd496c32b606369 +F src/expr.c 5790665132658362f1416755cc4060215c781e90 F src/insert.c ac4edfff474589c00b2490f206317dc5822122e5 F src/main.c e3297835b8e38ca726ac73f2c2bdb7cf08103197 -F src/parse.y e6c61f20620b4a331fecb5217eb556ac41aa441c -F src/select.c b1ffe8e6a03540f690c3749c9c12257fca3463bc +F src/parse.y 389687d20f2ac914205ebbd58cef72b8c70322b2 +F src/select.c 3a12d76074fa57d7c39c4436bdeb8d7e1eb6fdf4 F src/shell.c 3f4afc39a36e4824e8aa262623fd03568874799e F src/sqlite.h 58da0a8590133777b741f9836beaef3d58f40268 F src/sqliteInt.h 0aac58ed2e9fe46f24411e2e012fe85cd3457129 @@ -22,13 +22,13 @@ F src/tclsqlite.c 9f358618ae803bedf4fb96da5154fd45023bc1f7 F src/tokenize.c cb9eacd12548ee1ae7089eb3177b38851d7f0a1f F src/update.c d8d90df714bac99c68446a0c49f3d957ca6fc3c8 F src/util.c 38e4bb5edf6fa92e677698c45785bf73c69b9e9f -F src/vdbe.c 37f3b0824f90bfe3001dcf337bafb982f9d1b025 +F src/vdbe.c 8a92c95cf66ff67e8fc122d6892b08b0e7801d9c F src/vdbe.h 8f79f57c66ce1030f6371ff067b326d627a52c6d F src/where.c c9b90e7672f4662a83ef9a27a193020d69fe034c F test/all.test 0950c135cab7e60c07bd745ccfad1476211e5bd7 F test/copy.test b77a1214bd7756f2849d5c4fa6e715c0ff0c34eb -F test/dbbe.test 3978ab21ff2a0531a85618c538d27047d560fc5d -F test/delete.test 30451333f89479d2deb5410edd3f3cce67339944 +F test/dbbe.test 0a8e4293cf816e590dcbb01be4cd4e8f7f95bdc8 +F test/delete.test 30edd2c7484274fb2e7dbc4a1ac769bb330b322e F test/expr.test 7d017f1aa64c981b161408a015424cd90592bc16 F test/in.test 962a605b6a3a619214f84d1950dfc44fcf0d8b8f F test/index.test 9f99dca2d904b8de330863a978587f136e2df65a @@ -37,12 +37,12 @@ F test/insert2.test 732405e30331635af8d159fccabe835eea5cd0c6 F test/main.test cf1e9035aca55da9ef6d3b73ab36c54b7514b83f F test/select1.test 64703852af34c85bb31b0a74bd73b340e8267f42 F test/select2.test 3cd3c0f9d67e98b1b54af5853679b4a111224410 -F test/select3.test 73ae8c7b80c4e03a9c29d12f2ea1782e28b8e61f -F test/select4.test 5d6aa52fde345c51784202159bf9695cd9cc68b7 +F test/select3.test a9234b8424b6c6d71de534f43b91ade9be68e9cc +F test/select4.test cb5374d7c87680e294ac749307459a5cc547609d F test/select5.test b6f8b6bef467764a3edaea4e7cb9b0eb8f02ccd8 F test/sort.test d582086c4bb7df3fbf50aa72e69d7e235e9f8e31 F test/subselect.test bf8b251a92fb091973c1c469ce499dc9648a41d5 -F test/table.test 85d6f410d127ec508c6640f02d7c40d218414e81 +F test/table.test d3e01e4916a99ade7d8f1d534ee1b36d57c00490 F test/tester.tcl 95b286791e6256bb6db0165f9342c70fff549a62 F test/update.test 69459302ea75cafac1479e60b0e36efb88123c0e F test/vacuum.test 8becf5cfeb897108b35cdd996793e7f1df2f28fd @@ -57,7 +57,7 @@ F www/c_interface.tcl 9ac800854272db5fe439e07b7435b243a5422293 F www/changes.tcl 04e66b4257589ff78a7e1de93e9dda4725fb03d6 F www/index.tcl 52e29a4eeda8d59e91af43c61fef177c5f2ffd53 F www/sqlite.tcl 2f933ce18cffd34a0a020a82435ab937137970fd -P 305b043f4f71278d6d2c32e6e457f63efefae20d -R 2e8cf1a074c330c6453a374880c3eab1 +P bf98cf82a73c54c4eced04994bb1a019844dfc03 +R 147a3f5a92c9643c1c974e90b0fb5f44 U drh -Z f0a43ffe3166fea312bf9330021c453e +Z 583fb9f51c189b28ce13ee596d8aedf2 diff --git a/manifest.uuid b/manifest.uuid index 58b0a76d00..4d60e0e2ad 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bf98cf82a73c54c4eced04994bb1a019844dfc03 \ No newline at end of file +61c381e7e6c85619b7b494417956fc209c5b7b84 \ No newline at end of file diff --git a/src/dbbe.c b/src/dbbe.c index cce7b3c37d..3b3f4033f9 100644 --- a/src/dbbe.c +++ b/src/dbbe.c @@ -30,7 +30,7 @@ ** relatively simple to convert to a different database such ** as NDBM, SDBM, or BerkeleyDB. ** -** $Id: dbbe.c,v 1.12 2000/06/07 14:42:26 drh Exp $ +** $Id: dbbe.c,v 1.13 2000/06/08 15:10:47 drh Exp $ */ #include "sqliteInt.h" #include @@ -312,7 +312,11 @@ int sqliteDbbeOpenTable( return SQLITE_NOMEM; } if( zFile ){ - pFile->dbf = gdbm_open(zFile, 0, rw_mask, mode, 0); + if( !writeable || pBe->write ){ + pFile->dbf = gdbm_open(zFile, 0, rw_mask, mode, 0); + }else{ + pFile->dbf = 0; + } }else{ int limit; struct rc4 *pRc4; @@ -339,7 +343,9 @@ int sqliteDbbeOpenTable( pBe->pOpen = pFile; if( pFile->dbf==0 ){ if( !writeable && access(zFile,0) ){ - rc = SQLITE_OK; + /* Trying to read a non-existant file. This is OK. All the + ** reads will return empty, which is what we want. */ + rc = SQLITE_OK; }else if( access(zFile,W_OK|R_OK) ){ rc = SQLITE_PERM; }else{ diff --git a/src/expr.c b/src/expr.c index a3200eb4d9..d487ca3a4b 100644 --- a/src/expr.c +++ b/src/expr.c @@ -23,7 +23,7 @@ ************************************************************************* ** This file contains C code routines used for processing expressions ** -** $Id: expr.c,v 1.13 2000/06/08 13:36:40 drh Exp $ +** $Id: expr.c,v 1.14 2000/06/08 15:10:47 drh Exp $ */ #include "sqliteInt.h" @@ -400,7 +400,8 @@ int sqliteExprCheck(Parse *pParse, Expr *pExpr, int allowAgg, int *pIsAgg){ if( is_agg ) pExpr->op = TK_AGG_FUNCTION; if( is_agg && pIsAgg ) *pIsAgg = 1; for(i=0; nErr==0 && ipList->a[i].pExpr, 0, 0); + nErr = sqliteExprCheck(pParse, pExpr->pList->a[i].pExpr, + allowAgg && !is_agg, pIsAgg); } } default: { diff --git a/src/parse.y b/src/parse.y index 5b58983021..69f75e9525 100644 --- a/src/parse.y +++ b/src/parse.y @@ -26,7 +26,7 @@ ** the parser. Lemon will also generate a header file containing ** numeric codes for all of the tokens. ** -** @(#) $Id: parse.y,v 1.17 2000/06/08 13:36:40 drh Exp $ +** @(#) $Id: parse.y,v 1.18 2000/06/08 15:10:47 drh Exp $ */ %token_prefix TK_ %token_type {Token} @@ -83,14 +83,14 @@ id(A) ::= STRING(X). {A = X;} type ::= typename. type ::= typename LP signed RP. type ::= typename LP signed COMMA signed RP. -typename ::= ID. -typename ::= typename ID. +typename ::= id. +typename ::= typename id. signed ::= INTEGER. signed ::= PLUS INTEGER. signed ::= MINUS INTEGER. carglist ::= carglist carg. carglist ::= . -carg ::= CONSTRAINT ID ccons. +carg ::= CONSTRAINT id ccons. carg ::= ccons. carg ::= DEFAULT STRING(X). {sqliteAddDefaultValue(pParse,&X,0);} carg ::= DEFAULT ID(X). {sqliteAddDefaultValue(pParse,&X,0);} @@ -117,7 +117,7 @@ conslist_opt ::= . conslist_opt ::= COMMA conslist. conslist ::= conslist COMMA tcons. conslist ::= tcons. -tcons ::= CONSTRAINT ID tcons2. +tcons ::= CONSTRAINT id tcons2. tcons ::= tcons2. tcons2 ::= PRIMARY KEY LP idxlist(X) RP. {sqliteCreateIndex(pParse,0,0,X,0,0);} @@ -178,9 +178,7 @@ sclp(A) ::= selcollist(X) COMMA. {A = X;} sclp(A) ::= . {A = 0;} selcollist(A) ::= STAR. {A = 0;} selcollist(A) ::= sclp(P) expr(X). {A = sqliteExprListAppend(P,X,0);} -selcollist(A) ::= sclp(P) expr(X) as ID(Y). {A = sqliteExprListAppend(P,X,&Y);} -selcollist(A) ::= sclp(P) expr(X) as STRING(Y). - {A = sqliteExprListAppend(P,X,&Y);} +selcollist(A) ::= sclp(P) expr(X) as id(Y). {A = sqliteExprListAppend(P,X,&Y);} as ::= . as ::= AS. @@ -236,7 +234,7 @@ having_opt(A) ::= . {A = 0;} having_opt(A) ::= HAVING expr(X). {A = X;} -cmd ::= DELETE FROM ID(X) where_opt(Y). +cmd ::= DELETE FROM id(X) where_opt(Y). {sqliteDeleteFrom(pParse, &X, Y);} %type where_opt {Expr*} @@ -248,16 +246,16 @@ where_opt(A) ::= WHERE expr(X). {A = X;} %type setlist {ExprList*} %destructor setlist {sqliteExprListDelete($$);} -cmd ::= UPDATE ID(X) SET setlist(Y) where_opt(Z). +cmd ::= UPDATE id(X) SET setlist(Y) where_opt(Z). {sqliteUpdate(pParse,&X,Y,Z);} -setlist(A) ::= ID(X) EQ expr(Y) COMMA setlist(Z). +setlist(A) ::= id(X) EQ expr(Y) COMMA setlist(Z). {A = sqliteExprListAppend(Z,Y,&X);} -setlist(A) ::= ID(X) EQ expr(Y). {A = sqliteExprListAppend(0,Y,&X);} +setlist(A) ::= id(X) EQ expr(Y). {A = sqliteExprListAppend(0,Y,&X);} -cmd ::= INSERT INTO ID(X) fieldlist_opt(F) VALUES LP itemlist(Y) RP. +cmd ::= INSERT INTO id(X) fieldlist_opt(F) VALUES LP itemlist(Y) RP. {sqliteInsert(pParse, &X, Y, 0, F);} -cmd ::= INSERT INTO ID(X) fieldlist_opt(F) select(S). +cmd ::= INSERT INTO id(X) fieldlist_opt(F) select(S). {sqliteInsert(pParse, &X, 0, S, F);} @@ -290,8 +288,8 @@ item(A) ::= NULL. {A = sqliteExpr(TK_NULL, 0, 0, 0);} fieldlist_opt(A) ::= . {A = 0;} fieldlist_opt(A) ::= LP fieldlist(X) RP. {A = X;} -fieldlist(A) ::= fieldlist(X) COMMA ID(Y). {A = sqliteIdListAppend(X,&Y);} -fieldlist(A) ::= ID(Y). {A = sqliteIdListAppend(0,&Y);} +fieldlist(A) ::= fieldlist(X) COMMA id(Y). {A = sqliteIdListAppend(X,&Y);} +fieldlist(A) ::= id(Y). {A = sqliteIdListAppend(0,&Y);} %left OR. %left AND. @@ -308,7 +306,7 @@ fieldlist(A) ::= ID(Y). {A = sqliteIdListAppend(0,&Y);} expr(A) ::= LP expr(X) RP. {A = X;} expr(A) ::= ID(X). {A = sqliteExpr(TK_ID, 0, 0, &X);} expr(A) ::= NULL. {A = sqliteExpr(TK_NULL, 0, 0, 0);} -expr(A) ::= ID(X) DOT ID(Y). {Expr *temp1 = sqliteExpr(TK_ID, 0, 0, &X); +expr(A) ::= id(X) DOT id(Y). {Expr *temp1 = sqliteExpr(TK_ID, 0, 0, &X); Expr *temp2 = sqliteExpr(TK_ID, 0, 0, &Y); A = sqliteExpr(TK_DOT, temp1, temp2, 0);} expr(A) ::= INTEGER(X). {A = sqliteExpr(TK_INTEGER, 0, 0, &X);} @@ -393,7 +391,7 @@ expritem(A) ::= expr(X). {A = X;} expritem(A) ::= . {A = 0;} -cmd ::= CREATE(S) uniqueflag INDEX ID(X) ON ID(Y) LP idxlist(Z) RP(E). +cmd ::= CREATE(S) uniqueflag INDEX id(X) ON id(Y) LP idxlist(Z) RP(E). {sqliteCreateIndex(pParse, &X, &Y, Z, &S, &E);} uniqueflag ::= UNIQUE. uniqueflag ::= . @@ -406,7 +404,7 @@ idxlist(A) ::= idxlist(X) COMMA idxitem(Y). {A = sqliteIdListAppend(X,&Y);} idxlist(A) ::= idxitem(Y). {A = sqliteIdListAppend(0,&Y);} -idxitem(A) ::= ID(X). {A = X;} +idxitem(A) ::= id(X). {A = X;} cmd ::= DROP INDEX id(X). {sqliteDropIndex(pParse, &X);} diff --git a/src/select.c b/src/select.c index 58b35ce1a7..8d716bd3f6 100644 --- a/src/select.c +++ b/src/select.c @@ -24,7 +24,7 @@ ** This file contains C code routines that are called by the parser ** to handle SELECT statements. ** -** $Id: select.c,v 1.22 2000/06/08 13:36:40 drh Exp $ +** $Id: select.c,v 1.23 2000/06/08 15:10:48 drh Exp $ */ #include "sqliteInt.h" @@ -377,8 +377,8 @@ static int matchOrderbyToColumn( int match = 0; if( pOrderBy->a[i].done ) continue; for(j=0; jnExpr; j++){ - if( pEList->a[i].zName && (pE->op==TK_ID || pE->op==TK_STRING) ){ - char *zName = pEList->a[i].zName; + if( pEList->a[j].zName && (pE->op==TK_ID || pE->op==TK_STRING) ){ + char *zName = pEList->a[j].zName; char *zLabel = sqliteStrNDup(pE->token.z, pE->token.n); sqliteDequote(zLabel); if( sqliteStrICmp(zName, zLabel)==0 ){ @@ -386,7 +386,7 @@ static int matchOrderbyToColumn( } sqliteFree(zLabel); } - if( match==0 && sqliteExprCompare(pE, pEList->a[i].pExpr) ){ + if( match==0 && sqliteExprCompare(pE, pEList->a[j].pExpr) ){ match = 1; } if( match ){ diff --git a/src/vdbe.c b/src/vdbe.c index 6fbb5bae98..332eb0b9f5 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -41,7 +41,7 @@ ** But other routines are also provided to help in building up ** a program instruction by instruction. ** -** $Id: vdbe.c,v 1.28 2000/06/08 13:36:41 drh Exp $ +** $Id: vdbe.c,v 1.29 2000/06/08 15:10:48 drh Exp $ */ #include "sqliteInt.h" #include @@ -1711,7 +1711,7 @@ int sqliteVdbeExec( } case SQLITE_READONLY: { sqliteSetString(pzErrMsg,"table ", pOp->p3, - " is already opened for reading", 0); + " is readonly", 0); break; } case SQLITE_NOMEM: { diff --git a/test/dbbe.test b/test/dbbe.test index c93b8bec1a..d7c2700e27 100644 --- a/test/dbbe.test +++ b/test/dbbe.test @@ -23,7 +23,7 @@ # This file implements regression tests for SQLite library. The # focus of this file is exercising the code in dbbe.c. # -# $Id: dbbe.test,v 1.1 2000/06/07 14:42:27 drh Exp $ +# $Id: dbbe.test,v 1.2 2000/06/08 15:10:48 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -119,4 +119,18 @@ do_test dbbe-2.1 { lappend r [execsql {SELECT * FROM t1}] } {1 1} +# Try to change a table after opening the database readonly +# +do_test dbbe-3.1 { + catch {db close} + file delete -force testdb + sqlite db testdb 0666 + execsql {CREATE TABLE t1(x int)} + db close + sqlite db testdb 0444 + set v [catch {execsql {INSERT INTO t1 VALUES(1)}} msg] + lappend v $msg +} {1 {write permission denied for table t1}} + + finish_test diff --git a/test/delete.test b/test/delete.test index d796361fe8..9bebd86fdf 100644 --- a/test/delete.test +++ b/test/delete.test @@ -23,7 +23,7 @@ # This file implements regression tests for SQLite library. The # focus of this file is testing the DELETE FROM statement. # -# $Id: delete.test,v 1.4 2000/06/03 19:19:42 drh Exp $ +# $Id: delete.test,v 1.5 2000/06/08 15:10:48 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -58,7 +58,7 @@ do_test delete-3.1b { } {1 2 2 4 4 16} do_test delete-3.1c { execsql {CREATE INDEX index1 ON table1(f1)} - execsql {DELETE FROM table1 WHERE f1=3} + execsql {DELETE FROM 'table1' WHERE f1=3} execsql {SELECT * FROM table1 ORDER BY f1} } {1 2 2 4 4 16} do_test delete-3.1d { diff --git a/test/select3.test b/test/select3.test index ceb9c64468..f77eae4b48 100644 --- a/test/select3.test +++ b/test/select3.test @@ -24,7 +24,7 @@ # focus of this file is testing aggregate functions and the # GROUP BY and HAVING clauses of SELECT statements. # -# $Id: select3.test,v 1.1 2000/06/06 18:00:16 drh Exp $ +# $Id: select3.test,v 1.2 2000/06/08 15:10:48 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -111,4 +111,19 @@ do_test select3-4.3 { } } {3 4 4 8 5 15} +do_test select3-5.1 { + execsql { + SELECT log, count(*), avg(n), max(n+log*2) FROM t1 + GROUP BY log + ORDER BY max(n+log*2), avg(n) + } +} {0 1 1 1 1 1 2 4 2 2 3.5 8 3 4 6.5 14 4 8 12.5 24 5 15 24 41} +do_test select3-5.2 { + execsql { + SELECT log, count(*), avg(n), max(n+log*2) FROM t1 + GROUP BY log + ORDER BY max(n+log*2), min(log,avg(n)) + } +} {0 1 1 1 1 1 2 4 2 2 3.5 8 3 4 6.5 14 4 8 12.5 24 5 15 24 41} + finish_test diff --git a/test/select4.test b/test/select4.test index 2a3dbeb6ab..c90bf7c316 100644 --- a/test/select4.test +++ b/test/select4.test @@ -24,7 +24,7 @@ # focus of this file is testing UNION, INTERSECT and EXCEPT operators # in SELECT statements. # -# $Id: select4.test,v 1.2 2000/06/08 01:55:31 drh Exp $ +# $Id: select4.test,v 1.3 2000/06/08 15:10:48 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -244,4 +244,21 @@ do_test select4-5.4 { lappend v $msg } {0 {1 2 2 3}} +do_test select4-6.1 { + execsql { + SELECT log, count(*) as cnt FROM t1 GROUP BY log + UNION + SELECT log, n FROM t1 WHERE n=7 + ORDER BY cnt, log; + } +} {0 1 1 1 2 2 3 4 3 7 4 8 5 15} +do_test select4-6.2 { + execsql { + SELECT log, count(*) FROM t1 GROUP BY log + UNION + SELECT log, n FROM t1 WHERE n=7 + ORDER BY count(*), log; + } +} {0 1 1 1 2 2 3 4 3 7 4 8 5 15} + finish_test diff --git a/test/table.test b/test/table.test index fb609bff81..8e9f98218c 100644 --- a/test/table.test +++ b/test/table.test @@ -23,7 +23,7 @@ # This file implements regression tests for SQLite library. The # focus of this file is testing the CREATE TABLE statement. # -# $Id: table.test,v 1.4 2000/05/30 16:27:05 drh Exp $ +# $Id: table.test,v 1.5 2000/06/08 15:10:48 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -113,7 +113,7 @@ do_test table-1.13 { # Verify that we cannot make two tables with the same name # do_test table-2.1 { - execsql {CREATE TABLE test2(one text)} + execsql {CREATE TABLE TEST2(one text)} set v [catch {execsql {CREATE TABLE test2(two text)}} msg] lappend v $msg } {1 {table test2 already exists}} @@ -285,4 +285,12 @@ do_test table-5.4 { execsql {SELECT name FROM sqlite_master} } {test1} +# Create a table with a goofy name +# +do_test table-6.1 { + execsql {CREATE TABLE 'Spaces In This Name!'(x int)} + execsql {INSERT INTO 'spaces in this name!' VALUES(1)} + set list [glob -nocomplain testdb/spaces*.tbl] +} {testdb/spaces+in+this+name+.tbl} + finish_test