From 9904d824b890b9b30c514c14f2c5fcbc4118f456 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 21 Aug 2024 17:38:50 +0000 Subject: [PATCH] Improved comments on byte-code subroutine calls to materialize subqueries. Should not affect production builds. FossilOrigin-Name: 6b024c85ef856e26cddac8ad862e16909b5149c3e3efb4e73ba54c97291f1cc4 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/select.c | 1 + src/where.c | 12 +++++++----- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index e6ceef9686..eba71f8794 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C README.md:\sa\smarkup\slink\sfix\sand\suse\sthe\scanonical\sURL\sfor\sFossil. -D 2024-08-21T13:57:30.455 +C Improved\scomments\son\sbyte-code\ssubroutine\scalls\sto\smaterialize\ssubqueries.\nShould\snot\saffect\sproduction\sbuilds. +D 2024-08-21T17:38:50.489 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -764,7 +764,7 @@ F src/printf.c 6a87534ebfb9e5346011191b1f3a7ebc457f5938c7e4feeea478ecf53f6a41b2 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 9afed5fd7b9111633bdb74a73cdc47324e28e4dc6c27113e3e9aee38fb9422ab F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 -F src/select.c 26bd0ce6e8816f8968f50a377dc4255da4b392793e87ae27acd7276b56a447ce +F src/select.c 4b14337a2742f0c0beeba490e9a05507e9b4b12184b9cd12773501d08d48e3fe F src/shell.c.in fb7fe0a39473e7a3ad5ad7076ff49d87aa8ed7fdd98a1595345747ac5d78ac2b F src/sqlite.h.in 1ad9110150773c38ebababbad11b5cb361bcd3997676dec1c91ac5e0416a7b86 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 @@ -850,7 +850,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 887fc4ca3f020ebb2e376f222069570834ac63bf50111ef0cbf3ae417048ed89 F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c d5006d6b005e4ea7302ad390957a8d41ed83faa177e412f89bc5600a7462a014 -F src/where.c b6f79b189fcba459bb80420d3b4102f42a399be36ff29a3deff4ae4888fee46d +F src/where.c 61fea6c34c9c2350b114a4f64dce51ec073c2d8c50ca0734a0882ba6ab531805 F src/whereInt.h 6444b888ce395cb80511284b8a73b63472d34247fcb1b125ee06a54fa6ae878e F src/wherecode.c 137797b0de9ddf1ff43e5b0edffcc76fb05184ed651fc4f5a0a01a45c0b89d04 F src/whereexpr.c 44f41ae554c7572e1de1485b3169b233ee04d464b2ee5881687ede3bf07cacfa @@ -2210,8 +2210,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 3161b8028916bff9a13a04bfb1996bce7e1274a3c403fc58f4d798afd30c528f -R 2e449f153f783008445322155cf77dd3 -U stephan -Z fedf47a9f8fa7c0c7d99b3ea8b72d3a3 +P c49bfee6b878bd96adfc852fdc76e98bf81e2fb82be8325672fbc7af04e7dffa +R 862ab59c7e7e7a7369184a7d27a7302b +U drh +Z 51170964494b840c9c6cd6315a6727db # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 04eae5dbf7..2c55f6f94e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c49bfee6b878bd96adfc852fdc76e98bf81e2fb82be8325672fbc7af04e7dffa +6b024c85ef856e26cddac8ad862e16909b5149c3e3efb4e73ba54c97291f1cc4 diff --git a/src/select.c b/src/select.c index 0bb033785c..9fcf30ff4a 100644 --- a/src/select.c +++ b/src/select.c @@ -7863,6 +7863,7 @@ int sqlite3Select( pItem->fg.viaCoroutine = 1; pSubq->regResult = dest.iSdst; sqlite3VdbeEndCoroutine(v, pSubq->regReturn); + VdbeComment((v, "end %!S", pItem)); sqlite3VdbeJumpHere(v, addrTop-1); sqlite3ClearTempRegCache(pParse); }else if( pItem->fg.isCte && pItem->u2.pCteUse->addrM9e>0 ){ diff --git a/src/where.c b/src/where.c index c9f6b97c94..6e494850c3 100644 --- a/src/where.c +++ b/src/where.c @@ -7122,15 +7122,17 @@ WhereInfo *sqlite3WhereBegin( pSrc = &pTabList->a[pLevel->iFrom]; if( pSrc->fg.isMaterialized ){ Subquery *pSubq; + int iOnce = 0; assert( pSrc->fg.isSubquery ); pSubq = pSrc->u4.pSubq; - if( pSrc->fg.isCorrelated ){ - sqlite3VdbeAddOp2(v, OP_Gosub, pSubq->regReturn, pSubq->addrFillSub); + if( pSrc->fg.isCorrelated==0 ){ + iOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v); }else{ - int iOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v); - sqlite3VdbeAddOp2(v, OP_Gosub, pSubq->regReturn, pSubq->addrFillSub); - sqlite3VdbeJumpHere(v, iOnce); + iOnce = 0; } + sqlite3VdbeAddOp2(v, OP_Gosub, pSubq->regReturn, pSubq->addrFillSub); + VdbeComment((v, "materialize %!S", pSrc)); + if( iOnce ) sqlite3VdbeJumpHere(v, iOnce); } assert( pTabList == pWInfo->pTabList ); if( (wsFlags & (WHERE_AUTO_INDEX|WHERE_BLOOMFILTER))!=0 ){