-C Tests\sfor\sthe\ssubquery\sflattening\sfix\sof\scheck-in\s(2987).\s(CVS\s2988)
-D 2006-01-22T00:14:39
+C Code\ssize\sreductions\sin\sselect.c.\s(CVS\s2989)
+D 2006-01-22T00:42:09
F Makefile.in ab3ffd8d469cef4477257169b82810030a6bb967
F Makefile.linux-gcc aee18d8a05546dcf1888bd4547e442008a49a092
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
F src/prepare.c 5d6f5b7194ee72cecd66cab49d15159e55d63f28
F src/printf.c f47a2f4b5387cd2ebb12e9117a1a5d6bd9a2b812
F src/random.c d40f8d356cecbd351ccfab6eaedd7ec1b54f5261
-F src/select.c 4e9072092ddba113acf3c8192152ae9e75a23702
+F src/select.c bdfc4b1615757a75cc999a6264f791bd133c0c49
F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96
F src/shell.c 66b073375efbdee19045e7e0cd38b85f9aff71da
F src/sqlite.h.in 492580f7e3ff71eb43193eb7bb98e2d549889ce3
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
-P af18c0f431a1a6349e40249009f2ac222f8c8114
-R 038cd608b3bad3d890f2abe7363032af
+P 72a067f0df5818c0fdb3b9f8af20f83bb2e1dd34
+R 7149efc6bca05d61f3d140a668bc0541
U drh
-Z 893a67daf028f983e2ed2caeaec7613b
+Z 8f5502aac66dc065c601250997c9db38
** This file contains C code routines that are called by the parser
** to handle SELECT statements in SQLite.
**
-** $Id: select.c,v 1.297 2006/01/21 22:19:55 drh Exp $
+** $Id: select.c,v 1.298 2006/01/22 00:42:09 drh Exp $
*/
#include "sqliteInt.h"
+/*
+** Delete all the content of a Select structure but do not deallocate
+** the select structure itself.
+*/
+void clearSelect(Select *p){
+ sqlite3ExprListDelete(p->pEList);
+ sqlite3SrcListDelete(p->pSrc);
+ sqlite3ExprDelete(p->pWhere);
+ sqlite3ExprListDelete(p->pGroupBy);
+ sqlite3ExprDelete(p->pHaving);
+ sqlite3ExprListDelete(p->pOrderBy);
+ sqlite3SelectDelete(p->pPrior);
+ sqlite3ExprDelete(p->pLimit);
+ sqlite3ExprDelete(p->pOffset);
+}
+
+
/*
** Allocate a new Select structure and return a pointer to that
** structure.
Expr *pOffset /* OFFSET value. NULL means no offset */
){
Select *pNew;
+ Select standin;
pNew = sqliteMalloc( sizeof(*pNew) );
assert( !pOffset || pLimit ); /* Can't have OFFSET without LIMIT. */
if( pNew==0 ){
- sqlite3ExprListDelete(pEList);
- sqlite3SrcListDelete(pSrc);
- sqlite3ExprDelete(pWhere);
- sqlite3ExprListDelete(pGroupBy);
- sqlite3ExprDelete(pHaving);
- sqlite3ExprListDelete(pOrderBy);
- sqlite3ExprDelete(pLimit);
- sqlite3ExprDelete(pOffset);
- }else{
- if( pEList==0 ){
- pEList = sqlite3ExprListAppend(0, sqlite3Expr(TK_ALL,0,0,0), 0);
- }
- pNew->pEList = pEList;
- pNew->pSrc = pSrc;
- pNew->pWhere = pWhere;
- pNew->pGroupBy = pGroupBy;
- pNew->pHaving = pHaving;
- pNew->pOrderBy = pOrderBy;
- pNew->isDistinct = isDistinct;
- pNew->op = TK_SELECT;
- pNew->pLimit = pLimit;
- pNew->pOffset = pOffset;
- pNew->iLimit = -1;
- pNew->iOffset = -1;
- pNew->addrOpenVirt[0] = -1;
- pNew->addrOpenVirt[1] = -1;
- pNew->addrOpenVirt[2] = -1;
+ pNew = &standin;
+ memset(pNew, 0, sizeof(*pNew));
+ }
+ if( pEList==0 ){
+ pEList = sqlite3ExprListAppend(0, sqlite3Expr(TK_ALL,0,0,0), 0);
+ }
+ pNew->pEList = pEList;
+ pNew->pSrc = pSrc;
+ pNew->pWhere = pWhere;
+ pNew->pGroupBy = pGroupBy;
+ pNew->pHaving = pHaving;
+ pNew->pOrderBy = pOrderBy;
+ pNew->isDistinct = isDistinct;
+ pNew->op = TK_SELECT;
+ pNew->pLimit = pLimit;
+ pNew->pOffset = pOffset;
+ pNew->iLimit = -1;
+ pNew->iOffset = -1;
+ pNew->addrOpenVirt[0] = -1;
+ pNew->addrOpenVirt[1] = -1;
+ pNew->addrOpenVirt[2] = -1;
+ if( pNew==&standin) {
+ clearSelect(pNew);
+ pNew = 0;
}
return pNew;
}
+/*
+** Delete the given Select structure and all of its substructures.
+*/
+void sqlite3SelectDelete(Select *p){
+ if( p ){
+ clearSelect(p);
+ sqliteFree(p);
+ }
+}
+
/*
** Given 1 to 3 identifiers preceeding the JOIN keyword, determine the
** type of join. Return an integer constant that expresses that type
return 0;
}
-/*
-** Delete the given Select structure and all of its substructures.
-*/
-void sqlite3SelectDelete(Select *p){
- if( p==0 ) return;
- sqlite3ExprListDelete(p->pEList);
- sqlite3SrcListDelete(p->pSrc);
- sqlite3ExprDelete(p->pWhere);
- sqlite3ExprListDelete(p->pGroupBy);
- sqlite3ExprDelete(p->pHaving);
- sqlite3ExprListDelete(p->pOrderBy);
- sqlite3SelectDelete(p->pPrior);
- sqlite3ExprDelete(p->pLimit);
- sqlite3ExprDelete(p->pOffset);
- sqliteFree(p);
-}
-
/*
** Insert code into "v" that will push the record on the top of the
** stack into the sorter.
/* If there was a LIMIT clause on the SELECT statement, then do the check
** to see if this row should be output.
*/
- hasDistinct = distinct>=0 && pEList && pEList->nExpr>0;
+ hasDistinct = distinct>=0 && pEList->nExpr>0;
if( pOrderBy==0 && !hasDistinct ){
codeOffset(v, p, iContinue, 0);
}