]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
:-) (CVS 25)
authordrh <drh@noemail.net>
Wed, 31 May 2000 18:20:14 +0000 (18:20 +0000)
committerdrh <drh@noemail.net>
Wed, 31 May 2000 18:20:14 +0000 (18:20 +0000)
FossilOrigin-Name: 35a8f523e8389a1a6e41f6561500644b165d556e

manifest
manifest.uuid
src/parse.y
src/select.c
test/select1.test

index 2f880ebdae0f0c02a26b8d7172ae2efc7a9c0cf5..7cddc9aa564532016960bf161568bdd7610db695 100644 (file)
--- 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
index 0d75c750342099223875b2aa873952843de86fea..ad9d3662fede08d7ca5bf8722be8563474777f2e 100644 (file)
@@ -1 +1 @@
-4cd98ebaeaedf66b258bbfa3a04d90c054294322
\ No newline at end of file
+35a8f523e8389a1a6e41f6561500644b165d556e
\ No newline at end of file
index 750e1720132476071a48020c0d7d099a2329f110..556b92e05a06f03557750b6522128799314f9e19 100644 (file)
@@ -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}
 
index 1a9416e34865f349bfa90e96d12d93899d20f002..c0722f00e5262ef6ed2f3609e74de810643a127f 100644 (file)
@@ -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; i<pEList->nExpr; i++){
-    sqliteExprCode(pParse, pEList->a[i].pExpr);
+  if( !isAgg ){
+    for(i=0; i<pEList->nExpr; i++){
+      sqliteExprCode(pParse, pEList->a[i].pExpr);
+    }
   }
   
   /* If there is no ORDER BY clause, then we can invoke the callback
index 0099af86c8d2716944fb7b7fd807f657b16b5c05..a2d064d2685b244538762175179c8a6b2deaf675 100644 (file)
@@ -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