mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-10 01:02:56 +03:00
Ensure that the SrcList_item.colUsed field is set correctly (set to have a
1 for all columns of the table) when a generated column appears in the USING clause of a join. FossilOrigin-Name: 1923efb283e8840fa7436eb20b9d2174ef7cace1690d3b97b572a0db2048b8e3
This commit is contained in:
@@ -624,15 +624,28 @@ Expr *sqlite3CreateColumnExpr(sqlite3 *db, SrcList *pSrc, int iSrc, int iCol){
|
||||
Expr *p = sqlite3ExprAlloc(db, TK_COLUMN, 0, 0);
|
||||
if( p ){
|
||||
struct SrcList_item *pItem = &pSrc->a[iSrc];
|
||||
p->y.pTab = pItem->pTab;
|
||||
Table *pTab = p->y.pTab = pItem->pTab;
|
||||
p->iTable = pItem->iCursor;
|
||||
if( p->y.pTab->iPKey==iCol ){
|
||||
p->iColumn = -1;
|
||||
}else{
|
||||
p->iColumn = (ynVar)iCol;
|
||||
testcase( iCol==BMS );
|
||||
testcase( iCol==BMS-1 );
|
||||
pItem->colUsed |= ((Bitmask)1)<<(iCol>=BMS ? BMS-1 : iCol);
|
||||
if( pTab->tabFlags & TF_HasGenerated ){
|
||||
Column *pColumn = pTab->aCol + iCol;
|
||||
if( pColumn->colFlags & COLFLAG_GENERATED ){
|
||||
testcase( pTab->nCol==63 );
|
||||
testcase( pTab->nCol==64 );
|
||||
if( pTab->nCol>=64 ){
|
||||
pItem->colUsed = ALLBITS;
|
||||
}else{
|
||||
pItem->colUsed = MASKBIT(pTab->nCol)-1;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
testcase( iCol==BMS );
|
||||
testcase( iCol==BMS-1 );
|
||||
pItem->colUsed |= ((Bitmask)1)<<(iCol>=BMS ? BMS-1 : iCol);
|
||||
}
|
||||
}
|
||||
}
|
||||
return p;
|
||||
|
Reference in New Issue
Block a user