diff --git a/manifest b/manifest index 2f880ebdae..7cddc9aa56 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C :-)\s(CVS\s24) -D 2000-05-31T17:59:26 +C :-)\s(CVS\s25) +D 2000-05-31T18:20:14 F COPYRIGHT 74a8a6531a42e124df07ab5599aad63870fa0bd4 F Makefile.in 7ac2fef265940d93a544cb454efa836451559a71 F README 6b5960603c7f8bf42fc022b4b6436f242f238dbb @@ -13,8 +13,8 @@ F src/delete.c 16ef3418b19be9ab39db836c693970ca7bbff605 F src/expr.c 91970700e3e39b2b725b028c166f588a5bb0c038 F src/insert.c bd34716d0bba5561f6b55101adbf16fa75f872e8 F src/main.c 25cce7bce0eb3ba10bada7c05f4b38dc6dbbc86f -F src/parse.y bdfcd0a3fe7d6ad4b41dc2cbc0d04c4302f609b0 -F src/select.c 540fae91639d93ea1ef348882197554896841a2f +F src/parse.y 038e0f0fd243b89344c974c5d0552e85c4d27916 +F src/select.c 719ca9605a351b2a3521a692ae8d2936d4832609 F src/shell.c c5752d32cdeaa7d548d4f91177b697b023a00381 F src/sqlite.h 2397c17a8f4ca90c09acab0100dc7e2f8f441b69 F src/sqliteInt.h 81552acdedb0c3b256510a66c0f656d35d2ea2bd @@ -31,7 +31,7 @@ F test/delete.test 814d53e3b0d2d7069fb17e005d4041454d6585d4 F test/expr.test 1f514623a568ebd351d0f1fe30c8f273681c1396 F test/index.test 8d4f26901a5582daa353fe3c8266cbf4a53af830 F test/insert.test 161bc67a4189738c559e3569323ceae31f4d49d6 -F test/select1.test b994637d78e5b7f90c2032760f4c87aef8d461c1 +F test/select1.test a0b00df77e85adff75c338e487718c5d31f69e3a F test/table.test 85d6f410d127ec508c6640f02d7c40d218414e81 F test/tester.tcl 44690d463c1dc83a4c76ccde07cc146a988600f6 F test/update.test 69459302ea75cafac1479e60b0e36efb88123c0e @@ -45,7 +45,7 @@ F www/c_interface.tcl f875864edf7974157d1c257ca08de854660882a5 F www/changes.tcl 995d64c96978a996f0e9e46f2ce896355a7c87a7 F www/index.tcl 600e85c207929bedb9c6fd221aa7875fd8f43edf F www/sqlite.tcl 7deb564df188ad4523adecfe2365de6d09f6dfd9 -P 0b040cea57ee76103030c0d5ef571dc481a2b2d3 -R 6c10963e34e77cc84c8f0379f7394fc1 +P 4cd98ebaeaedf66b258bbfa3a04d90c054294322 +R 1eda0f1d67d8520e96913acfd2d34146 U drh -Z 83085793cdd6972c96321a385eef56bb +Z 21bfd749554e09c09048cdae5c21372a diff --git a/manifest.uuid b/manifest.uuid index 0d75c75034..ad9d3662fe 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4cd98ebaeaedf66b258bbfa3a04d90c054294322 \ No newline at end of file +35a8f523e8389a1a6e41f6561500644b165d556e \ No newline at end of file diff --git a/src/parse.y b/src/parse.y index 750e172013..556b92e05a 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.4 2000/05/31 15:34:53 drh Exp $ +** @(#) $Id: parse.y,v 1.5 2000/05/31 18:20:14 drh Exp $ */ %token_prefix TK_ %token_type {Token} @@ -176,13 +176,7 @@ sortlist(A) ::= sortitem(Y) sortorder(Z). A = sqliteExprListAppend(0,Y,0); A->a[0].idx = Z; } -sortitem(A) ::= ID(X). {A = sqliteExpr(TK_ID, 0, 0, &X);} -sortitem(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); - } +sortitem(A) ::= expr(X). {A = X;} %type sortorder {int} diff --git a/src/select.c b/src/select.c index 1a9416e348..c0722f00e5 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.1 2000/05/31 15:34:53 drh Exp $ +** $Id: select.c,v 1.2 2000/05/31 18:20:14 drh Exp $ */ #include "sqliteInt.h" @@ -154,8 +154,11 @@ void sqliteSelect( if( pTabList->nId>1 ){ char *zName = 0; Table *pTab = pTabList->a[p->iTable].pTab; - sqliteSetString(&zName, pTab->zName, ".", - pTab->azCol[p->iField], 0); + char *zTab; + + zTab = pTabList->a[p->iTable].zAlias; + if( zTab==0 ) zTab = pTab->zName; + sqliteSetString(&zName, zTab, ".", pTab->azCol[p->iField], 0); sqliteVdbeAddOp(v, OP_ColumnName, i, 0, zName, 0); sqliteFree(zName); }else{ @@ -191,8 +194,10 @@ void sqliteSelect( /* Pull the requested fields. */ - for(i=0; inExpr; i++){ - sqliteExprCode(pParse, pEList->a[i].pExpr); + if( !isAgg ){ + for(i=0; inExpr; i++){ + sqliteExprCode(pParse, pEList->a[i].pExpr); + } } /* If there is no ORDER BY clause, then we can invoke the callback diff --git a/test/select1.test b/test/select1.test index 0099af86c8..a2d064d268 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.1 2000/05/31 17:59:27 drh Exp $ +# $Id: select1.test,v 1.2 2000/05/31 18:20:14 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -271,5 +271,25 @@ do_test select-6.6 { ORDER BY f2}} msg] lappend v $msg } {0 {field1 33 test2.t1 abc field1 77 test2.t1 abc}} +do_test select-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}} +do_test select-6.8 { + set v [catch {execsql2 {SELECT A.f1, f1 FROM test1 as A, test1 as B + ORDER BY f2}} msg] + lappend v $msg +} {1 {ambiguous field name: f1}} +do_test select-6.8 { + set v [catch {execsql2 {SELECT A.f1, B.f1 FROM test1 as A, test1 as B + ORDER BY f2}} msg] + lappend v $msg +} {1 {ambiguous field name: f2}} +do_test select-6.9 { + set v [catch {execsql2 {SELECT A.f1, B.f1 FROM test1 as A, test1 as B + ORDER BY A.f1, B.f1}} msg] + lappend v $msg +} {0 {A.f1 11 B.f1 11 A.f1 11 B.f1 33 A.f1 33 B.f1 11 A.f1 33 B.f1 33}} finish_test