diff --git a/VERSION b/VERSION index 04b10b4f15..ebf14b4698 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.1.7 +2.1.8 diff --git a/manifest b/manifest index 6f6ac49fc0..6e339f88a0 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Comment\sand\sdocumentation\schanges.\s(CVS\s331) -D 2001-12-15T14:22:19 +C Added\sthe\sability\sto\ssay\sthings\slike\s"SELECT\srowid,\s*\sFROM\stable1;"\s(CVS\s332) +D 2001-12-16T20:05:05 F Makefile.in 352fed589f09dd94347e0bb391d047118ebd6105 F Makefile.template 0fbf0ee1fe38183d760170a13e91fffec64e73f5 F README a4c0ba11354ef6ba0776b400d057c59da47a4cc0 -F VERSION b971ae09c25173d53f5df4cfc62821ff99fc1bfe +F VERSION 380c16915706a90410eb148b6266d51f0d49ad8b F aclocal.m4 11faa843caa38fd451bc6aeb43e248d1723a269d F config.guess f38b1e93d1e0fa6f5a6913e9e7b12774b9232588 F config.log 6a73d03433669b10a3f0c221198c3f26b9413914 @@ -33,10 +33,10 @@ F src/os.c 07882cde5c61f26751b8ee76fd84726c1f7e453c F src/os.h 00a18e0ae1139a64f1d3ead465ae2b9ff43f3db2 F src/pager.c dde0eb5bf9af0ac0ff8a4429b2bee2aec2194ec9 F src/pager.h f78d064c780855ff70beacbeba0e2324471b26fe -F src/parse.y 5295f393f41ea89958287e5738e6c12c7cd67482 +F src/parse.y 23ff6728eb2f5d3052fe8b1c311bfd55d9fb0944 F src/printf.c 300a90554345751f26e1fc0c0333b90a66110a1d F src/random.c 2a9cc2c9716d14815fd4c2accf89d87a1143e46b -F src/select.c fa1c7144a9ad7ce3f16373b443bc25e764af4be7 +F src/select.c 76a8fafb29935865ddbef263ee90f1398d950d8b F src/shell.c 407095aaeeae78f42deb3e846b1ad77f8ed3b4ef F src/shell.tcl 27ecbd63dd88396ad16d81ab44f73e6c0ea9d20e F src/sqlite.h.in 934de9112747ad8d8e7d5fec44876246b24ca5a3 @@ -76,7 +76,7 @@ F test/printf.test 3cb415073754cb8ff076f26173143c3cd293a9da F test/quick.test 6f023c7a73fc413e6d65b7a1879c79764038dc05 F test/quote.test 286db944717afa9a9bf829dd85e59185c65d5435 F test/rowid.test ba56df896cb913b70d06661d960869e310fe426e -F test/select1.test 13aa0a5545209a73d1073cb9062a1b9075b734ae +F test/select1.test 7423a9dbb81b6d282b13cbe10be64d1216dec155 F test/select2.test ed2c1882857106b85478f54f67000e14966be4c4 F test/select3.test 5e1fe8e5a4e63fb2827ab3b89527e0fd4ae35259 F test/select4.test 29a2ffb187f3d8b6ca42a0a6b619e9cabe12e228 @@ -104,7 +104,7 @@ F www/arch.fig d5f9752a4dbf242e9cfffffd3f5762b6c63b3bcf F www/arch.png 82ef36db1143828a7abc88b1e308a5f55d4336f4 F www/arch.tcl 72a0c80e9054cc7025a50928d28d9c75c02c2b8b F www/c_interface.tcl 58922228e8fdb0f6af3561a051ee8ccec6dbfd17 -F www/changes.tcl 0b921ad20b5dd262e5a9594691b9708a311e5912 +F www/changes.tcl 7718ad82090404f6a2a062dd534670996c2b82cc F www/crosscompile.tcl 3622ebbe518927a3854a12de51344673eb2dd060 F www/download.tcl 1ea61f9d89a2a5a9b2cee36b0d5cf97321bdefe0 F www/dynload.tcl 02eb8273aa78cfa9070dd4501dca937fb22b466c @@ -117,7 +117,7 @@ F www/speed.tcl 83457b2bf6bb430900bd48ca3dd98264d9a916a5 F www/sqlite.tcl 8b5884354cb615049aed83039f8dfe1552a44279 F www/tclsqlite.tcl 880ef67cb4f2797b95bf1368fc4e0d8ca0fda956 F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218 -P 0d44465347125c8e7e962ffb67213f9953a9b7ab -R f9524b24c72db56ae24d23e4dfe8d2a7 +P e8595579a5218aa3f344f967a23ac52ea89daca1 +R 0e3b3ee92605e01cba0081d64199478c U drh -Z c454c32fd5ff2d794a364b8c8ca2dfec +Z 9f8a16e7e900ed26b3f50785c874bb79 diff --git a/manifest.uuid b/manifest.uuid index 6b0bcea620..e6f44a8236 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e8595579a5218aa3f344f967a23ac52ea89daca1 \ No newline at end of file +ffbdd43f5de62e7bf81631c83473aca29c3a6c98 \ No newline at end of file diff --git a/src/parse.y b/src/parse.y index 86679e828c..f2a1897fd3 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.38 2001/11/06 04:00:18 drh Exp $ +** @(#) $Id: parse.y,v 1.39 2001/12/16 20:05:06 drh Exp $ */ %token_prefix TK_ %token_type {Token} @@ -198,8 +198,9 @@ distinct(A) ::= ALL. {A = 0;} distinct(A) ::= . {A = 0;} // selcollist is a list of expressions that are to become the return -// values of the SELECT statement. In the case of "SELECT * FROM ..." -// the selcollist value is NULL. +// values of the SELECT statement. The "*" in statements like +// "SELECT * FROM ..." is encoded as a special expression with an +// opcode of TK_ALL. // %type selcollist {ExprList*} %destructor selcollist {sqliteExprListDelete($$);} @@ -207,9 +208,11 @@ distinct(A) ::= . {A = 0;} %destructor sclp {sqliteExprListDelete($$);} 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 ids(Y). {A = sqliteExprListAppend(P,X,&Y);} +selcollist(A) ::= sclp(P) STAR. { + A = sqliteExprListAppend(P, sqliteExpr(TK_ALL, 0, 0, 0), 0); +} as ::= . as ::= AS. diff --git a/src/select.c b/src/select.c index b30172cb0a..2179cb5b4f 100644 --- a/src/select.c +++ b/src/select.c @@ -12,7 +12,7 @@ ** This file contains C code routines that are called by the parser ** to handle SELECT statements in SQLite. ** -** $Id: select.c,v 1.49 2001/11/07 16:48:27 drh Exp $ +** $Id: select.c,v 1.50 2001/12/16 20:05:06 drh Exp $ */ #include "sqliteInt.h" @@ -318,7 +318,7 @@ static const char *selectOpName(int id){ ** in pParse and return non-zero. */ static int fillInColumnList(Parse *pParse, Select *p){ - int i, j; + int i, j, k; IdList *pTabList; ExprList *pEList; @@ -353,34 +353,52 @@ static int fillInColumnList(Parse *pParse, Select *p){ } } - /* If the list of columns to retrieve is "*" then replace it with - ** a list of all columns from all tables. + /* For every "*" that occurs in the column list, insert the names of + ** all columns in all tables. The parser inserted a special expression + ** with the TK_ALL operator for each "*" that it found in the column list. + ** The following code just has to locate the TK_ALL expressions and expand + ** each one to the list of all columns in all tables. */ - if( pEList==0 ){ - for(i=0; inId; i++){ - Table *pTab = pTabList->a[i].pTab; - for(j=0; jnCol; j++){ - Expr *pExpr = sqliteExpr(TK_DOT, 0, 0, 0); - if( pExpr==0 ) break; - pExpr->pLeft = sqliteExpr(TK_ID, 0, 0, 0); - if( pExpr->pLeft==0 ){ sqliteExprDelete(pExpr); break; } - if( pTabList->a[i].zAlias && pTabList->a[i].zAlias[0] ){ - pExpr->pLeft->token.z = pTabList->a[i].zAlias; - pExpr->pLeft->token.n = strlen(pTabList->a[i].zAlias); - }else{ - pExpr->pLeft->token.z = pTab->zName; - pExpr->pLeft->token.n = strlen(pTab->zName); + for(k=0; knExpr; k++){ + if( pEList->a[k].pExpr->op==TK_ALL ) break; + } + if( knExpr ){ + struct ExprList_item *a = pEList->a; + ExprList *pNew = 0; + for(k=0; knExpr; k++){ + if( a[k].pExpr->op!=TK_ALL ){ + pNew = sqliteExprListAppend(pNew, a[k].pExpr, 0); + pNew->a[pNew->nExpr-1].zName = a[k].zName; + a[k].pExpr = 0; + a[k].zName = 0; + }else{ + for(i=0; inId; i++){ + Table *pTab = pTabList->a[i].pTab; + for(j=0; jnCol; j++){ + Expr *pExpr = sqliteExpr(TK_DOT, 0, 0, 0); + if( pExpr==0 ) break; + pExpr->pLeft = sqliteExpr(TK_ID, 0, 0, 0); + if( pExpr->pLeft==0 ){ sqliteExprDelete(pExpr); break; } + if( pTabList->a[i].zAlias && pTabList->a[i].zAlias[0] ){ + pExpr->pLeft->token.z = pTabList->a[i].zAlias; + pExpr->pLeft->token.n = strlen(pTabList->a[i].zAlias); + }else{ + pExpr->pLeft->token.z = pTab->zName; + pExpr->pLeft->token.n = strlen(pTab->zName); + } + pExpr->pRight = sqliteExpr(TK_ID, 0, 0, 0); + if( pExpr->pRight==0 ){ sqliteExprDelete(pExpr); break; } + pExpr->pRight->token.z = pTab->aCol[j].zName; + pExpr->pRight->token.n = strlen(pTab->aCol[j].zName); + pExpr->span.z = ""; + pExpr->span.n = 0; + pNew = sqliteExprListAppend(pNew, pExpr, 0); + } } - pExpr->pRight = sqliteExpr(TK_ID, 0, 0, 0); - if( pExpr->pRight==0 ){ sqliteExprDelete(pExpr); break; } - pExpr->pRight->token.z = pTab->aCol[j].zName; - pExpr->pRight->token.n = strlen(pTab->aCol[j].zName); - pExpr->span.z = ""; - pExpr->span.n = 0; - pEList = sqliteExprListAppend(pEList, pExpr, 0); } } - p->pEList = pEList; + sqliteExprListDelete(pEList); + p->pEList = pNew; } return 0; } diff --git a/test/select1.test b/test/select1.test index 9f5e9dc55e..48f834d84d 100644 --- a/test/select1.test +++ b/test/select1.test @@ -11,7 +11,7 @@ # This file implements regression tests for SQLite library. The # focus of this file is testing the SELECT statement. # -# $Id: select1.test,v 1.15 2001/11/06 14:10:42 drh Exp $ +# $Id: select1.test,v 1.16 2001/12/16 20:05:06 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -54,6 +54,15 @@ do_test select1-1.7 { do_test select1-1.8 { execsql {SELECT * FROM test1} } {11 22} +do_test select1-1.8.1 { + execsql {SELECT *, * FROM test1} +} {11 22 11 22} +do_test select1-1.8.2 { + execsql {SELECT *, min(f1,f2), max(f1,f2) FROM test1} +} {11 22 11 22} +do_test select1-1.8.3 { + execsql {SELECT 'one', *, 'two', * FROM test1} +} {one 11 22 two 11 22} execsql {CREATE TABLE test2(r1 real, r2 real)} execsql {INSERT INTO test2(r1,r2) VALUES(1.1,2.2)} @@ -61,6 +70,12 @@ execsql {INSERT INTO test2(r1,r2) VALUES(1.1,2.2)} do_test select1-1.9 { execsql {SELECT * FROM test1, test2} } {11 22 1.1 2.2} +do_test select1-1.9.1 { + execsql {SELECT *, 'hi' FROM test1, test2} +} {11 22 1.1 2.2 hi} +do_test select1-1.9.2 { + execsql {SELECT 'one', *, 'two', * FROM test1, test2} +} {one 11 22 1.1 2.2 two 11 22 1.1 2.2} do_test select1-1.10 { execsql {SELECT test1.f1, test2.r1 FROM test1, test2} } {11 1.1} diff --git a/www/changes.tcl b/www/changes.tcl index c2dc8950eb..09bd409b66 100644 --- a/www/changes.tcl +++ b/www/changes.tcl @@ -17,6 +17,13 @@ proc chng {date desc} { puts "

    $desc

" } +chng {2001 Dec 16 (2.1.8)} { +
  • Added the ability to specify "*" as part of a larger column list in + the result section of a SELECT statement. For example: + "SELECT rowid, * FROM table1;".
  • +
  • Updates to comments and documentation.
  • +} + chng {2001 Dec 14 (2.1.7)} {
  • Fix a bug in CREATE TEMPORARY TABLE which was causing the table to be initially allocated in the main database file instead