From 62ed36bb5dd4e8a15042d9752abc4223cae3be14 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sun, 10 Apr 2022 20:28:41 +0000 Subject: [PATCH] Minor improvements to the sqlite3SrcListShiftJoinType() routine. This started out to be an effort to convert RIGHT JOIN to LEFT JOIN if the join was on the first pair of relations, but that messes up the "*" expansion and so won't work. FossilOrigin-Name: a48902c71ed30c83de7dbd26d1c7956136c35dc53b1076bc8b1ebcba568a3fd3 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/build.c | 15 +++++++++++---- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 300a7c0914..c280af91e6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\sthe\sleft-most\stable\sof\sa\sRIGHT\sJOIN\sis\simplemented\sas\sa\sco-routine,\s\nmake\ssure\sall\sits\scolumns\sare\sflushed\sto\sNULL\swhen\sit\sfinishes\sso\sthat\nthey\sappear\sto\sbe\sNULL\sduring\sthe\sRIGHT\sJOIN\spost-processing. -D 2022-04-10T19:51:22.704 +C Minor\simprovements\sto\sthe\ssqlite3SrcListShiftJoinType()\sroutine.\s\sThis\sstarted\nout\sto\sbe\san\seffort\sto\sconvert\sRIGHT\sJOIN\sto\sLEFT\sJOIN\sif\sthe\sjoin\swas\son\nthe\sfirst\spair\sof\srelations,\sbut\sthat\smesses\sup\sthe\s"*"\sexpansion\sand\sso\swon't\nwork. +D 2022-04-10T20:28:41.210 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -495,7 +495,7 @@ F src/btmutex.c 8acc2f464ee76324bf13310df5692a262b801808984c1b79defb2503bbafadb6 F src/btree.c 45161c2d5c9527b9c9bbfd7478daf3e0a619cf4bbe3278378aaea3d4b4e4f5b5 F src/btree.h 74d64b8f28cfa4a894d14d4ed64fa432cd697b98b61708d4351482ae15913e22 F src/btreeInt.h 8ce1332edd89dfd2461d561ac10a0ab5601c8e06200cb5230596c3caaf54482e -F src/build.c 4a35acbeb5a73e5dfb0ed199a4ba601179cd22216654f9eb14c1dcfe993673e8 +F src/build.c d30ef1cbd19efbaf8596521589f2a56292325e03f0801bf160608da7b03a03ff F src/callback.c 4c19af69835787bfe790ac560f3071a824eb629f34e41f97b52ce5235c77de1c F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c 026dbdcdbd8c3cde98a88483ee88310ff43150ab164ad768f12cc700a11495ad @@ -1946,8 +1946,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 140e97fde94fdc3babdd456ce1b22900ead0e40e2afe63d89d21ccdbf141b607 -R 4785f5aaf180af8e1a0a99264df2d1f5 +P f84b2beca719758979d7a5a63c3d16d5121a7518b3fbe5039af474a83dd569c2 +R cd052684f405fbc67ae88c7e7611d8e4 U drh -Z 69bb375996d123a078fecd333472e7f3 +Z ff6cefb3fcd28c733eed400a6a07e7f1 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index ac3f707f78..a904647d09 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f84b2beca719758979d7a5a63c3d16d5121a7518b3fbe5039af474a83dd569c2 \ No newline at end of file +a48902c71ed30c83de7dbd26d1c7956136c35dc53b1076bc8b1ebcba568a3fd3 \ No newline at end of file diff --git a/src/build.c b/src/build.c index 7181011c32..22f7a79e05 100644 --- a/src/build.c +++ b/src/build.c @@ -5067,14 +5067,21 @@ void sqlite3SrcListFuncArgs(Parse *pParse, SrcList *p, ExprList *pList){ ** The operator is "natural cross join". The A and B operands are stored ** in p->a[0] and p->a[1], respectively. The parser initially stores the ** operator with A. This routine shifts that operator over to B. +** +** Additional changes: +** +** * All tables to the left of the right-most RIGHT JOIN are tagged with +** JT_LTORJ (mnemonic: Left Table Of Right Join) so that the +** code generator can easily tell that the table is part of +** the left operand of at least one RIGHT JOIN. */ void sqlite3SrcListShiftJoinType(SrcList *p){ - if( p ){ - int i; + if( p && p->nSrc>1 ){ + int i = p->nSrc-1; u8 allFlags = 0; - for(i=p->nSrc-1; i>0; i--){ + do{ allFlags |= p->a[i].fg.jointype = p->a[i-1].fg.jointype; - } + }while( (--i)>0 ); p->a[0].fg.jointype = 0; /* All terms to the left of a RIGHT JOIN should be tagged with the -- 2.47.2