1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-12 13:01:09 +03:00

Fix to the recomputation of the colUsed field added by check-in

[a9bb71ba708ba722].  This fixes ticket [5829597ac43811e3].

FossilOrigin-Name: 5d14a1c4f2fc17de98ad685ad1422cdfda89dfccb00afcaf32ee416b6f84f525
This commit is contained in:
drh
2020-03-21 23:10:38 +00:00
parent f7f6dbf501
commit 74a07986ce
5 changed files with 38 additions and 30 deletions

View File

@@ -175,6 +175,31 @@ static int areDoubleQuotedStringsEnabled(sqlite3 *db, NameContext *pTopNC){
}
}
/*
** The argument is guaranteed to be a non-NULL Expr node of type TK_COLUMN.
** return the appropriate colUsed mask.
*/
Bitmask sqlite3ExprColUsed(Expr *pExpr){
int n;
Table *pExTab;
n = pExpr->iColumn;
pExTab = pExpr->y.pTab;
assert( pExTab!=0 );
if( (pExTab->tabFlags & TF_HasGenerated)!=0
&& (pExTab->aCol[n].colFlags & COLFLAG_GENERATED)!=0
){
testcase( pExTab->nCol==BMS-1 );
testcase( pExTab->nCol==BMS );
return pExTab->nCol>=BMS ? ALLBITS : MASKBIT(pExTab->nCol)-1;
}else{
testcase( n==BMS-1 );
testcase( n==BMS );
if( n>=BMS ) n = BMS-1;
return ((Bitmask)1)<<n;
}
}
/*
** Given the name of a column of the form X.Y.Z or Y.Z or just Z, look up
** that name in the set of source tables in pSrcList and make the pExpr
@@ -577,22 +602,7 @@ static int lookupName(
** of the table.
*/
if( pExpr->iColumn>=0 && pMatch!=0 ){
int n = pExpr->iColumn;
Table *pExTab = pExpr->y.pTab;
assert( pExTab!=0 );
assert( pMatch->iCursor==pExpr->iTable );
if( (pExTab->tabFlags & TF_HasGenerated)!=0
&& (pExTab->aCol[n].colFlags & COLFLAG_GENERATED)!=0
){
testcase( pExTab->nCol==BMS-1 );
testcase( pExTab->nCol==BMS );
pMatch->colUsed = pExTab->nCol>=BMS ? ALLBITS : MASKBIT(pExTab->nCol)-1;
}else{
testcase( n==BMS-1 );
testcase( n==BMS );
if( n>=BMS ) n = BMS-1;
pMatch->colUsed |= ((Bitmask)1)<<n;
}
pMatch->colUsed |= sqlite3ExprColUsed(pExpr);
}
/* Clean up and return