From: drh <> Date: Wed, 13 Apr 2022 17:41:03 +0000 (+0000) Subject: If the OP_NullRow opcode is given a cursor that has not yet been opened, X-Git-Tag: version-3.39.0~206^2~62 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3ac624344d7dae3d4dc30ecb38b950cf49ba000c;p=thirdparty%2Fsqlite.git If the OP_NullRow opcode is given a cursor that has not yet been opened, then go automatically open it to a special pseudo-cursor that allows returns NULL for every column. Used by the new RIGHT JOIN implementation. FossilOrigin-Name: 4526c5d316508093b7f3aeda1ce9d16ceb0be79842015a6d51f28c22b4473ca2 --- diff --git a/manifest b/manifest index 3131341e68..3e4338817a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Move\sthe\sexplain\scomment\sfor\sthe\sRIGHT-JOIN\spost-processing\sloop\sto\sthe\nverify\sbeginning\sof\sthe\sloop\s-\sto\smake\sthe\sstart\sof\sthe\sloop\sclearer\sto\nhuman\sbytecode\sreaders. -D 2022-04-13T16:46:35.568 +C If\sthe\sOP_NullRow\sopcode\sis\sgiven\sa\scursor\sthat\shas\snot\syet\sbeen\sopened,\nthen\sgo\sautomatically\sopen\sit\sto\sa\sspecial\spseudo-cursor\sthat\sallows\sreturns\nNULL\sfor\severy\scolumn.\s\sUsed\sby\sthe\snew\sRIGHT\sJOIN\simplementation. +D 2022-04-13T17:41:03.247 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -624,7 +624,7 @@ F src/upsert.c 8789047a8f0a601ea42fa0256d1ba3190c13746b6ba940fe2d25643a7e991937 F src/utf.c ee39565f0843775cc2c81135751ddd93eceb91a673ea2c57f61c76f288b041a0 F src/util.c 602fe229f32a96ceccae4f40824129669582096f7c355f53dbac156c9fecef23 F src/vacuum.c 6c38ddc52f0619865c91dae9c441d4d48bf3040d7dc1bc5b22da1e45547ed0b3 -F src/vdbe.c 871c55b7eea607980465a3e9d5c1ba1af679789be5e9181af11ed2ff9ffd420f +F src/vdbe.c 6d0790dd22255dc9a1f3fa89131c78aa4b38ec541688a3d722e7646b6b0ed792 F src/vdbe.h 89f5edb1422c8783a0b29db836e409876f2b3e847f78e2b21b1fbcc48a93f85f F src/vdbeInt.h 5f3d0abcf30c2b7a6672ad4386f18be0fca9c9b2cefe18f85a2e3df74f2613bf F src/vdbeapi.c 354c893f1500cf524cc45c32879b9c68893a28b77e3442c24668d6afe4236217 @@ -1947,8 +1947,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 fa9d206f904280e3eafc6f4ba6c0c7325948364c62eeeb9f0fdc5825d622ec35 -R 417e8b623ef51e88d5d23ce84cb0214d +P 7ed2a271e6fcbb5e69a7f3a88d3f45fe6318819c0cc6a0dcc06c3dae5aa1503f +R fa7cb92eb7963a9424648d6e8405a1a6 U drh -Z c96a6f41b9eb32bc9d4646f151818910 +Z 03080d3b275bf11b0b4b2d9c4c59a668 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index cc4629dc90..eef2da0ec5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7ed2a271e6fcbb5e69a7f3a88d3f45fe6318819c0cc6a0dcc06c3dae5aa1503f \ No newline at end of file +4526c5d316508093b7f3aeda1ce9d16ceb0be79842015a6d51f28c22b4473ca2 \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index 45a47756eb..34c3dd1fd4 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -2714,10 +2714,9 @@ op_column_restart: if( pC->cacheStatus!=p->cacheCtr ){ /*OPTIMIZATION-IF-FALSE*/ if( pC->nullRow ){ - if( pC->eCurType==CURTYPE_PSEUDO ){ + if( pC->eCurType==CURTYPE_PSEUDO && pC->seekResult>0 ){ /* For the special case of as pseudo-cursor, the seekResult field ** identifies the register that holds the record */ - assert( pC->seekResult>0 ); pReg = &aMem[pC->seekResult]; assert( pReg->flags & MEM_Blob ); assert( memIsValid(pReg) ); @@ -5802,16 +5801,23 @@ case OP_Rowid: { /* out2 */ ** that occur while the cursor is on the null row will always ** write a NULL. ** -** Or, if P1 is a Pseudo-Cursor (a cursor opened using OP_OpenPseudo) -** just reset the cache for that cursor. This causes the row of -** content held by the pseudo-cursor to be reparsed. +** If cursor P1 is not previously opened, open it now to a special +** pseudo-cursor that always returns NULL for every column. */ case OP_NullRow: { VdbeCursor *pC; assert( pOp->p1>=0 && pOp->p1nCursor ); pC = p->apCsr[pOp->p1]; - assert( pC!=0 ); + if( pC==0 ){ + /* If the cursor is not already open, create a special kind of + ** pseudo-cursor that always gives null rows. */ + pC = allocateCursor(p, pOp->p1, 1, CURTYPE_PSEUDO); + if( pC==0 ) goto no_mem; + pC->seekResult = 0; + pC->isTable = 1; + pC->uc.pCursor = sqlite3BtreeFakeValidCursor(); + } pC->nullRow = 1; pC->cacheStatus = CACHE_STALE; if( pC->eCurType==CURTYPE_BTREE ){