/ Check-in [7e85a162]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:More bug fixes. But there are still tests that fail. (CVS 2664)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 7e85a162d0ecf0acdbffcacc62b60d97fe123881
User & Date: drh 2005-09-07 22:48:16
Context
2005-09-07
23:05
More bug fixes. All of the "quick" tests pass. The full test suite still shows problems. (CVS 2665) check-in: a1b6d910 user: drh tags: trunk
22:48
More bug fixes. But there are still tests that fail. (CVS 2664) check-in: 7e85a162 user: drh tags: trunk
22:09
Bug fixes in aggregate processing. Fewer tests fail. (CVS 2663) check-in: c3ac5859 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/expr.c.

     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains routines used for analyzing expressions and
    13     13   ** for generating VDBE code that evaluates expressions in SQLite.
    14     14   **
    15         -** $Id: expr.c,v 1.225 2005/09/07 21:22:46 drh Exp $
           15  +** $Id: expr.c,v 1.226 2005/09/07 22:48:16 drh Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   #include <ctype.h>
    19     19   
    20     20   /*
    21     21   ** Return the 'affinity' of the expression pExpr if any.
    22     22   **
................................................................................
  2127   2127               }
  2128   2128               if( i>=pAggInfo->nColumn && (i = addAggInfoColumn(pAggInfo))>=0 ){
  2129   2129                 pCol = &pAggInfo->aCol[i];
  2130   2130                 pCol->iTable = pExpr->iTable;
  2131   2131                 pCol->iColumn = pExpr->iColumn;
  2132   2132                 pCol->iMem = pParse->nMem++;
  2133   2133                 pCol->iSorterColumn = -1;
         2134  +              pCol->pExpr = pExpr;
  2134   2135                 if( pAggInfo->pGroupBy ){
  2135   2136                   int j, n;
  2136   2137                   ExprList *pGB = pAggInfo->pGroupBy;
  2137   2138                   struct ExprList_item *pTerm = pGB->a;
  2138   2139                   n = pGB->nExpr;
  2139   2140                   for(j=0; j<n; j++, pTerm++){
  2140   2141                     Expr *pE = pTerm->pExpr;

Changes to src/select.c.

     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains C code routines that are called by the parser
    13     13   ** to handle SELECT statements in SQLite.
    14     14   **
    15         -** $Id: select.c,v 1.262 2005/09/07 22:09:48 drh Exp $
           15  +** $Id: select.c,v 1.263 2005/09/07 22:48:16 drh Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   
    19     19   
    20     20   /*
    21     21   ** Allocate a new Select structure and return a pointer to that
    22     22   ** structure.
................................................................................
  2442   2442   ** the current cursor position.
  2443   2443   */
  2444   2444   static void updateAccumulator(Parse *pParse, AggInfo *pAggInfo){
  2445   2445     Vdbe *v = pParse->pVdbe;
  2446   2446     int i;
  2447   2447     struct AggInfo_func *pF;
  2448   2448     struct AggInfo_col *pC;
  2449         -  Expr fauxExpr;
  2450   2449   
  2451   2450     pAggInfo->directMode = 1;
  2452   2451     for(i=0, pF=pAggInfo->aFunc; i<pAggInfo->nFunc; i++, pF++){
  2453   2452       int nArg;
  2454   2453       ExprList *pList = pF->pExpr->pList;
  2455   2454       if( pList ){
  2456   2455         nArg = pList->nExpr;
................................................................................
  2468   2467         if( !pColl ){
  2469   2468           pColl = pParse->db->pDfltColl;
  2470   2469         }
  2471   2470         sqlite3VdbeOp3(v, OP_CollSeq, 0, 0, (char *)pColl, P3_COLLSEQ);
  2472   2471       }
  2473   2472       sqlite3VdbeOp3(v, OP_AggStep, pF->iMem, nArg, (void*)pF->pFunc, P3_FUNCDEF);
  2474   2473     }
  2475         -  memset(&fauxExpr, 0, sizeof(fauxExpr));
  2476         -  fauxExpr.op = TK_AGG_COLUMN;
  2477         -  fauxExpr.pAggInfo = pAggInfo;
  2478   2474     for(i=0, pC=pAggInfo->aCol; i<pAggInfo->nAccumulator; i++, pC++){
  2479         -    fauxExpr.iAgg = i;
  2480         -    sqlite3ExprCode(pParse, &fauxExpr);
         2475  +    sqlite3ExprCode(pParse, pC->pExpr);
  2481   2476       sqlite3VdbeAddOp(v, OP_MemStore, pC->iMem, 1);
  2482   2477     }
  2483   2478     pAggInfo->directMode = 0;
  2484   2479   }
  2485   2480   
  2486   2481   
  2487   2482   /*
................................................................................
  2986   2981         */
  2987   2982         resetAccumulator(pParse, &sAggInfo);
  2988   2983         pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, 0);
  2989   2984         updateAccumulator(pParse, &sAggInfo);
  2990   2985         sqlite3WhereEnd(pWInfo);
  2991   2986         finalizeAggFunctions(pParse, &sAggInfo);
  2992   2987         pOrderBy = 0;
         2988  +      if( pHaving ){
         2989  +        sqlite3ExprIfFalse(pParse, pHaving, addrEnd, 1);
         2990  +      }
  2993   2991         selectInnerLoop(pParse, p, p->pEList, 0, 0, 0, -1, 
  2994   2992                         eDest, iParm, addrEnd, addrEnd, aff);
  2995   2993       }
  2996   2994       sqlite3VdbeResolveLabel(v, addrEnd);
  2997   2995       
  2998   2996     } /* endif aggregate query */
  2999   2997   

Changes to src/sqliteInt.h.

     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** Internal interface definitions for SQLite.
    13     13   **
    14         -** @(#) $Id: sqliteInt.h,v 1.408 2005/09/07 21:22:47 drh Exp $
           14  +** @(#) $Id: sqliteInt.h,v 1.409 2005/09/07 22:48:16 drh Exp $
    15     15   */
    16     16   #ifndef _SQLITEINT_H_
    17     17   #define _SQLITEINT_H_
    18     18   
    19     19   /*
    20     20   ** These #defines should enable >2GB file support on Posix if the
    21     21   ** underlying operating system supports it.  If the OS lacks
................................................................................
   810    810     ExprList *pGroupBy;     /* The group by clause */
   811    811     int nSortingColumn;     /* Number of columns in the sorting index */
   812    812     struct AggInfo_col {    /* For each column used in source tables */
   813    813       int iTable;              /* Cursor number of the source table */
   814    814       int iColumn;             /* Column number within the source table */
   815    815       int iSorterColumn;       /* Column number in the sorting index */
   816    816       int iMem;                /* Memory location that acts as accumulator */
          817  +    Expr *pExpr;             /* The original expression */
   817    818     } *aCol;
   818    819     int nColumn;            /* Number of used entries in aCol[] */
   819    820     int nColumnAlloc;       /* Number of slots allocated for aCol[] */
   820    821     int nAccumulator;       /* Number of columns that show through to the output.
   821    822                             ** Additional columns are used only as parameters to
   822    823                             ** aggregate functions */
   823    824     struct AggInfo_func {   /* For each aggregate function */

Changes to test/collate5.test.

    10     10   #
    11     11   #*************************************************************************
    12     12   # This file implements regression tests for SQLite library.  The
    13     13   # focus of this file is testing DISTINCT, UNION, INTERSECT and EXCEPT
    14     14   # SELECT statements that use user-defined collation sequences. Also
    15     15   # GROUP BY clauses that use user-defined collation sequences.
    16     16   #
    17         -# $Id: collate5.test,v 1.4 2005/04/01 10:47:40 drh Exp $
           17  +# $Id: collate5.test,v 1.5 2005/09/07 22:48:16 drh Exp $
    18     18   
    19     19   set testdir [file dirname $argv0]
    20     20   source $testdir/tester.tcl
    21     21   
    22     22   
    23     23   #
    24     24   # Tests are organised as follows:
................................................................................
   248    248       INSERT INTO collate5t1 VALUES('a', '1');
   249    249       INSERT INTO collate5t1 VALUES('A', '1.0');
   250    250       INSERT INTO collate5t1 VALUES('b', '2');
   251    251       INSERT INTO collate5t1 VALUES('B', '3');
   252    252     }
   253    253   } {}
   254    254   do_test collate5-4.1 {
   255         -  execsql {
          255  +  string tolower [execsql {
   256    256       SELECT a, count(*) FROM collate5t1 GROUP BY a;
   257         -  }
          257  +  }]
   258    258   } {a 2 b 2}
   259    259   do_test collate5-4.2 {
   260    260     execsql {
   261         -    SELECT a, b, count(*) FROM collate5t1 GROUP BY a, b;
          261  +    SELECT a, b, count(*) FROM collate5t1 GROUP BY a, b ORDER BY a, b;
   262    262     }
   263         -} {a 1 2 b 2 1 B 3 1}
          263  +} {A 1.0 2 b 2 1 B 3 1}
   264    264   do_test collate5-4.3 {
   265    265     execsql {
   266    266       DROP TABLE collate5t1;
   267    267     }
   268    268   } {}
   269    269   
   270    270   finish_test

Changes to test/misc4.test.

     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.
    12     12   #
    13     13   # This file implements tests for miscellanous features that were
    14     14   # left out of other test files.
    15     15   #
    16         -# $Id: misc4.test,v 1.17 2005/09/07 21:22:47 drh Exp $
           16  +# $Id: misc4.test,v 1.18 2005/09/07 22:48:16 drh Exp $
    17     17   
    18     18   set testdir [file dirname $argv0]
    19     19   source $testdir/tester.tcl
    20     20   
    21     21   # Prepare a statement that will create a temporary table.  Then do
    22     22   # a rollback.  Then try to execute the prepared statement.
    23     23   #
................................................................................
    95     95       CREATE TABLE Table2(ID integer NOT NULL, Value TEXT);
    96     96       INSERT INTO Table2 VALUES(1, 'z');
    97     97       INSERT INTO Table2 VALUES (1, 'a');
    98     98       SELECT ID, Value FROM Table1
    99     99          UNION SELECT ID, max(Value) FROM Table2 GROUP BY 1
   100    100       ORDER BY 1, 2;
   101    101     }
   102         -} {{} {} 1 x 1 z}
          102  +} {1 x 1 z}
   103    103   } ;# ifcapable compound
   104    104   
   105    105   # Ticket #1047.  Make sure column types are preserved in subqueries.
   106    106   #
   107    107   ifcapable subquery {
   108    108     do_test misc4-4.1 {
   109    109       execsql {

Changes to test/select5.test.

     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this file is testing aggregate functions and the
    13     13   # GROUP BY and HAVING clauses of SELECT statements.
    14     14   #
    15         -# $Id: select5.test,v 1.10 2005/08/19 03:03:52 drh Exp $
           15  +# $Id: select5.test,v 1.11 2005/09/07 22:48:16 drh Exp $
    16     16   
    17     17   set testdir [file dirname $argv0]
    18     18   source $testdir/tester.tcl
    19     19   
    20     20   # Build some test data
    21     21   #
    22     22   execsql {
................................................................................
   150    150       SELECT a, b FROM t2 GROUP BY a, b;
   151    151     } 
   152    152   } {1 2 1 4 6 4}
   153    153   do_test select5-5.5 {
   154    154     execsql {
   155    155       SELECT a, b FROM t2 GROUP BY a;
   156    156     } 
   157         -} {1 2 6 4}
          157  +} {1 4 6 4}
   158    158   
   159    159   finish_test

Changes to test/select6.test.

     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this file is testing SELECT statements that contain
    13     13   # subqueries in their FROM clause.
    14     14   #
    15         -# $Id: select6.test,v 1.18 2005/07/08 17:13:47 drh Exp $
           15  +# $Id: select6.test,v 1.19 2005/09/07 22:48:16 drh Exp $
    16     16   
    17     17   set testdir [file dirname $argv0]
    18     18   source $testdir/tester.tcl
    19     19   
    20     20   # Omit this whole file if the library is build without subquery support.
    21     21   ifcapable !subquery {
    22     22     finish_test
................................................................................
   190    190   do_test select6-3.6 {
   191    191     execsql {
   192    192       SELECT a,b,a+b FROM (SELECT avg(x) as 'a', avg(y) as 'b' FROM t1)
   193    193       WHERE a>10
   194    194     }
   195    195   } {10.5 3.7 14.2}
   196    196   do_test select6-3.7 {
          197  +btree_breakpoint
   197    198     execsql {
   198    199       SELECT a,b,a+b FROM (SELECT avg(x) as 'a', avg(y) as 'b' FROM t1)
   199    200       WHERE a<10
   200    201     }
   201    202   } {}
   202    203   do_test select6-3.8 {
   203    204     execsql {