diff options
author | drh <> | 2024-04-25 17:52:10 +0000 |
---|---|---|
committer | drh <> | 2024-04-25 17:52:10 +0000 |
commit | ddc6bd9f21ab9420eb91beec3f2e49f595116eb2 (patch) | |
tree | 8382c208b8beb9e555068162779c4a2efbf730c5 /src/select.c | |
parent | 23afc2c4ec1abc95f61e75411926527e93ebb500 (diff) | |
download | sqlite-ddc6bd9f21ab9420eb91beec3f2e49f595116eb2.tar.gz sqlite-ddc6bd9f21ab9420eb91beec3f2e49f595116eb2.zip |
Further improvements to the computation of affinity for compound subqueries:
make sure that the selected affinity is compatible with a literal values in
arms to the left of the arm that is used to determine affinity.
FossilOrigin-Name: bbdf22e3d989f42b963f1f2f219dfeac11db786f17ac27097ab72f72e7638a2a
Diffstat (limited to 'src/select.c')
-rw-r--r-- | src/select.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/select.c b/src/select.c index 785f9bc25..8ee59cf68 100644 --- a/src/select.c +++ b/src/select.c @@ -2336,21 +2336,22 @@ void sqlite3SubqueryColumnTypes( for(i=0, pCol=pTab->aCol; i<pTab->nCol; i++, pCol++){ const char *zType; i64 n; + int m = 0; Select *pS2 = pSelect; pTab->tabFlags |= (pCol->colFlags & COLFLAG_NOINSERT); p = a[i].pExpr; /* pCol->szEst = ... // Column size est for SELECT tables never used */ pCol->affinity = sqlite3ExprAffinity(p); while( pCol->affinity<=SQLITE_AFF_NONE && pS2->pNext!=0 ){ + m |= sqlite3ExprDataType(pS2->pEList->a[i].pExpr); pS2 = pS2->pNext; pCol->affinity = sqlite3ExprAffinity(pS2->pEList->a[i].pExpr); } if( pCol->affinity<=SQLITE_AFF_NONE ){ pCol->affinity = aff; } - if( pCol->affinity>=SQLITE_AFF_TEXT && pS2->pNext ){ - int m = 0; - for(m=0, pS2=pS2->pNext; pS2; pS2=pS2->pNext){ + if( pCol->affinity>=SQLITE_AFF_TEXT && (pS2->pNext || pS2!=pSelect) ){ + for(pS2=pS2->pNext; pS2; pS2=pS2->pNext){ m |= sqlite3ExprDataType(pS2->pEList->a[i].pExpr); } if( pCol->affinity==SQLITE_AFF_TEXT && (m&0x01)!=0 ){ |