Fix unreachable conditionals and revise a testcase that was made obsolete by
the changes on this branch. FossilOrigin-Name: 71f0adf7ca6824c3aba69104b9976dbb71b377474529e1a36220b4804293501e
This commit is contained in:
+17
-10
@@ -3401,7 +3401,8 @@ static void substSelect(
|
||||
** parent to a compound query confuses the code that handles
|
||||
** recursive queries in multiSelect().
|
||||
**
|
||||
** (24) The subquery may not be an aggregate that uses the built-in min() or
|
||||
** (**) We no longer attempt to flatten aggregate subqueries. Was:
|
||||
** The subquery may not be an aggregate that uses the built-in min() or
|
||||
** or max() functions. (Without this restriction, a query like:
|
||||
** "SELECT x FROM (SELECT max(y), x FROM t1)" would not necessarily
|
||||
** return the value X for which Y was maximal.)
|
||||
@@ -3474,10 +3475,8 @@ static int flattenSubquery(
|
||||
if( pSub->pLimit && (p->selFlags & SF_Distinct)!=0 ){
|
||||
return 0; /* Restriction (21) */
|
||||
}
|
||||
testcase( pSub->selFlags & SF_Recursive );
|
||||
testcase( pSub->selFlags & SF_MinMaxAgg );
|
||||
if( pSub->selFlags & (SF_Recursive|SF_MinMaxAgg) ){
|
||||
return 0; /* Restrictions (22) and (24) */
|
||||
if( pSub->selFlags & (SF_Recursive) ){
|
||||
return 0; /* Restrictions (22) */
|
||||
}
|
||||
if( (p->selFlags & SF_Recursive) && pSub->pPrior ){
|
||||
return 0; /* Restriction (23) */
|
||||
@@ -3857,14 +3856,22 @@ static int pushDownWhereTerms(
|
||||
){
|
||||
Expr *pNew;
|
||||
int nChng = 0;
|
||||
Select *pX; /* For looping over compound SELECTs in pSubq */
|
||||
if( pWhere==0 ) return 0;
|
||||
for(pX=pSubq; pX; pX=pX->pPrior){
|
||||
if( (pX->selFlags & (SF_Recursive))!=0 ){
|
||||
testcase( pX!=pSubq );
|
||||
return 0; /* restriction (2) */
|
||||
if( pSubq->selFlags & SF_Recursive ) return 0; /* restriction (2) */
|
||||
|
||||
#ifdef SQLITE_DEBUG
|
||||
/* Only the first term of a compound can have a WITH clause. But make
|
||||
** sure no other terms are marked SF_Recursive in case something changes
|
||||
** in the future.
|
||||
*/
|
||||
{
|
||||
Select *pX;
|
||||
for(pX=pSubq; pX; pX=pX->pPrior){
|
||||
assert( (pX->selFlags & (SF_Recursive))==0 );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if( pSubq->pLimit!=0 ){
|
||||
return 0; /* restriction (3) */
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user