From d446165f7d712dddbecb2f5eaeec418f019b4b7b Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 13 Mar 2019 08:28:51 +0000 Subject: [PATCH] Minor optimization in sqlite3WindowCodeStep(). FossilOrigin-Name: b1322ffb6e63a110998068bf4f0a903028bd4fc0464ae1e517d745fb46423f39 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/window.c | 9 ++++++--- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index ba1585a7b9..c3868871ed 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Allow\sreal\svalues\sto\sbe\sused\sin\sPRECEDING\sand\sFOLLOWING\sexpressions\sfor\sRANGE\swindow\sframes. -D 2019-03-12T18:28:51.117 +C Minor\soptimization\sin\ssqlite3WindowCodeStep(). +D 2019-03-13T08:28:51.566 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 236d2739dc3e823c3c909bca2d6cef93009bafbefd7018a8f3281074ecb92954 @@ -604,7 +604,7 @@ F src/where.c 8a207cb2ca6b99e1edb1e4bbff9b0504385a759cbf66180d1deb34d80ca4b799 F src/whereInt.h 5f14db426ca46a83eabab1ae9aa6d4b8f27504ad35b64c290916289b1ddb2e88 F src/wherecode.c ce7b21e1be2b981d62683fc59c4ca73a04a7ff2f1ebec23d41baf2da2349afd6 F src/whereexpr.c 36b47f7261d6b6f1a72d774c113b74beddf6745aba1018e64b196e29db233442 -F src/window.c 536bc80552d11f95a3524f8a7239727f94115ada67d1dd900e4988196346c225 +F src/window.c ac687a055121a757d951584285d1ae4554245f98cd17f6092118b29c17340d8f F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test a6d901b436328bd67a79b41bb0ac2663918fe3bd F test/affinity3.test 6a101af2fc945ce2912f6fe54dd646018551710d @@ -1812,7 +1812,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5129bcc996b3c9f78ab6b674a4364787e7b353b90f15f027cad4431012022c30 -R f73d694ac4c1f1f064a3ca7465b32f6d +P 25ff7091cb12c63b1864ce68a9151f8432af5804b5ae905a2175761ab4b9fdd8 +R 8c316b11f34d1b1237d8105ff52ba315 U dan -Z ea7ae61d59972a80f1c852bccb429b9d +Z b674509c0d99256be9c341d8d5499a74 diff --git a/manifest.uuid b/manifest.uuid index ac8e6248bf..46dc1c3b61 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -25ff7091cb12c63b1864ce68a9151f8432af5804b5ae905a2175761ab4b9fdd8 \ No newline at end of file +b1322ffb6e63a110998068bf4f0a903028bd4fc0464ae1e517d745fb46423f39 \ No newline at end of file diff --git a/src/window.c b/src/window.c index 4aef228134..a14ebad61d 100644 --- a/src/window.c +++ b/src/window.c @@ -2114,7 +2114,6 @@ void sqlite3WindowCodeStep( Window *pMWin = p->pWin; ExprList *pOrderBy = pMWin->pOrderBy; Vdbe *v = sqlite3GetVdbe(pParse); - int regFlushPart; /* Register for "Gosub flush_partition" */ int csrWrite; /* Cursor used to write to eph. table */ int csrInput = p->pSrc->a[0].iCursor; /* Cursor of sub-select */ int nInput = p->pSrc->a[0].pTab->nCol; /* Number of cols returned by sub */ @@ -2122,7 +2121,7 @@ void sqlite3WindowCodeStep( int addrIfNot; /* Address of OP_IfNot */ int addrGosubFlush; /* Address of OP_Gosub to flush: */ int addrInteger; /* Address of OP_Integer */ - int addrEmpty = 0; /* Address of OP_Rewind in flush: */ + int addrEmpty; /* Address of OP_Rewind in flush: */ int regStart = 0; /* Value of PRECEDING */ int regEnd = 0; /* Value of FOLLOWING */ int regNew; /* Array of registers holding new input row */ @@ -2130,6 +2129,7 @@ void sqlite3WindowCodeStep( int regRowid; /* Rowid for regRecord in eph table */ int regNewPeer = 0; /* Peer values for new row (part of regNew) */ int regPeer = 0; /* Peer values for current row */ + int regFlushPart = 0; /* Register for "Gosub flush_partition" */ WindowCodeArg s; /* Context object for sub-routines */ int lblWhereEnd; /* Label just before sqlite3WhereEnd() code */ @@ -2154,11 +2154,13 @@ void sqlite3WindowCodeStep( s.start.csr = s.current.csr+2; s.end.csr = s.current.csr+3; + /* Allocate registers for the array of values from the sub-query, the + ** samve values in record form, and the rowid used to insert said record + ** into the ephemeral table. */ regNew = pParse->nMem+1; pParse->nMem += nInput; regRecord = ++pParse->nMem; regRowid = ++pParse->nMem; - regFlushPart = ++pParse->nMem; /* If the window frame contains an " PRECEDING" or " FOLLOWING" ** clause, allocate registers to store the results of evaluating each @@ -2203,6 +2205,7 @@ void sqlite3WindowCodeStep( int regNewPart = regNew + pMWin->nBufferCol; KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pPart, 0, 0); + regFlushPart = ++pParse->nMem; addr = sqlite3VdbeAddOp3(v, OP_Compare, regNewPart, pMWin->regPart, nPart); sqlite3VdbeAppendP4(v, (void*)pKeyInfo, P4_KEYINFO); sqlite3VdbeAddOp3(v, OP_Jump, addr+2, addr+4, addr+2); -- 2.47.2