mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-11 01:42:22 +03:00
Add missing comment to new routine in select.c.
FossilOrigin-Name: ef2f0cf21ba61bdd29e09cf41b012a2d757683f524a252f0af7dfee7df1a1a0f
This commit is contained in:
59
src/select.c
59
src/select.c
@@ -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 ){
|
||||
|
||||
Reference in New Issue
Block a user