mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-10 01:02:56 +03:00
Whenever a generated column is used, assume that all columns are used.
FossilOrigin-Name: 6601da58032d18ae00b466c0f2077fb2b1ecd84225b56e1787724bea478eedc9
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user