diff --git a/manifest b/manifest index 0401f06785..4abc272fb3 100644 --- a/manifest +++ b/manifest @@ -1,28 +1,28 @@ -C added\sthe\ssqlite_busy_handler()\sinterface\s(CVS\s1700) -D 2000-07-28T14:32:49 +C better\scolumn\slabels\sin\sselect\sresults\s(CVS\s110) +D 2000-07-29T13:06:59 F COPYRIGHT 74a8a6531a42e124df07ab5599aad63870fa0bd4 F Makefile.in 9e6dcd232e594fb599a5e9ba8bcf45e6c6e2fe72 F README 51f6a4e7408b34afa5bc1c0485f61b6a4efb6958 F configure 1354f60305c781609c94cd4b677ab4ff4d830b85 x F configure.in 77732d0a7d3ec66b7fc2303ae823fa5419ca7e6c F doc/lemon.html e233a3e97a779c7a87e1bc4528c664a58e49dd47 -F src/build.c ac2e238356008411c3aa09c96823529d4103afcc +F src/build.c ecb8ec724914780efed01d1739e6dd398d75af46 F src/dbbe.c 3604cf7dec6856a4963ab8f2220449f3d02e759a F src/dbbe.h 8718b718b36d37584e9bbdfccec10588fa91271f F src/delete.c 4d491eaf61b515516749c7ed68fa3b2ee8a09065 F src/expr.c 2fa63f086707176d09092e71832f9bbdc6a8ac85 F src/insert.c f146f149ad2422a1dc3bfa7a1651a25940f98958 F src/main.c 82dba47063cb9837910c3bcefacb47de7486fb47 -F src/parse.y 86e268c29a0f00ffc062bbe934d95ea0d6308b0a -F src/select.c aaf23d4a6ef44e4378840ec94b6aa64641c01b5c +F src/parse.y 754653f073ee03749471f86ef1bca641b35887c7 +F src/select.c d382e96c2221d08367cc87976f2b574537c9de97 F src/shell.c ffcb11569f6f1756148b389ac0f1fc480859698e F src/sqlite.h 82ae53028e27919250f886ff9d7c4927de81978a -F src/sqliteInt.h cf4b8f3c7fbb50adf3d879770defe72502a39022 +F src/sqliteInt.h 74eb0e266e05d10278e2c20a2cd8fe9fd9fa0d1a F src/tclsqlite.c 9f358618ae803bedf4fb96da5154fd45023bc1f7 F src/tokenize.c 77ff8164a8751994bc9926ce282847f653ac0c16 F src/update.c 51b9ef7434b15e31096155da920302e9db0d27fc F src/util.c fcd7ac9d2be8353f746e52f665e6c4f5d6b3b805 -F src/vdbe.c 72b533a452953aca618a935b5155d1d4eed3193c +F src/vdbe.c b9ce1439931a56bdbec560d41d32f623b5d4b1c7 F src/vdbe.h 6c5653241633c583549c2d8097394ab52550eb63 F src/where.c 420f666a38b405cd58bd7af832ed99f1dbc7d336 F test/all.test 0950c135cab7e60c07bd745ccfad1476211e5bd7 @@ -36,8 +36,8 @@ F test/insert.test 66f4c3bd600fec8eb1e733b928cbe6fa885eff0c F test/insert2.test 732405e30331635af8d159fccabe835eea5cd0c6 F test/lock.test 42a2d171eba1078cf3fd58ab64241eb8f1b08d69 F test/main.test b7366cc6f3690915a11834bc1090deeff08acaf9 -F test/select1.test 4e57b0b5eae0c991d9cc51d1288be0476110e6f6 -F test/select2.test ed6e7fc3437079686d7ae4390a00347bbd5f7bf8 +F test/select1.test 68ff778c24fc8982e63dda37acb5b0396913adf7 +F test/select2.test 45c28211702b5c82b06dd624a112ea17417f343c F test/select3.test a9234b8424b6c6d71de534f43b91ade9be68e9cc F test/select4.test cb5374d7c87680e294ac749307459a5cc547609d F test/select5.test e2b9d51d88cbd6c307c2c05b0ef55fe7ba811ac2 @@ -59,14 +59,14 @@ F www/arch.fig 4e26e9dca3c49724fc8f554c695ddea9f2413156 F www/arch.png c4d908b79065a72e7dcf19317f36d1324c550e87 F www/arch.tcl 4f6a9afecc099a27bba17b4f8cc9561abc15dc40 F www/c_interface.tcl 29593cf77025bab137b7ba64b9459eb5eb6b4873 -F www/changes.tcl 6c14cc0f1c1a8929aa0b44304b0e2450d801b5b5 +F www/changes.tcl 4491a4c835a87945ec4b493d8fed8e31e7917db5 F www/fileformat.tcl f3a70650e942262f8285d53097d48f0b3aa59862 F www/index.tcl 58c9a33ceba12f5efee446c6b10b4f6523a214e1 F www/lang.tcl 1645e9107d75709be4c6099b643db235bbe0a151 F www/opcode.tcl 401bdc639509c2f17d3bb97cbbdfdc22a61faa07 F www/sqlite.tcl 69781eaffb02e17aa4af28b76a2bedb19baa8e9f F www/vdbe.tcl 3330c700ef9c212a169f568a595361e4cce749ed -P 4fe8e51c248369572637a5351bd193f07e059fa2 -R c695a62141a00b7f6ab88cfdecb913c6 +P 2d57b02fec35fa922aab3f707e3b7dfa1ef561a0 +R 87f4dde86778218c5426917d42801d46 U drh -Z f47fbbfa788e1f0f92603c42750a7387 +Z 40af36ae39a880c6a582ccc2005dae71 diff --git a/manifest.uuid b/manifest.uuid index a77db27b80..367f18e87f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2d57b02fec35fa922aab3f707e3b7dfa1ef561a0 \ No newline at end of file +3bf434d93a54a24f4882d0d9375f82ceee0b7602 \ No newline at end of file diff --git a/src/build.c b/src/build.c index f7ccc6228b..b9ee8eee85 100644 --- a/src/build.c +++ b/src/build.c @@ -33,7 +33,7 @@ ** COPY ** VACUUM ** -** $Id: build.c,v 1.20 2000/07/28 14:32:49 drh Exp $ +** $Id: build.c,v 1.21 2000/07/29 13:06:59 drh Exp $ */ #include "sqliteInt.h" @@ -81,9 +81,23 @@ Expr *sqliteExpr(int op, Expr *pLeft, Expr *pRight, Token *pToken){ pNew->token.z = ""; pNew->token.n = 0; } + if( pLeft && pRight ){ + sqliteExprSpan(pNew, &pLeft->span, &pRight->span); + }else{ + pNew->span = pNew->token; + } return pNew; } +/* +** Set the Expr.token field of the given expression to span all +** text between the two given tokens. +*/ +void sqliteExprSpan(Expr *pExpr, Token *pLeft, Token *pRight){ + pExpr->span.z = pLeft->z; + pExpr->span.n = pRight->n + (int)pRight->z - (int)pLeft->z; +} + /* ** Construct a new expression node for a function with multiple ** arguments. diff --git a/src/parse.y b/src/parse.y index f59b662b64..194262ec65 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.23 2000/06/21 13:59:12 drh Exp $ +** @(#) $Id: parse.y,v 1.24 2000/07/29 13:06:59 drh Exp $ */ %token_prefix TK_ %token_type {Token} @@ -301,17 +301,25 @@ inscollist(A) ::= id(Y). {A = sqliteIdListAppend(0,&Y);} %type expr {Expr*} %destructor expr {sqliteExprDelete($$);} -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 *temp2 = sqliteExpr(TK_ID, 0, 0, &Y); - A = sqliteExpr(TK_DOT, temp1, temp2, 0);} +expr(A) ::= LP(B) expr(X) RP(E). {A = X; sqliteExprSpan(A,&B,&E);} +expr(A) ::= ID(X). {A = sqliteExpr(TK_ID, 0, 0, &X);} +expr(A) ::= NULL(X). {A = sqliteExpr(TK_NULL, 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);} expr(A) ::= FLOAT(X). {A = sqliteExpr(TK_FLOAT, 0, 0, &X);} expr(A) ::= STRING(X). {A = sqliteExpr(TK_STRING, 0, 0, &X);} -expr(A) ::= ID(X) LP exprlist(Y) RP. {A = sqliteExprFunction(Y, &X);} -expr(A) ::= ID(X) LP STAR RP. {A = sqliteExprFunction(0, &X);} +expr(A) ::= ID(X) LP exprlist(Y) RP(E). { + A = sqliteExprFunction(Y, &X); + sqliteExprSpan(A,&X,&E); +} +expr(A) ::= ID(X) LP STAR RP(E). { + A = sqliteExprFunction(0, &X); + sqliteExprSpan(A,&X,&E); +} expr(A) ::= expr(X) AND expr(Y). {A = sqliteExpr(TK_AND, X, Y, 0);} expr(A) ::= expr(X) OR expr(Y). {A = sqliteExpr(TK_OR, X, Y, 0);} expr(A) ::= expr(X) LT expr(Y). {A = sqliteExpr(TK_LT, X, Y, 0);} @@ -324,31 +332,50 @@ expr(A) ::= expr(X) LIKE expr(Y). {A = sqliteExpr(TK_LIKE, X, Y, 0);} expr(A) ::= expr(X) NOT LIKE expr(Y). { A = sqliteExpr(TK_LIKE, X, Y, 0); A = sqliteExpr(TK_NOT, A, 0, 0); + sqliteExprSpan(A,&X->span,&Y->span); } expr(A) ::= expr(X) GLOB expr(Y). {A = sqliteExpr(TK_GLOB,X,Y,0);} expr(A) ::= expr(X) NOT GLOB expr(Y). { A = sqliteExpr(TK_GLOB, X, Y, 0); A = sqliteExpr(TK_NOT, A, 0, 0); + sqliteExprSpan(A,&X->span,&Y->span); } expr(A) ::= expr(X) PLUS expr(Y). {A = sqliteExpr(TK_PLUS, X, Y, 0);} expr(A) ::= expr(X) MINUS expr(Y). {A = sqliteExpr(TK_MINUS, X, Y, 0);} expr(A) ::= expr(X) STAR expr(Y). {A = sqliteExpr(TK_STAR, X, Y, 0);} expr(A) ::= expr(X) SLASH expr(Y). {A = sqliteExpr(TK_SLASH, X, Y, 0);} expr(A) ::= expr(X) CONCAT expr(Y). {A = sqliteExpr(TK_CONCAT, X, Y, 0);} -expr(A) ::= expr(X) ISNULL. {A = sqliteExpr(TK_ISNULL, X, 0, 0);} -expr(A) ::= expr(X) NOTNULL. {A = sqliteExpr(TK_NOTNULL, X, 0, 0);} -expr(A) ::= NOT expr(X). {A = sqliteExpr(TK_NOT, X, 0, 0);} -expr(A) ::= MINUS expr(X). [UMINUS] {A = sqliteExpr(TK_UMINUS, X, 0, 0);} -expr(A) ::= PLUS expr(X). [UMINUS] {A = X;} -expr(A) ::= LP select(X) RP. { +expr(A) ::= expr(X) ISNULL(E). { + A = sqliteExpr(TK_ISNULL, X, 0, 0); + sqliteExprSpan(A,&X->span,&E); +} +expr(A) ::= expr(X) NOTNULL(E). { + A = sqliteExpr(TK_NOTNULL, X, 0, 0); + sqliteExprSpan(A,&X->span,&E); +} +expr(A) ::= NOT(B) expr(X). { + A = sqliteExpr(TK_NOT, X, 0, 0); + sqliteExprSpan(A,&B,&X->span); +} +expr(A) ::= MINUS(B) expr(X). [UMINUS] { + A = sqliteExpr(TK_UMINUS, X, 0, 0); + sqliteExprSpan(A,&B,&X->span); +} +expr(A) ::= PLUS(B) expr(X). [UMINUS] { + A = X; + sqliteExprSpan(A,&B,&X->span); +} +expr(A) ::= LP(B) select(X) RP(E). { A = sqliteExpr(TK_SELECT, 0, 0, 0); A->pSelect = X; + sqliteExprSpan(A,&B,&E); } expr(A) ::= expr(W) BETWEEN expr(X) AND expr(Y). { ExprList *pList = sqliteExprListAppend(0, X, 0); pList = sqliteExprListAppend(pList, Y, 0); A = sqliteExpr(TK_BETWEEN, W, 0, 0); A->pList = pList; + sqliteExprSpan(A,&W->span,&Y->span); } expr(A) ::= expr(W) NOT BETWEEN expr(X) AND expr(Y). { ExprList *pList = sqliteExprListAppend(0, X, 0); @@ -356,24 +383,29 @@ expr(A) ::= expr(W) NOT BETWEEN expr(X) AND expr(Y). { A = sqliteExpr(TK_BETWEEN, W, 0, 0); A->pList = pList; A = sqliteExpr(TK_NOT, A, 0, 0); + sqliteExprSpan(A,&W->span,&Y->span); } -expr(A) ::= expr(X) IN LP exprlist(Y) RP. { +expr(A) ::= expr(X) IN LP exprlist(Y) RP(E). { A = sqliteExpr(TK_IN, X, 0, 0); A->pList = Y; + sqliteExprSpan(A,&X->span,&E); } -expr(A) ::= expr(X) IN LP select(Y) RP. { +expr(A) ::= expr(X) IN LP select(Y) RP(E). { A = sqliteExpr(TK_IN, X, 0, 0); A->pSelect = Y; + sqliteExprSpan(A,&X->span,&E); } -expr(A) ::= expr(X) NOT IN LP exprlist(Y) RP. { +expr(A) ::= expr(X) NOT IN LP exprlist(Y) RP(E). { A = sqliteExpr(TK_IN, X, 0, 0); A->pList = Y; A = sqliteExpr(TK_NOT, A, 0, 0); + sqliteExprSpan(A,&X->span,&E); } -expr(A) ::= expr(X) NOT IN LP select(Y) RP. { +expr(A) ::= expr(X) NOT IN LP select(Y) RP(E). { A = sqliteExpr(TK_IN, X, 0, 0); A->pSelect = Y; A = sqliteExpr(TK_NOT, A, 0, 0); + sqliteExprSpan(A,&X->span,&E); } diff --git a/src/select.c b/src/select.c index d9d21c76a3..0eac435cdc 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.25 2000/06/21 13:59:12 drh Exp $ +** $Id: select.c,v 1.26 2000/07/29 13:06:59 drh Exp $ */ #include "sqliteInt.h" @@ -234,13 +234,18 @@ void generateColumnNames(Parse *pParse, IdList *pTabList, ExprList *pEList){ sqliteVdbeAddOp(v, OP_ColumnCount, pEList->nExpr, 0, 0, 0); for(i=0; inExpr; i++){ Expr *p; + int addr; if( pEList->a[i].zName ){ char *zName = pEList->a[i].zName; sqliteVdbeAddOp(v, OP_ColumnName, i, 0, zName, 0); continue; } p = pEList->a[i].pExpr; - if( p->op!=TK_COLUMN || pTabList==0 ){ + if( p->span.z && p->span.z[0] ){ + addr = sqliteVdbeAddOp(v,OP_ColumnName, i, 0, 0, 0); + sqliteVdbeChangeP3(v, addr, p->span.z, p->span.n); + sqliteVdbeCompressSpace(v, addr); + }else if( p->op!=TK_COLUMN || pTabList==0 ){ char zName[30]; sprintf(zName, "column%d", i+1); sqliteVdbeAddOp(v, OP_ColumnName, i, 0, zName, 0); @@ -327,6 +332,8 @@ static int fillInColumnList(Parse *pParse, Select *p){ pExpr->pRight = sqliteExpr(TK_ID, 0, 0, 0); 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); } } diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 963f4452f9..1b84eb1167 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -23,7 +23,7 @@ ************************************************************************* ** Internal interface definitions for SQLite. ** -** @(#) $Id: sqliteInt.h,v 1.26 2000/07/28 14:32:50 drh Exp $ +** @(#) $Id: sqliteInt.h,v 1.27 2000/07/29 13:06:59 drh Exp $ */ #include "sqlite.h" #include "dbbe.h" @@ -204,6 +204,7 @@ struct Expr { Expr *pLeft, *pRight; /* Left and right subnodes */ ExprList *pList; /* A list of expressions used as a function argument */ Token token; /* An operand token */ + Token span; /* Complete text of the expression */ int iTable, iColumn; /* When op==TK_COLUMN, then this expr node means the ** iColumn-th field of the iTable-th table. When ** op==TK_FUNCTION, iColumn holds the function id */ @@ -365,6 +366,7 @@ void sqliteDequote(char*); int sqliteRunParser(Parse*, char*, char **); void sqliteExec(Parse*); Expr *sqliteExpr(int, Expr*, Expr*, Token*); +void sqliteExprSpan(Expr*,Token*,Token*); Expr *sqliteExprFunction(ExprList*, Token*); void sqliteExprDelete(Expr*); ExprList *sqliteExprListAppend(ExprList*,Expr*,Token*); diff --git a/src/vdbe.c b/src/vdbe.c index c6b921773d..0d916e0c48 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.35 2000/07/28 14:32:50 drh Exp $ +** $Id: vdbe.c,v 1.36 2000/07/29 13:06:59 drh Exp $ */ #include "sqliteInt.h" #include @@ -352,6 +352,32 @@ void sqliteVdbeDequoteP3(Vdbe *p, int addr){ sqliteDequote(z); } +/* +** On the P3 argument of the given instruction, change all +** strings of whitespace characters into a single space and +** delete leading and trailing whitespace. +*/ +void sqliteVdbeCompressSpace(Vdbe *p, int addr){ + char *z; + int i, j; + if( addr<0 || addr>=p->nOp ) return; + z = p->aOp[addr].p3; + i = j = 0; + while( isspace(z[i]) ){ i++; } + while( z[i] ){ + if( isspace(z[i]) ){ + z[j++] = ' '; + while( isspace(z[++i]) ){} + }else{ + z[j++] = z[i++]; + } + } + while( i>0 && isspace(z[i-1]) ){ + z[i-1] = 0; + i--; + } +} + /* ** Create a new symbolic label for an instruction that has yet to be ** coded. The symbolic label is really just a negative number. The diff --git a/test/select1.test b/test/select1.test index b9b6e5eae3..5d2e9b2def 100644 --- a/test/select1.test +++ b/test/select1.test @@ -23,7 +23,7 @@ # This file implements regression tests for SQLite library. The # focus of this file is testing the SELECT statement. # -# $Id: select1.test,v 1.6 2000/06/21 13:59:13 drh Exp $ +# $Id: select1.test,v 1.7 2000/07/29 13:07:00 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -265,17 +265,17 @@ do_test select1-6.4 { do_test select1-6.5 { set v [catch {execsql2 {SELECT test1.f1+F2 FROM test1 ORDER BY f2}} msg] lappend v $msg -} {0 {column1 33 column1 77}} +} {0 {test1.f1+F2 33 test1.f1+F2 77}} do_test select1-6.6 { set v [catch {execsql2 {SELECT test1.f1+F2, t1 FROM test1, test2 ORDER BY f2}} msg] lappend v $msg -} {0 {column1 33 test2.t1 abc column1 77 test2.t1 abc}} +} {0 {test1.f1+F2 33 t1 abc test1.f1+F2 77 t1 abc}} do_test select1-6.7 { set v [catch {execsql2 {SELECT A.f1, t1 FROM test1 as A, test2 ORDER BY f2}} msg] lappend v $msg -} {0 {A.f1 11 test2.t1 abc A.f1 33 test2.t1 abc}} +} {0 {A.f1 11 t1 abc A.f1 33 t1 abc}} do_test select1-6.8 { set v [catch {execsql2 {SELECT A.f1, f1 FROM test1 as A, test1 as B ORDER BY f2}} msg] diff --git a/test/select2.test b/test/select2.test index 59d759d559..7437cbe60d 100644 --- a/test/select2.test +++ b/test/select2.test @@ -23,7 +23,7 @@ # This file implements regression tests for SQLite library. The # focus of this file is testing the SELECT statement. # -# $Id: select2.test,v 1.7 2000/06/21 13:59:13 drh Exp $ +# $Id: select2.test,v 1.8 2000/07/29 13:07:00 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -115,7 +115,7 @@ do_test select2-3.3 { set t1 [lindex [time {execsql {SELECT f1 from tbl2 WHERE f2==2000}} 1] 0] execsql {DROP INDEX idx1} set t2 [lindex [time {execsql {SELECT f1 FROM tbl2 WHERE f2==2000}} 1] 0] - expr {$t1*25 < $t2} + expr {$t1*10 < $t2} } {1} finish_test diff --git a/www/changes.tcl b/www/changes.tcl index 63112f0c60..457c0b684c 100644 --- a/www/changes.tcl +++ b/www/changes.tcl @@ -17,6 +17,10 @@ proc chng {date desc} { puts "

    $desc

" } +chng {2000 July 29} { +
  • Better labels on column names of the result.
  • +} + chng {2000 July 28} {
  • Added the sqlite_busy_handler() and sqlite_busy_timeout() interface.