/ Check-in [e20e76f6]
Login

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

Overview
Comment:Clarify the use of loop variables in a expr.c. (CVS 3683)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:e20e76f6d8578f4faab0b101b6d4deb2a8987454
User & Date: drh 2007-03-12 23:48:53
Context
2007-03-13
16:32
Do not crash when a corrupt database contains two indices with the same name. (CVS 3684) check-in: 48b2a400 user: danielk1977 tags: trunk
2007-03-12
23:48
Clarify the use of loop variables in a expr.c. (CVS 3683) check-in: e20e76f6 user: drh tags: trunk
2007-03-10
20:50
Fix another typo in copyright.html (CVS 3682) check-in: 92f15864 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.280 2007/02/24 15:29:04 drh Exp $
           15  +** $Id: expr.c,v 1.281 2007/03/12 23:48:53 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   **
................................................................................
  2284   2284             if( pExpr->iTable==pItem->iCursor ){
  2285   2285               /* If we reach this point, it means that pExpr refers to a table
  2286   2286               ** that is in the FROM clause of the aggregate query.  
  2287   2287               **
  2288   2288               ** Make an entry for the column in pAggInfo->aCol[] if there
  2289   2289               ** is not an entry there already.
  2290   2290               */
         2291  +            int k;
  2291   2292               pCol = pAggInfo->aCol;
  2292         -            for(i=0; i<pAggInfo->nColumn; i++, pCol++){
         2293  +            for(k=0; k<pAggInfo->nColumn; k++, pCol++){
  2293   2294                 if( pCol->iTable==pExpr->iTable &&
  2294   2295                     pCol->iColumn==pExpr->iColumn ){
  2295   2296                   break;
  2296   2297                 }
  2297   2298               }
  2298         -            if( i>=pAggInfo->nColumn && (i = addAggInfoColumn(pAggInfo))>=0 ){
  2299         -              pCol = &pAggInfo->aCol[i];
         2299  +            if( k>=pAggInfo->nColumn && (k = addAggInfoColumn(pAggInfo))>=0 ){
         2300  +              pCol = &pAggInfo->aCol[k];
  2300   2301                 pCol->pTab = pExpr->pTab;
  2301   2302                 pCol->iTable = pExpr->iTable;
  2302   2303                 pCol->iColumn = pExpr->iColumn;
  2303   2304                 pCol->iMem = pParse->nMem++;
  2304   2305                 pCol->iSorterColumn = -1;
  2305   2306                 pCol->pExpr = pExpr;
  2306   2307                 if( pAggInfo->pGroupBy ){
................................................................................
  2324   2325               /* There is now an entry for pExpr in pAggInfo->aCol[] (either
  2325   2326               ** because it was there before or because we just created it).
  2326   2327               ** Convert the pExpr to be a TK_AGG_COLUMN referring to that
  2327   2328               ** pAggInfo->aCol[] entry.
  2328   2329               */
  2329   2330               pExpr->pAggInfo = pAggInfo;
  2330   2331               pExpr->op = TK_AGG_COLUMN;
  2331         -            pExpr->iAgg = i;
         2332  +            pExpr->iAgg = k;
  2332   2333               break;
  2333   2334             } /* endif pExpr->iTable==pItem->iCursor */
  2334   2335           } /* end loop over pSrcList */
  2335   2336         }
  2336   2337         return 1;
  2337   2338       }
  2338   2339       case TK_AGG_FUNCTION: {