Changes to select.c to facilitate full coverage testing. (CVS 6658)
FossilOrigin-Name: f678ed34faab88f4e126e553119773386c7c84fa
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
C Improvements\sto\sthe\sSQLITE_INT_TO_PTR\smacro\sto\sreduce\sthe\snumber\sof\nwarnings.\s\sFor\ssome\splatforms\sit\smight\sbe\snecessary\sto\scompile\swith\nthe\s-DHAVE_STDINT_H\sflag.\s\sTicket\s#3860.\s(CVS\s6657)
|
||||
D 2009-05-19T14:21:29
|
||||
C Changes\sto\sselect.c\sto\sfacilitate\sfull\scoverage\stesting.\s(CVS\s6658)
|
||||
D 2009-05-19T19:04:58
|
||||
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
||||
F Makefile.in 583e87706abc3026960ed759aff6371faf84c211
|
||||
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
||||
@@ -158,7 +158,7 @@ F src/printf.c 3f4dca207a88258d37af5a7a03e800a825fe6456
|
||||
F src/random.c 676b9d7ac820fe81e6fb2394ac8c10cff7f38628
|
||||
F src/resolve.c 2ce8f8bc8a0c913cbaec3fb3da2be113ea1fa5af
|
||||
F src/rowset.c 14d12b5e81b5907b87d511f6f4219805f96a4b55
|
||||
F src/select.c e5813bd0a75f8d303a56667fa669c8cb9d47c375
|
||||
F src/select.c 88e654ab5b183e4fdb084680b66b5bfa6f214dc5
|
||||
F src/shell.c 0a11f831603f17fea20ca97133c0f64e716af4a7
|
||||
F src/sqlite.h.in 0c459a45c1047be24c6a58646e8be4d001a3a28a
|
||||
F src/sqlite3ext.h 1db7d63ab5de4b3e6b83dd03d1a4e64fef6d2a17
|
||||
@@ -729,7 +729,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
|
||||
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
||||
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||
P 9675b6223645fe01b202cbefae63f3209a50efcc
|
||||
R eb53957791a887f64e4f685f972f02b8
|
||||
P 1b0ee9d188c000a2331caae2e9c8b89b0bcbc0b0
|
||||
R d15b16c16d25d0a15fe74d1aa7c5ea6b
|
||||
U drh
|
||||
Z c7784eccbedf809f068273bf3d8d4078
|
||||
Z cdf595d21d0d1c681184a9d7037bb48e
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
1b0ee9d188c000a2331caae2e9c8b89b0bcbc0b0
|
||||
f678ed34faab88f4e126e553119773386c7c84fa
|
||||
+34
-45
@@ -12,7 +12,7 @@
|
||||
** This file contains C code routines that are called by the parser
|
||||
** to handle SELECT statements in SQLite.
|
||||
**
|
||||
** $Id: select.c,v 1.517 2009/05/18 15:46:08 drh Exp $
|
||||
** $Id: select.c,v 1.518 2009/05/19 19:04:58 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
|
||||
@@ -2921,9 +2921,10 @@ static u8 minMaxQuery(Select *p){
|
||||
|
||||
if( pEList->nExpr!=1 ) return WHERE_ORDERBY_NORMAL;
|
||||
pExpr = pEList->a[0].pExpr;
|
||||
if( ExprHasProperty(pExpr, EP_xIsSelect) ) return 0;
|
||||
if( pExpr->op!=TK_AGG_FUNCTION ) return 0;
|
||||
if( NEVER(ExprHasProperty(pExpr, EP_xIsSelect)) ) return 0;
|
||||
pEList = pExpr->x.pList;
|
||||
if( pExpr->op!=TK_AGG_FUNCTION || pEList==0 || pEList->nExpr!=1 ) return 0;
|
||||
if( pEList==0 || pEList->nExpr!=1 ) return 0;
|
||||
if( pEList->a[0].pExpr->op!=TK_AGG_COLUMN ) return WHERE_ORDERBY_NORMAL;
|
||||
if( pExpr->token.n!=3 ) return WHERE_ORDERBY_NORMAL;
|
||||
if( sqlite3StrNICmp((char*)pExpr->token.z,"min",3)==0 ){
|
||||
@@ -3028,7 +3029,7 @@ static int selectExpander(Walker *pWalker, Select *p){
|
||||
if( db->mallocFailed ){
|
||||
return WRC_Abort;
|
||||
}
|
||||
if( p->pSrc==0 || (p->selFlags & SF_Expanded)!=0 ){
|
||||
if( NEVER(p->pSrc==0) || (p->selFlags & SF_Expanded)!=0 ){
|
||||
return WRC_Prune;
|
||||
}
|
||||
p->selFlags |= SF_Expanded;
|
||||
@@ -3080,16 +3081,9 @@ static int selectExpander(Walker *pWalker, Select *p){
|
||||
if( pTab->pSelect || IsVirtual(pTab) ){
|
||||
/* We reach here if the named table is a really a view */
|
||||
if( sqlite3ViewGetColumnNames(pParse, pTab) ) return WRC_Abort;
|
||||
|
||||
/* If pFrom->pSelect!=0 it means we are dealing with a
|
||||
** view within a view. The SELECT structure has already been
|
||||
** copied by the outer view so we can skip the copy step here
|
||||
** in the inner view.
|
||||
*/
|
||||
if( pFrom->pSelect==0 ){
|
||||
pFrom->pSelect = sqlite3SelectDup(db, pTab->pSelect, 0);
|
||||
sqlite3WalkSelect(pWalker, pFrom->pSelect);
|
||||
}
|
||||
assert( pFrom->pSelect==0 );
|
||||
pFrom->pSelect = sqlite3SelectDup(db, pTab->pSelect, 0);
|
||||
sqlite3WalkSelect(pWalker, pFrom->pSelect);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -3119,8 +3113,9 @@ static int selectExpander(Walker *pWalker, Select *p){
|
||||
for(k=0; k<pEList->nExpr; k++){
|
||||
Expr *pE = pEList->a[k].pExpr;
|
||||
if( pE->op==TK_ALL ) break;
|
||||
if( pE->op==TK_DOT && pE->pRight && pE->pRight->op==TK_ALL
|
||||
&& pE->pLeft && pE->pLeft->op==TK_ID ) break;
|
||||
assert( pE->op!=TK_DOT || pE->pRight!=0 );
|
||||
assert( pE->op!=TK_DOT || (pE->pLeft!=0 && pE->pLeft->op==TK_ID) );
|
||||
if( pE->op==TK_DOT && pE->pRight->op==TK_ALL ) break;
|
||||
}
|
||||
if( k<pEList->nExpr ){
|
||||
/*
|
||||
@@ -3136,8 +3131,8 @@ static int selectExpander(Walker *pWalker, Select *p){
|
||||
|
||||
for(k=0; k<pEList->nExpr; k++){
|
||||
Expr *pE = a[k].pExpr;
|
||||
if( pE->op!=TK_ALL &&
|
||||
(pE->op!=TK_DOT || pE->pRight==0 || pE->pRight->op!=TK_ALL) ){
|
||||
assert( pE->op!=TK_DOT || pE->pRight!=0 );
|
||||
if( pE->op!=TK_ALL && (pE->op!=TK_DOT || pE->pRight->op!=TK_ALL) ){
|
||||
/* This particular expression does not need to be expanded.
|
||||
*/
|
||||
pNew = sqlite3ExprListAppend(pParse, pNew, a[k].pExpr, 0);
|
||||
@@ -3151,7 +3146,8 @@ static int selectExpander(Walker *pWalker, Select *p){
|
||||
** expanded. */
|
||||
int tableSeen = 0; /* Set to 1 when TABLE matches */
|
||||
char *zTName; /* text of name of TABLE */
|
||||
if( pE->op==TK_DOT && pE->pLeft ){
|
||||
if( pE->op==TK_DOT ){
|
||||
assert( pE->pLeft!=0 );
|
||||
zTName = sqlite3NameFromToken(db, &pE->pLeft->token);
|
||||
}else{
|
||||
zTName = 0;
|
||||
@@ -3159,7 +3155,7 @@ static int selectExpander(Walker *pWalker, Select *p){
|
||||
for(i=0, pFrom=pTabList->a; i<pTabList->nSrc; i++, pFrom++){
|
||||
Table *pTab = pFrom->pTab;
|
||||
char *zTabName = pFrom->zAlias;
|
||||
if( zTabName==0 || zTabName[0]==0 ){
|
||||
if( zTabName==0 ){
|
||||
zTabName = pTab->zName;
|
||||
}
|
||||
if( db->mallocFailed ) break;
|
||||
@@ -3298,19 +3294,18 @@ static int selectAddSubqueryTypeInfo(Walker *pWalker, Select *p){
|
||||
struct SrcList_item *pFrom;
|
||||
|
||||
assert( p->selFlags & SF_Resolved );
|
||||
if( (p->selFlags & SF_HasTypeInfo)==0 ){
|
||||
p->selFlags |= SF_HasTypeInfo;
|
||||
pParse = pWalker->pParse;
|
||||
pTabList = p->pSrc;
|
||||
for(i=0, pFrom=pTabList->a; i<pTabList->nSrc; i++, pFrom++){
|
||||
Table *pTab = pFrom->pTab;
|
||||
if( pTab && (pTab->tabFlags & TF_Ephemeral)!=0 ){
|
||||
/* A sub-query in the FROM clause of a SELECT */
|
||||
Select *pSel = pFrom->pSelect;
|
||||
assert( pSel );
|
||||
while( pSel->pPrior ) pSel = pSel->pPrior;
|
||||
selectAddColumnTypeAndCollation(pParse, pTab->nCol, pTab->aCol, pSel);
|
||||
}
|
||||
assert( (p->selFlags & SF_HasTypeInfo)==0 );
|
||||
p->selFlags |= SF_HasTypeInfo;
|
||||
pParse = pWalker->pParse;
|
||||
pTabList = p->pSrc;
|
||||
for(i=0, pFrom=pTabList->a; i<pTabList->nSrc; i++, pFrom++){
|
||||
Table *pTab = pFrom->pTab;
|
||||
if( ALWAYS(pTab!=0) && (pTab->tabFlags & TF_Ephemeral)!=0 ){
|
||||
/* A sub-query in the FROM clause of a SELECT */
|
||||
Select *pSel = pFrom->pSelect;
|
||||
assert( pSel );
|
||||
while( pSel->pPrior ) pSel = pSel->pPrior;
|
||||
selectAddColumnTypeAndCollation(pParse, pTab->nCol, pTab->aCol, pSel);
|
||||
}
|
||||
}
|
||||
return WRC_Continue;
|
||||
@@ -3354,10 +3349,9 @@ void sqlite3SelectPrep(
|
||||
NameContext *pOuterNC /* Name context for container */
|
||||
){
|
||||
sqlite3 *db;
|
||||
if( p==0 ) return;
|
||||
if( NEVER(p==0) ) return;
|
||||
db = pParse->db;
|
||||
if( p->selFlags & SF_HasTypeInfo ) return;
|
||||
if( pParse->nErr || db->mallocFailed ) return;
|
||||
sqlite3SelectExpand(pParse, p);
|
||||
if( pParse->nErr || db->mallocFailed ) return;
|
||||
sqlite3ResolveSelectNames(pParse, p, pOuterNC);
|
||||
@@ -3578,13 +3572,7 @@ int sqlite3Select(
|
||||
goto select_end;
|
||||
}
|
||||
isAgg = (p->selFlags & SF_Aggregate)!=0;
|
||||
if( pEList==0 ) goto select_end;
|
||||
|
||||
/*
|
||||
** Do not even attempt to generate any code if we have already seen
|
||||
** errors before this routine starts.
|
||||
*/
|
||||
if( pParse->nErr>0 ) goto select_end;
|
||||
assert( pEList!=0 );
|
||||
|
||||
/* Begin generating code.
|
||||
*/
|
||||
@@ -3625,7 +3613,7 @@ int sqlite3Select(
|
||||
sqlite3Select(pParse, pSub, &dest);
|
||||
pItem->isPopulated = 1;
|
||||
}
|
||||
if( pParse->nErr || db->mallocFailed ){
|
||||
if( /*pParse->nErr ||*/ db->mallocFailed ){
|
||||
goto select_end;
|
||||
}
|
||||
pParse->nHeight -= sqlite3SelectExprHeight(p);
|
||||
@@ -3676,7 +3664,8 @@ int sqlite3Select(
|
||||
/* If possible, rewrite the query to use GROUP BY instead of DISTINCT.
|
||||
** GROUP BY might use an index, DISTINCT never does.
|
||||
*/
|
||||
if( (p->selFlags & (SF_Distinct|SF_Aggregate))==SF_Distinct && !p->pGroupBy ){
|
||||
assert( p->pGroupBy==0 || (p->selFlags & SF_Aggregate)!=0 );
|
||||
if( (p->selFlags & (SF_Distinct|SF_Aggregate))==SF_Distinct ){
|
||||
p->pGroupBy = sqlite3ExprListDup(db, p->pEList, 0);
|
||||
pGroupBy = p->pGroupBy;
|
||||
p->selFlags &= ~SF_Distinct;
|
||||
@@ -4009,7 +3998,7 @@ int sqlite3Select(
|
||||
resetAccumulator(pParse, &sAggInfo);
|
||||
sqlite3VdbeAddOp1(v, OP_Return, regReset);
|
||||
|
||||
} /* endif pGroupBy */
|
||||
} /* endif pGroupBy. Begin aggregate queries without GROUP BY: */
|
||||
else {
|
||||
ExprList *pDel = 0;
|
||||
#ifndef SQLITE_OMIT_BTREECOUNT
|
||||
|
||||
Reference in New Issue
Block a user