diff options
author | drh <> | 2025-05-30 19:55:46 +0000 |
---|---|---|
committer | drh <> | 2025-05-30 19:55:46 +0000 |
commit | dd16539e71e375abbe2affa3b142f2454a3d9edc (patch) | |
tree | c699ec0c9a3fa825933536c5357c792db39469b9 /src | |
parent | f42ceb9075c6dc64e36c17a1836ea3a0a2b4e8f6 (diff) | |
download | sqlite-dd16539e71e375abbe2affa3b142f2454a3d9edc.tar.gz sqlite-dd16539e71e375abbe2affa3b142f2454a3d9edc.zip |
When synthesizing an ON constraint from a USING or NATURAL, if the left-hand
side is coming from a RIGHT JOIN, be sure to set the EP_CanBeNull flag so that
the optimizer knows to check for NULL even if the column has a NOT NULL
constraint. Fix for the problem reported by
[forum:/forumpost/4fc70203b61c7e12|forum post 4fc70203b61]
FossilOrigin-Name: 60adc78a22956429d34ccc4e2c193c5994c11c3b3cff7901d47fad7d92dba935
Diffstat (limited to 'src')
-rw-r--r-- | src/select.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/select.c b/src/select.c index 3b951afff..da0aa63e4 100644 --- a/src/select.c +++ b/src/select.c @@ -596,7 +596,7 @@ static int sqlite3ProcessJoin(Parse *pParse, Select *p){ } pE1 = sqlite3CreateColumnExpr(db, pSrc, iLeft, iLeftCol); sqlite3SrcItemColumnUsed(&pSrc->a[iLeft], iLeftCol); - if( (pSrc->a[0].fg.jointype & JT_LTORJ)!=0 ){ + if( (pSrc->a[0].fg.jointype & JT_LTORJ)!=0 && pParse->nErr==0 ){ /* This branch runs if the query contains one or more RIGHT or FULL ** JOINs. If only a single table on the left side of this join ** contains the zName column, then this branch is a no-op. @@ -612,6 +612,8 @@ static int sqlite3ProcessJoin(Parse *pParse, Select *p){ */ ExprList *pFuncArgs = 0; /* Arguments to the coalesce() */ static const Token tkCoalesce = { "coalesce", 8 }; + assert( pE1!=0 ); + ExprSetProperty(pE1, EP_CanBeNull); while( tableAndColumnIndex(pSrc, iLeft+1, i, zName, &iLeft, &iLeftCol, pRight->fg.isSynthUsing)!=0 ){ if( pSrc->a[iLeft].fg.isUsing==0 |