aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <>2024-04-25 23:26:11 +0000
committerdrh <>2024-04-25 23:26:11 +0000
commitec14ef80b03eb0b7bd05a6ce3beb07c9601bde63 (patch)
treec2e2c6e124efc33111cf4f2fdeb1790883fc8a37 /src
parentc859f0267c3f53a0bb8ee92125ee9a5d2a6153ee (diff)
parentddc6bd9f21ab9420eb91beec3f2e49f595116eb2 (diff)
downloadsqlite-ec14ef80b03eb0b7bd05a6ce3beb07c9601bde63.tar.gz
sqlite-ec14ef80b03eb0b7bd05a6ce3beb07c9601bde63.zip
Improvement to the way that affinity is determined for columns of a
compound subquery. The affinity is the affinity of the left-most arm of the compound subquery that has an affinity other than NONE, adjusted to accommodate the data types coming out of the other arms. FossilOrigin-Name: e6df846f36209bac3e420dd80ce2bbbd87ab7a20b8063fce05f78a3c7ab6027e
Diffstat (limited to 'src')
-rw-r--r--src/select.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/select.c b/src/select.c
index 9c2bf3b93..8ee59cf68 100644
--- a/src/select.c
+++ b/src/select.c
@@ -2336,17 +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 && pSelect->pNext ){
- int m = 0;
- Select *pS2;
- for(m=0, pS2=pSelect->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 ){