]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Comment changes in select.c. (CVS 4691)
authordanielk1977 <danielk1977@noemail.net>
Mon, 7 Jan 2008 10:16:40 +0000 (10:16 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Mon, 7 Jan 2008 10:16:40 +0000 (10:16 +0000)
FossilOrigin-Name: 38020592f15c072e0d221ae2e0df13508ac4bd49

manifest
manifest.uuid
src/select.c

index 1af51c90abbc5b2d1dc6f9d9a899ca413737369a..5d0a75fd6f1d4d60f11330851cf42f601457447b 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Registerify\sthe\sSRT_Subroutine\sdestination\sfor\sSELECT\sresults.\s(CVS\s4690)
-D 2008-01-06T00:25:22
+C Comment\schanges\sin\sselect.c.\s(CVS\s4691)
+D 2008-01-07T10:16:41
 F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
 F Makefile.in 30789bf70614bad659351660d76b8e533f3340e9
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -131,7 +131,7 @@ F src/pragma.c dfb200ec383b5ab3e81cd7bc4e1305e71053ef9a
 F src/prepare.c f1bb8eb642082e618a359c08e3e107490eafe0e3
 F src/printf.c eb27822ba2eec669161409ca31279a24c26ac910
 F src/random.c 4a22746501bf36b0a088c66e38dde5daba6a35da
-F src/select.c 3dc81bc22d54b4b08a825f926587e1f96ded57c3
+F src/select.c 31faeb619940082085e75f4cbef3f44c5e0f12d5
 F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96
 F src/shell.c 5391e889384d2062249f668110d64ed16f601c4b
 F src/sqlite.h.in 2a7e3776534bbe6ff2cdc058f3abebe91e7e429f
@@ -604,7 +604,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
 F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
-P 6bb1b1bc1858028b743a4f660d42d5e9595dc022
-R b9dfb6958eba47fbda8ba22262d4cfe6
-U drh
-Z 16b2a7371bc928893099feda1e3b8325
+P 8201f71729c3afbb41764cea3cda65b03150cb0c
+R e1386487a1716925644579ddb593d24b
+U danielk1977
+Z f79dec53250d0fbc0e2807bb20650e3c
index 2bc122dafa9811cbe352280ad03fb5b09c632632..e1ed53647b46d14c59c109377e0c28344433c8e1 100644 (file)
@@ -1 +1 @@
-8201f71729c3afbb41764cea3cda65b03150cb0c
\ No newline at end of file
+38020592f15c072e0d221ae2e0df13508ac4bd49
\ No newline at end of file
index 2280cf68793860568f02ef00c9d60c697c860865..e818218e842959a8330253de021e57f546b0f56d 100644 (file)
@@ -12,7 +12,7 @@
 ** This file contains C code routines that are called by the parser
 ** to handle SELECT statements in SQLite.
 **
-** $Id: select.c,v 1.390 2008/01/06 00:25:22 drh Exp $
+** $Id: select.c,v 1.391 2008/01/07 10:16:41 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 
@@ -2642,8 +2642,10 @@ static int flattenSubquery(
 ** it is, or 0 otherwise. At present, a query is considered to be
 ** a min()/max() query if:
 **
-**   1. The result set contains exactly one element, either 
-**      min(x) or max(x), where x is a column identifier.
+**   1. There is a single object in the FROM clause.
+**
+**   2. There is a single expression in the result set, and it is
+**      either min(x) or max(x), where x is a column reference.
 */
 static int minMaxQuery(Parse *pParse, Select *p){
   Expr *pExpr;
@@ -3652,6 +3654,31 @@ int sqlite3Select(
       ExprList *pDel = 0;
       u8 flag;
 
+      /* Check if the query is of one of the following forms:
+      **
+      **   SELECT min(x) FROM ...
+      **   SELECT max(x) FROM ...
+      **
+      ** If it is, then ask the code in where.c to attempt to sort results
+      ** as if there was an "ORDER ON x" or "ORDER ON x DESC" clause. 
+      ** If where.c is able to produce results sorted in this order, then
+      ** add vdbe code to break out of the processing loop after the 
+      ** first iteration (since the first iteration of the loop is 
+      ** guaranteed to operate on the row with the minimum or maximum 
+      ** value of x, the only row required).
+      **
+      ** A special flag must be passed to sqlite3WhereBegin() to slightly
+      ** modify behaviour as follows:
+      **
+      **   + If the query is a "SELECT min(x)", then the loop coded by
+      **     where.c should not iterate over any values with a NULL value
+      **     for x.
+      **
+      **   + The optimizer code in where.c (the thing that decides which
+      **     index or indices to use) should place a different priority on 
+      **     satisfying the 'ORDER BY' clause than it does in other cases.
+      **     Refer to code and comments in where.c for details.
+      */
       flag = minMaxQuery(pParse, p);
       if( flag ){
         pMinMax = sqlite3ExprListDup(db, p->pEList->a[0].pExpr->pList);