]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Refactor one function name. Comment improvements. No functional changes.
authordrh <>
Sun, 25 Jan 2026 18:21:53 +0000 (18:21 +0000)
committerdrh <>
Sun, 25 Jan 2026 18:21:53 +0000 (18:21 +0000)
FossilOrigin-Name: 5b4c0a5e8609e16a4b08b7f95d55e513ee4300b22d044ac8f42e60b96cff5be6

manifest
manifest.uuid
src/select.c

index 985c3b68e747d328660c65ab1bba2523c911194b..9b93a36c5ab2e37bf9707fc4f5ab3db9c2d4af8d 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-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
@@ -738,7 +738,7 @@ F src/printf.c b1b29b5e58e1530d5daeee5963d3c318d8ab2d7e38437580e28755753e0c1ded
 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
@@ -2193,8 +2193,8 @@ F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee
 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.
index 902cb1dd802d9cbb1d2d6c56066081297366026e..1e46ac2c6dbb27cc722611db5cb00622acbaf58c 100644 (file)
@@ -1 +1 @@
-781b7ec0bcaa5d94e8c5fd31b4fe0203393d5209a5f518848f057ec3d2b8d7ac
+5b4c0a5e8609e16a4b08b7f95d55e513ee4300b22d044ac8f42e60b96cff5be6
index a41529eb901068d87a6254f3f5551c9b9a5b712b..b823f3ed3a77cd698d6287fad980d339548da65e 100644 (file)
@@ -2585,7 +2585,7 @@ static CollSeq *multiSelectCollSeq(Parse *pParse, Select *p, int iCol){
 ** 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;
@@ -2720,7 +2720,7 @@ static void generateWithRecursiveQuery(
   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;
@@ -2805,7 +2805,7 @@ end_of_recursive_query:
 #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 */
@@ -2958,15 +2958,23 @@ static int multiSelect(
   /* 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 */
 
@@ -3023,7 +3031,7 @@ static int multiSelect(
   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.
@@ -3337,8 +3345,9 @@ static int generateOutputSubroutine(
 }
 
 /*
-** 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:
 **
@@ -3355,7 +3364,7 @@ static int generateOutputSubroutine(
 **
 **    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.
@@ -3419,10 +3428,10 @@ static int generateOutputSubroutine(
 ** 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 */
@@ -3519,7 +3528,7 @@ static int multiSelectOrderBy(
       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;
   }
@@ -5505,14 +5514,14 @@ int sqlite3IndexedByLookup(Parse *pParse, SrcItem *pFrom){
 **    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){