-C Additional\ssimplifications\sto\sachieve\s100%\sMC/DC.
-D 2026-01-25T13:26:19.936
+C Refactor\sone\sfunction\sname.\s\sComment\simprovements.\s\sNo\sfunctional\schanges.
+D 2026-01-25T18:21:53.279
F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c
F src/resolve.c 47aa7fdc9ec4c19b103ac5e79d7887d30119b5675309facf5eed1118391c868b
F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97
-F src/select.c 076ca826b97cc5c9e344da1fc7e8af49beaa0f0e5328baa5c37fedac7e1a276d
+F src/select.c c43a16c436d342260c6d872c7d0c9afa1fa90705c83f18fbbc0a74d312cd6d08
F src/shell.c.in e8818572acd50464bc00426fe0d755e98239f73d531437c3dc7721d1fecb1231
F src/sqlite.h.in d463dcdd67d4865991cd62dc8d3f678086b38365593861f77c09c3401551d59f
F src/sqlite3.rc 015537e6ac1eec6c7050e17b616c2ffe6f70fca241835a84a4f0d5937383c479
F tool/warnings.sh d924598cf2f55a4ecbc2aeb055c10bd5f48114793e7ba25f9585435da29e7e98
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
F tool/winmain.c 00c8fb88e365c9017db14c73d3c78af62194d9644feaf60e220ab0f411f3604c
-P 82735513762c8adfe7ad4865dcb76c625cbd8f6976bb98f2c342cf98cfdf3b36
-R 11583e75ed2938a81fcd318c1a04fc02
+P 781b7ec0bcaa5d94e8c5fd31b4fe0203393d5209a5f518848f057ec3d2b8d7ac
+R 12674c2f8b312dc84fc35da4be0993ed
U drh
-Z adb88811f9b0a6736b3c500cc897ac0b
+Z 1132ccc2797672409401e1e1fbceab99
# Remove this line to create a well-formed Fossil manifest.
** function is responsible for ensuring that this structure is eventually
** freed.
*/
-static KeyInfo *multiSelectOrderByKeyInfo(Parse *pParse, Select *p, int nExtra){
+static KeyInfo *multiSelectByMergeKeyInfo(Parse *pParse, Select *p, int nExtra){
ExprList *pOrderBy = p->pOrderBy;
int nOrderBy = ALWAYS(pOrderBy!=0) ? pOrderBy->nExpr : 0;
sqlite3 *db = pParse->db;
regCurrent = ++pParse->nMem;
sqlite3VdbeAddOp3(v, OP_OpenPseudo, iCurrent, regCurrent, nCol);
if( pOrderBy ){
- KeyInfo *pKeyInfo = multiSelectOrderByKeyInfo(pParse, p, 1);
+ KeyInfo *pKeyInfo = multiSelectByMergeKeyInfo(pParse, p, 1);
sqlite3VdbeAddOp4(v, OP_OpenEphemeral, iQueue, pOrderBy->nExpr+2, 0,
(char*)pKeyInfo, P4_KEYINFO);
destQueue.pOrderBy = pOrderBy;
#endif /* SQLITE_OMIT_CTE */
/* Forward references */
-static int multiSelectOrderBy(
+static int multiSelectByMerge(
Parse *pParse, /* Parsing context */
Select *p, /* The right-most of SELECTs to be coded */
SelectDest *pDest /* What to do with query results */
/* Compound SELECTs that have an ORDER BY clause are handled separately.
*/
if( p->pOrderBy ){
- return multiSelectOrderBy(pParse, p, pDest);
+ /* If the compound has an ORDER BY clause, then always use the merge
+ ** algorithm. */
+ return multiSelectByMerge(pParse, p, pDest);
}else if( p->op!=TK_ALL ){
+ /* If the compound is EXCEPT, INTERSECT, or UNION (anything other than
+ ** UNION ALL) then also always use the merge algorithm. However, the
+ ** multiSelectByMerge() routine requires that the compound have an
+ ** ORDER BY clause, and it doesn't right now. So invent one first. */
Expr *pOne = sqlite3ExprInt32(db, 1);
p->pOrderBy = sqlite3ExprListAppend(pParse, 0, pOne);
if( pParse->nErr ) goto multi_select_end;
assert( p->pOrderBy!=0 );
p->pOrderBy->a[0].u.x.iOrderByCol = 1;
- return multiSelectOrderBy(pParse, p, pDest);
+ return multiSelectByMerge(pParse, p, pDest);
}else{
+ /* For a UNION ALL compound without ORDER BY, simply run the left
+ ** query, then run the right query */
int addr = 0;
int nLimit = 0; /* Initialize to suppress harmless compiler warning */
if( pParse->nErr ) goto multi_select_end;
/* Compute collating sequences used by
- ** temporary tables needed to implement the compound select.
+ ** temporary table needed to implement the compound select.
** Attach the KeyInfo structure to all temporary tables.
**
** This section is run by the right-most SELECT statement only.
}
/*
-** Alternative compound select code generator for cases when there
-** is an ORDER BY clause.
+** Generate code for a compound SELECT statement using a merge
+** algorithm. The compound must have an ORDER BY clause for this
+** to work.
**
** We assume a query of the following form:
**
**
** outB: Move the output of the selectB coroutine into the output
** of the compound query. (Only generated for UNION and
-** UNION ALL. EXCEPT and INSERTSECT never output a row that
+** UNION ALL. EXCEPT and INTERSECT never output a row that
** appears only in B.)
**
** AltB: Called when there is data from both coroutines and A<B.
** We call AltB, AeqB, AgtB, EofA, and EofB "subroutines" but they are not
** actually called using Gosub and they do not Return. EofA and EofB loop
** until all data is exhausted then jump to the "end" label. AltB, AeqB,
-** and AgtB jump to either L2 or to one of EofA or EofB.
+** and AgtB jump to either Cmpr or to one of EofA or EofB.
*/
#ifndef SQLITE_OMIT_COMPOUND_SELECT
-static int multiSelectOrderBy(
+static int multiSelectByMerge(
Parse *pParse, /* Parsing context */
Select *p, /* The right-most of SELECTs to be coded */
SelectDest *pDest /* What to do with query results */
assert( pItem->u.x.iOrderByCol<=p->pEList->nExpr );
aPermute[i] = pItem->u.x.iOrderByCol - 1;
}
- pKeyMerge = multiSelectOrderByKeyInfo(pParse, p, 1);
+ pKeyMerge = multiSelectByMergeKeyInfo(pParse, p, 1);
}else{
pKeyMerge = 0;
}
** SELECT * FROM (SELECT ... FROM t1 EXCEPT SELECT ... FROM t2)
** ORDER BY ... COLLATE ...
**
-** This transformation is necessary because the multiSelectOrderBy() routine
+** This transformation is necessary because the multiSelectByMerge() routine
** above that generates the code for a compound SELECT with an ORDER BY clause
** uses a merge algorithm that requires the same collating sequence on the
** result columns as on the ORDER BY clause. See ticket
** http://sqlite.org/src/info/6709574d2a
**
** This transformation is only needed for EXCEPT, INTERSECT, and UNION.
-** The UNION ALL operator works fine with multiSelectOrderBy() even when
+** The UNION ALL operator works fine with multiSelectByMerge() even when
** there are COLLATE terms in the ORDER BY.
*/
static int convertCompoundSelectToSubquery(Walker *pWalker, Select *p){