1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-12 13:01:09 +03:00

Add missing comment to new routine in select.c.

FossilOrigin-Name: ef2f0cf21ba61bdd29e09cf41b012a2d757683f524a252f0af7dfee7df1a1a0f
This commit is contained in:
dan
2021-03-09 16:47:33 +00:00
parent 4fcb30b7d7
commit 96ecb7b004
3 changed files with 37 additions and 39 deletions

View File

@@ -1,5 +1,5 @@
C Experimental\soptimization\sfor\sdistinct\saggregates\s(e.g.\s"SELECT\scount(DISTINCT\s<expr)\sFROM\s...").
D 2021-03-09T16:06:25.224
C Add\smissing\scomment\sto\snew\sroutine\sin\sselect.c.
D 2021-03-09T16:47:33.281
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -542,7 +542,7 @@ F src/printf.c 2b03a80d7c11bb422115dca175a18bf430e9c9dbaa0eee63b758f0c022f8f34f
F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384
F src/resolve.c 688070848f0a0c41bcc545a4b4b052921d9abc29ba3102985d3d6f7595d9637c
F src/rowset.c ba9515a922af32abe1f7d39406b9d35730ed65efab9443dc5702693b60854c92
F src/select.c b51fbd795e5de19bd8448816eb37b098ef679f49b2572a5d570db73aaa2494a6
F src/select.c 7741bb3b315bd9d36c01275fb7a0b319dc30b70054f46a3521acdd71e8615d07
F src/shell.c.in af18a2e980aabe739a8188266464866fe7947b100674e07480e7ba3e37595947
F src/sqlite.h.in 3426a080ea1f222a73e3bd91e7eacbd30570a0117c03d42c6dde606f33e5e318
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
@@ -1910,10 +1910,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 9c9ba36e859e330c50ed40ede4b93eeb0a5c3337240465d953a7be9115a81390
R 05e155a5881f070d054d078349eab572
T *branch * distinct-agg-opt
T *sym-distinct-agg-opt *
T -sym-trunk *
P eb919611fd2f255e4ad1fe7db633363793169f6cf99c650eaefa48c022eb5d22
R 9199f92495fd5d3674624db01699c96b
U dan
Z a27a5de08cdd8303a3cf21c478413fb4
Z a3e310de94fb22aed527b8a42451f5c8

View File

@@ -1 +1 @@
eb919611fd2f255e4ad1fe7db633363793169f6cf99c650eaefa48c022eb5d22
ef2f0cf21ba61bdd29e09cf41b012a2d757683f524a252f0af7dfee7df1a1a0f

View File

@@ -740,37 +740,38 @@ static void codeOffset(
}
}
#if 0
/*
** Add code that will check to make sure the N registers starting at iMem
** form a distinct entry. iTab is a sorting index that holds previously
** seen combinations of the N values. A new entry is made in iTab
** if the current N values are new.
** Add code that will check to make sure the array of registers starting at
** iMem form a distinct entry. This is used by both "SELECT DISTINCT ..." and
** distinct aggregates ("SELECT count(DISTINCT <expr>) ..."). Parameter iTab is
** the cursor number of an ephemeral table opened by instruction iTabAddr for
** the code generated by this routine to use. There are three strategies, based
** on the value of parameter eTnctType:
**
** A jump to addrRepeat is made and the N+1 values are popped from the
** stack if the top N elements are not distinct.
** WHERE_DISTINCT_UNORDERED/WHERE_DISTINCT_NOOP:
** The ephemeral cursor table is queries for a record identical to the
** record formed by the current array of registers. If one is found,
** jump to VM address addrRepeat. Otherwise, insert a new record into
** the ephemeral cursor and proceed.
**
** WHERE_DISTINCT_ORDERED:
** In this case rows are being delivered sorted order sorted. The ephermal
** table is not required in this case. Instead, the current set of
** registers are compared to previous row. If they match, the new row
** is not distinct and control jumps to VM address addrRepeat. Otherwise,
** the VM program proceeds with processing the new row.
**
** WHERE_DISTINCT_UNIQUE:
** In this case it has already been determined that the rows are distinct.
** No special action is required.
**
** Parameter pEList is the list of expressions used to generated the
** contents of each row. It is used by this routine to determine (a)
** how many elements there are in the array of registers and (b) the
** collation sequences that should be used for the comparisons if
** eTnctType is WHERE_DISTINCT_ORDERED.
*/
static void codeDistinct(
Parse *pParse, /* Parsing and code generating context */
int iTab, /* A sorting index used to test for distinctness */
int addrRepeat, /* Jump to here if not distinct */
int N, /* Number of elements */
int iMem /* First element */
){
Vdbe *v;
int r1;
v = pParse->pVdbe;
r1 = sqlite3GetTempReg(pParse);
sqlite3VdbeAddOp4Int(v, OP_Found, iTab, addrRepeat, iMem, N); VdbeCoverage(v);
sqlite3VdbeAddOp3(v, OP_MakeRecord, iMem, N, r1);
sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iTab, r1, iMem, N);
sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
sqlite3ReleaseTempReg(pParse, r1);
}
#endif
static void codeDistinct2(
Parse *pParse, /* Parsing and code generating context */
int eTnctType, /* WHERE_DISTINCT_* value */
int iTab, /* A sorting index used to test for distinctness */
@@ -1087,7 +1088,7 @@ static void selectInnerLoop(
*/
if( hasDistinct ){
assert( nResultCol==p->pEList->nExpr );
codeDistinct2(pParse, pDistinct->eTnctType, pDistinct->tabTnct,
codeDistinct(pParse, pDistinct->eTnctType, pDistinct->tabTnct,
pDistinct->addrTnct, iContinue, p->pEList, regResult);
if( pSort==0 ){
codeOffset(v, p->iOffset, iContinue);
@@ -5748,7 +5749,7 @@ static void updateAccumulator(
}
testcase( nArg==0 ); /* Error condition */
testcase( nArg>1 ); /* Also an error */
codeDistinct2(pParse, eDistinctType, pF->iDistinct, pF->iDistAddr,
codeDistinct(pParse, eDistinctType, pF->iDistinct, pF->iDistAddr,
addrNext, pList, regAgg);
}
if( pF->pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL ){