diff options
author | drh <drh@noemail.net> | 2019-11-21 19:37:00 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2019-11-21 19:37:00 +0000 |
commit | 522ebfa7cee96fb325a22ea3a2464a63485886a8 (patch) | |
tree | 270a2eaf1b17376ee4ea60f03ca18deabe886560 /src | |
parent | 57f7ece78410a8aae86aa4625fb7556897db384c (diff) | |
download | sqlite-522ebfa7cee96fb325a22ea3a2464a63485886a8.tar.gz sqlite-522ebfa7cee96fb325a22ea3a2464a63485886a8.zip |
Whenever a generated column is used, assume that all columns are used.
FossilOrigin-Name: 6601da58032d18ae00b466c0f2077fb2b1ecd84225b56e1787724bea478eedc9
Diffstat (limited to 'src')
-rw-r--r-- | src/resolve.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/resolve.c b/src/resolve.c index 9be62c090..fbfdf118e 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -551,9 +551,18 @@ static int lookupName( /* If a column from a table in pSrcList is referenced, then record ** this fact in the pSrcList.a[].colUsed bitmask. Column 0 causes - ** bit 0 to be set. Column 1 sets bit 1. And so forth. If the - ** column number is greater than the number of bits in the bitmask - ** then set the high-order bit of the bitmask. + ** bit 0 to be set. Column 1 sets bit 1. And so forth. + ** + ** The colUsed mask is an optimization used to help determine if an + ** index is a covering index. The correct answer is still obtained + ** if the mask contains extra bits. But omitting bits from the mask + ** might result in an incorrect answer. + ** + ** The high-order bit of the mask is a "we-use-them-all" bit. + ** If the column number is greater than the number of bits in the bitmask + ** then set the high-order bit of the bitmask. Also set the high-order + ** bit if the column is a generated column, as that adds dependencies + ** that are difficult to track, so we assume that all columns are used. */ if( pExpr->iColumn>=0 && pMatch!=0 ){ int n = pExpr->iColumn; @@ -561,7 +570,12 @@ static int lookupName( if( n>=BMS ){ n = BMS-1; } + assert( pExpr->y.pTab!=0 ); assert( pMatch->iCursor==pExpr->iTable ); + if( pExpr->y.pTab->tabFlags & TF_HasGenerated ){ + Column *pCol = pExpr->y.pTab->aCol + pExpr->iColumn; + if( pCol->colFlags & COLFLAG_GENERATED ) n = BMS-1; + } pMatch->colUsed |= ((Bitmask)1)<<n; } |