diff options
author | drh <> | 2021-08-02 16:41:57 +0000 |
---|---|---|
committer | drh <> | 2021-08-02 16:41:57 +0000 |
commit | f38524d20db165c94dc94e06b62f0aad5942a03b (patch) | |
tree | d5f916ae22a0bae1a3d7168c0b1a031d6c22da92 /src/select.c | |
parent | 79cf2b7120ea382a2649698656860d09740e6205 (diff) | |
download | sqlite-f38524d20db165c94dc94e06b62f0aad5942a03b.tar.gz sqlite-f38524d20db165c94dc94e06b62f0aad5942a03b.zip |
Refactor the Table object to reduce its memory footprint.
FossilOrigin-Name: bbb6759bcf6e01d36dfc787a82a610d359f50aaeac8104b73883a84906d54e1f
Diffstat (limited to 'src/select.c')
-rw-r--r-- | src/select.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/src/select.c b/src/select.c index 66e1434a3..d6708c231 100644 --- a/src/select.c +++ b/src/select.c @@ -4933,7 +4933,7 @@ static Table *isSimpleCount(Select *p, AggInfo *pAggInfo){ } pTab = p->pSrc->a[0].pTab; pExpr = p->pEList->a[0].pExpr; - assert( pTab && !pTab->pSelect && pExpr ); + assert( pTab && !IsView(pTab) && pExpr ); if( IsVirtual(pTab) ) return 0; if( pExpr->op!=TK_AGG_FUNCTION ) return 0; @@ -5478,30 +5478,31 @@ static int selectExpander(Walker *pWalker, Select *p){ return WRC_Abort; } #if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE) - if( IsVirtual(pTab) || pTab->pSelect ){ + if( !IsOrdinaryTable(pTab) ){ i16 nCol; u8 eCodeOrig = pWalker->eCode; if( sqlite3ViewGetColumnNames(pParse, pTab) ) return WRC_Abort; assert( pFrom->pSelect==0 ); - if( pTab->pSelect - && (db->flags & SQLITE_EnableView)==0 - && pTab->pSchema!=db->aDb[1].pSchema - ){ - sqlite3ErrorMsg(pParse, "access to view \"%s\" prohibited", - pTab->zName); - } + if( IsView(pTab) ){ + if( (db->flags & SQLITE_EnableView)==0 + && pTab->pSchema!=db->aDb[1].pSchema + ){ + sqlite3ErrorMsg(pParse, "access to view \"%s\" prohibited", + pTab->zName); + } + pFrom->pSelect = sqlite3SelectDup(db, pTab->u.view.pSelect, 0); + }else #ifndef SQLITE_OMIT_VIRTUALTABLE - assert( SQLITE_VTABRISK_Normal==1 && SQLITE_VTABRISK_High==2 ); - if( IsVirtual(pTab) + if( ALWAYS(IsVirtual(pTab)) && pFrom->fg.fromDDL - && ALWAYS(pTab->pVTable!=0) - && pTab->pVTable->eVtabRisk > ((db->flags & SQLITE_TrustedSchema)!=0) + && ALWAYS(pTab->u.vtab.p!=0) + && pTab->u.vtab.p->eVtabRisk > ((db->flags & SQLITE_TrustedSchema)!=0) ){ sqlite3ErrorMsg(pParse, "unsafe use of virtual table \"%s\"", pTab->zName); } + assert( SQLITE_VTABRISK_Normal==1 && SQLITE_VTABRISK_High==2 ); #endif - pFrom->pSelect = sqlite3SelectDup(db, pTab->pSelect, 0); nCol = pTab->nCol; pTab->nCol = -1; pWalker->eCode = 1; /* Turn on Select.selId renumbering */ |