mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-12 13:01:09 +03:00
Remove a redundant restriction from the query flattener.
FossilOrigin-Name: 66629b2a0997ceedcfb38553f2200466b6c4e352ea00f8a0a7cb67a660c19523
This commit is contained in:
16
src/select.c
16
src/select.c
@@ -3393,8 +3393,9 @@ static void substSelect(
|
||||
**
|
||||
** (22) The subquery may not be a recursive CTE.
|
||||
**
|
||||
** (23) If the outer query is a recursive CTE, then the sub-query may not be
|
||||
** a compound query. This restriction is because transforming the
|
||||
** (**) Subsumed into restriction (17d3). Was: If the outer query is
|
||||
** a recursive CTE, then the sub-query may not be a compound query.
|
||||
** This restriction is because transforming the
|
||||
** parent to a compound query confuses the code that handles
|
||||
** recursive queries in multiSelect().
|
||||
**
|
||||
@@ -3475,9 +3476,6 @@ static int flattenSubquery(
|
||||
if( pSub->selFlags & (SF_Recursive) ){
|
||||
return 0; /* Restrictions (22) */
|
||||
}
|
||||
if( (p->selFlags & SF_Recursive) && pSub->pPrior ){
|
||||
return 0; /* Restriction (23) */
|
||||
}
|
||||
|
||||
/*
|
||||
** If the subquery is the right operand of a LEFT JOIN, then the
|
||||
@@ -3551,6 +3549,14 @@ static int flattenSubquery(
|
||||
}
|
||||
}
|
||||
|
||||
/* Ex-restriction (23):
|
||||
** The only way that the recursive part of a CTE can contain a compound
|
||||
** subquery is for the subquery to be one term of a join. But if the
|
||||
** subquery is a join, then the flattening has already been stopped by
|
||||
** restriction (17d3)
|
||||
*/
|
||||
assert( (p->selFlags & SF_Recursive)==0 || pSub->pPrior==0 );
|
||||
|
||||
/***** If we reach this point, flattening is permitted. *****/
|
||||
SELECTTRACE(1,pParse,p,("flatten %s.%p from term %d\n",
|
||||
pSub->zSelName, pSub, iFrom));
|
||||
|
||||
Reference in New Issue
Block a user