aboutsummaryrefslogtreecommitdiff
path: root/src/wherecode.c
diff options
context:
space:
mode:
authordrh <>2022-04-09 03:16:26 +0000
committerdrh <>2022-04-09 03:16:26 +0000
commitc2308ad2a0cb4f6d957518c615d308ed79b42d04 (patch)
tree9942b2760a4d6e5a99536135f9f3f6d37942db01 /src/wherecode.c
parentc1871630908063abfb0915fd0598f0a1ff783666 (diff)
downloadsqlite-c2308ad2a0cb4f6d957518c615d308ed79b42d04.tar.gz
sqlite-c2308ad2a0cb4f6d957518c615d308ed79b42d04.zip
A few bits and bobs of code generation toward getting RIGHT JOIN to work.
Much more remains to do. FossilOrigin-Name: 55b4543122646997d928598343bc467c993f971e86e9037c85430cc948750576
Diffstat (limited to 'src/wherecode.c')
-rw-r--r--src/wherecode.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/wherecode.c b/src/wherecode.c
index 74873de09..5b8ed8934 100644
--- a/src/wherecode.c
+++ b/src/wherecode.c
@@ -2721,6 +2721,41 @@ Bitmask sqlite3WhereCodeOneLoopStart(
}
}
+ /* For a RIGHT OUTER JOIN, record the fact that the current row has
+ ** been matched at least once.
+ */
+ if( pLevel->iRJMatch ){
+ Table *pTab;
+ int nPk;
+ int r;
+ int jmp1 = 0;
+
+ pTab = pWInfo->pTabList->a[pLevel->iFrom].pTab;
+ if( HasRowid(pTab) ){
+ r = sqlite3GetTempRange(pParse, 2);
+ sqlite3ExprCodeGetColumnOfTable(v, pTab, pLevel->iTabCur, -1, r+1);
+ nPk = 1;
+ }else{
+ int iPk;
+ Index *pPk = sqlite3PrimaryKeyIndex(pTab);
+ nPk = pPk->nKeyCol;
+ r = sqlite3GetTempRange(pParse, nPk+1);
+ for(iPk=0; iPk<nPk; iPk++){
+ int iCol = pPk->aiColumn[iPk];
+ sqlite3ExprCodeGetColumnOfTable(v, pTab, iCur, iCol,r+1+iPk);
+ }
+ }
+ jmp1 = sqlite3VdbeAddOp4Int(v, OP_Found, pLevel->iRJMatch, 0, r+1, nPk);
+ VdbeCoverage(v);
+ sqlite3VdbeAddOp3(v, OP_MakeRecord, r+1, nPk, r);
+ sqlite3VdbeAddOp4Int(v, OP_IdxInsert, pLevel->iRJMatch, r, r+1, nPk);
+ sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
+ sqlite3VdbeJumpHere(v, jmp1);
+
+ /* Release the array of temp registers */
+ sqlite3ReleaseTempRange(pParse, r, nPk+1);
+ }
+
#if WHERETRACE_ENABLED /* 0x20800 */
if( sqlite3WhereTrace & 0x20000 ){
sqlite3DebugPrintf("All WHERE-clause terms after coding level %d:\n",