-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
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
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
** 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"
** 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.
/* Process the UNION or INTERSECTION
*/
+ base = pParse->nTab;
switch( p->op ){
case TK_ALL:
case TK_EXCEPT:
pParse->nErr++;
return 1;
}
+ pParse->nTab = base;
return 0;
}
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.
*/
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
}
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) ){
if( pOrderBy ){
generateSortTail(v, pEList->nExpr);
}
+ pParse->nTab = base;
return 0;
}