aboutsummaryrefslogtreecommitdiff
path: root/src/select.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/select.c')
-rw-r--r--src/select.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/select.c b/src/select.c
index 90fab7bb8..c6940d704 100644
--- a/src/select.c
+++ b/src/select.c
@@ -2733,9 +2733,10 @@ static int flattenSubquery(
*/
if( ALWAYS(pSubitem->pTab!=0) ){
Table *pTabToDel = pSubitem->pTab;
+ Parse *pRoot = (pParse->pRoot ? pParse->pRoot : pParse);
if( pTabToDel->nRef==1 ){
- pTabToDel->pNextZombie = pParse->pZombieTab;
- pParse->pZombieTab = pTabToDel;
+ pTabToDel->pNextZombie = pRoot->pZombieTab;
+ pRoot->pZombieTab = pTabToDel;
}else{
pTabToDel->nRef--;
}