aboutsummaryrefslogtreecommitdiff
path: root/src/select.c
diff options
context:
space:
mode:
authordrh <>2022-04-10 23:01:20 +0000
committerdrh <>2022-04-10 23:01:20 +0000
commit9debb58e4801ad5737ff88fbc117a1fc06695efa (patch)
tree6bb40d6fb1ed4df230f167d724981c2c67e475bf /src/select.c
parent62ed36bb5dd4e8a15042d9752abc4223cae3be14 (diff)
downloadsqlite-9debb58e4801ad5737ff88fbc117a1fc06695efa.tar.gz
sqlite-9debb58e4801ad5737ff88fbc117a1fc06695efa.zip
Revisit [f84b2beca7197589]: disallow co-routine implementations of tables
that are to the left of a RIGHT JOIN, to avoid other complications. FossilOrigin-Name: cf00ebfc4b77f45ec466b0d57d7c22c7f48acab19e4e55b168eb4b53f390d887
Diffstat (limited to 'src/select.c')
-rw-r--r--src/select.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/select.c b/src/select.c
index 3672a7c0f..80b488777 100644
--- a/src/select.c
+++ b/src/select.c
@@ -6727,18 +6727,19 @@ int sqlite3Select(
/* Generate code to implement the subquery
**
- ** The subquery is implemented as a co-routine if:
+ ** The subquery is implemented as a co-routine all of the following are
+ ** true:
+ **
** (1) the subquery is guaranteed to be the outer loop (so that
** it does not need to be computed more than once), and
** (2) the subquery is not a CTE that should be materialized
- **
- ** TODO: Are there other reasons beside (1) and (2) to use a co-routine
- ** implementation?
+ ** (3) the subquery is not part of a left operand for a RIGHT JOIN
*/
if( i==0
&& (pTabList->nSrc==1
|| (pTabList->a[1].fg.jointype&(JT_OUTER|JT_CROSS))!=0) /* (1) */
&& (pItem->fg.isCte==0 || pItem->u2.pCteUse->eM10d!=M10d_Yes) /* (2) */
+ && (pTabList->a[0].fg.jointype & JT_LTORJ)==0 /* (3) */
){
/* Implement a co-routine that will return a single row of the result
** set on each invocation.
@@ -6755,9 +6756,6 @@ int sqlite3Select(
pItem->pTab->nRowLogEst = pSub->nSelectRow;
pItem->fg.viaCoroutine = 1;
pItem->regResult = dest.iSdst;
- if( pItem->fg.jointype & JT_LTORJ ){
- sqlite3VdbeAddOp3(v, OP_Null, 0, dest.iSdst, dest.iSdst+dest.nSdst-1);
- }
sqlite3VdbeEndCoroutine(v, pItem->regReturn);
sqlite3VdbeJumpHere(v, addrTop-1);
sqlite3ClearTempRegCache(pParse);