aboutsummaryrefslogtreecommitdiff
path: root/src/resolve.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2020-03-21 23:10:38 +0000
committerdrh <drh@noemail.net>2020-03-21 23:10:38 +0000
commit74a07986cee851014e2bd154e0376768cd4d07b5 (patch)
tree7c81222e21b149bc5270140668afbb2b3428a51c /src/resolve.c
parentf7f6dbf501df83d70e7e39f8f46d1b0c149c63c6 (diff)
downloadsqlite-74a07986cee851014e2bd154e0376768cd4d07b5.tar.gz
sqlite-74a07986cee851014e2bd154e0376768cd4d07b5.zip
Fix to the recomputation of the colUsed field added by check-in
[a9bb71ba708ba722]. This fixes ticket [5829597ac43811e3]. FossilOrigin-Name: 5d14a1c4f2fc17de98ad685ad1422cdfda89dfccb00afcaf32ee416b6f84f525
Diffstat (limited to 'src/resolve.c')
-rw-r--r--src/resolve.c42
1 files changed, 26 insertions, 16 deletions
diff --git a/src/resolve.c b/src/resolve.c
index 0364407d4..e90e8a768 100644
--- a/src/resolve.c
+++ b/src/resolve.c
@@ -176,6 +176,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
** expression node refer back to that source column. The following changes
@@ -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