]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
:-) (CVS 75)
authordrh <drh@noemail.net>
Thu, 8 Jun 2000 00:19:02 +0000 (00:19 +0000)
committerdrh <drh@noemail.net>
Thu, 8 Jun 2000 00:19:02 +0000 (00:19 +0000)
FossilOrigin-Name: c47d552e7e275dcc03a687e2a874e8e6e1eeb109

manifest
manifest.uuid
src/select.c

index f1d58fb447077a9988f4991aff5c6ac039c3f645..d0134264226b4995f7749c0a904d12f3fb1f7a58 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C :-)\s(CVS\s74)
-D 2000-06-07T23:51:50
+C :-)\s(CVS\s75)
+D 2000-06-08T00:19:03
 F COPYRIGHT 74a8a6531a42e124df07ab5599aad63870fa0bd4
 F Makefile.in 17ba1ccf8d2d40c627796bba8f72952365d6d644
 F README 51f6a4e7408b34afa5bc1c0485f61b6a4efb6958
@@ -14,7 +14,7 @@ F src/expr.c baa8a4229b3acf69d908efcd697ab63922009c9f
 F src/insert.c ac4edfff474589c00b2490f206317dc5822122e5
 F src/main.c e3297835b8e38ca726ac73f2c2bdb7cf08103197
 F src/parse.y bb2126c8313c111184b89af8675911dcb57f1dca
-F src/select.c 21d1097e32e0a8430c286309817be33b734eab9d
+F src/select.c 409c38858024a4bf7d046e0aa387900fb742f70b
 F src/shell.c 3f4afc39a36e4824e8aa262623fd03568874799e
 F src/sqlite.h 58da0a8590133777b741f9836beaef3d58f40268
 F src/sqliteInt.h 816c491f9896090dde03804fd3f60346456b99df
@@ -54,7 +54,7 @@ F www/c_interface.tcl 9ac800854272db5fe439e07b7435b243a5422293
 F www/changes.tcl 04e66b4257589ff78a7e1de93e9dda4725fb03d6
 F www/index.tcl 52e29a4eeda8d59e91af43c61fef177c5f2ffd53
 F www/sqlite.tcl 2f933ce18cffd34a0a020a82435ab937137970fd
-P a00b81b0e1878487a6edaaca1b0dff002ad506d8
-R edeb782218e986f032924498f63df3c4
+P 2ffeb8509c469f5a499d56bb109da079fcdff570
+R 34a6f329df3d735505a6a2ab126209c9
 U drh
-Z e7171fdd9bf45a1d225b747155ebb197
+Z e59795bced83ef8a6bbccbb701b0703f
index adde17c19dbae953fac9d68f0d4856c5d791689e..75dad7e29c35f41d833417337f62830f6f15c5ce 100644 (file)
@@ -1 +1 @@
-2ffeb8509c469f5a499d56bb109da079fcdff570
\ No newline at end of file
+c47d552e7e275dcc03a687e2a874e8e6e1eeb109
\ No newline at end of file
index d524b1a17e08dad3d935212543b0662159df1a2b..150bea9861428222239a33f32760769b329e6961 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.16 2000/06/07 23:51:50 drh Exp $
+** $Id: select.c,v 1.17 2000/06/08 00:19:03 drh Exp $
 */
 #include "sqliteInt.h"
 
@@ -429,9 +429,10 @@ Vdbe *sqliteGetVdbe(Parse *pParse){
 ** or intersection of two or more separate queries.
 */
 static int multiSelect(Parse *pParse, Select *p, int eDest, int iParm){
-  int rc;
-  Select *pPrior;
-  Vdbe *v;
+  int rc;             /* Success code from a subroutine */
+  Select *pPrior;     /* Another SELECT immediately to our left */
+  Vdbe *v;            /* Generate code to this VDBE */
+  int base;           /* Baseline value for pParse->nTab */
 
   /* Make sure there is no ORDER BY clause on prior SELECTs.  Only the 
   ** last SELECT in the series may have an ORDER BY.
@@ -452,6 +453,7 @@ static int multiSelect(Parse *pParse, Select *p, int eDest, int iParm){
 
   /* Process the UNION or INTERSECTION
   */
+  base = pParse->nTab;
   switch( p->op ){
     case TK_ALL:
     case TK_EXCEPT:
@@ -580,6 +582,7 @@ static int multiSelect(Parse *pParse, Select *p, int eDest, int iParm){
     pParse->nErr++;
     return 1;
   }
+  pParse->nTab = base;
   return 0;
 }
 
@@ -626,6 +629,7 @@ int sqliteSelect(
   Expr *pHaving;         /* The HAVING clause.  May be NULL */
   int isDistinct;        /* True if the DISTINCT keyword is present */
   int distinct;          /* Table to use for the distinct set */
+  int base;              /* First cursor available for use */
 
   /* If there is are a sequence of queries, do the earlier ones first.
   */
@@ -642,11 +646,16 @@ int sqliteSelect(
   pHaving = p->pHaving;
   isDistinct = p->isDistinct;
 
+  /* Save the current value of pParse->nTab.  Restore this value before
+  ** we exit.
+  */
+  base = pParse->nTab;
+
   /* 
   ** Do not even attempt to generate any code if we have already seen
   ** errors before this routine starts.
   */
-  if( pParse->nErr>0 ) return 0;
+  if( pParse->nErr>0 ) return 1;
   sqliteParseInfoReset(pParse);
 
   /* Look up every table in the table list and create an appropriate
@@ -702,7 +711,11 @@ int sqliteSelect(
   }
   if( pHaving ) sqliteExprResolveInSelect(pParse, pHaving);
 
-  /* Resolve the field names and do a semantics check on all the expressions.
+  /* At this point, we should have allocated all the cursors that we
+  ** need to handle subquerys and temporary tables.  From here on we
+  ** are committed to keeping the same value for pParse->nTab.
+  **
+  ** Resolve the field names and do a semantics check on all the expressions.
   */
   for(i=0; i<pEList->nExpr; i++){
     if( sqliteExprResolveIds(pParse, pTabList, pEList->a[i].pExpr) ){
@@ -918,5 +931,6 @@ int sqliteSelect(
   if( pOrderBy ){
     generateSortTail(v, pEList->nExpr);
   }
+  pParse->nTab = base;
   return 0;
 }