/ Check-in [9001e222]
Login

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

Overview
Comment:Fix for tickets #912 and #922. Problem introduced by check-in (1973). (CVS 1975)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:9001e2220d2e35b81a9b7dc70c012f94bb6db679
User & Date: drh 2004-09-24 12:24:07
Context
2004-09-24
12:24
Simplification of the trigger code. (CVS 1976) check-in: 9fa904d9 user: drh tags: trunk
12:24
Fix for tickets #912 and #922. Problem introduced by check-in (1973). (CVS 1975) check-in: 9001e222 user: drh tags: trunk
2004-09-20
14:57
Pthread is now conditionally included in makefile, see ticket #910 (CVS 1974) check-in: a35e5227 user: dougcurrie 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.163 2004/09/19 02:15:25 drh Exp $
           15  +** $Id: expr.c,v 1.164 2004/09/24 12:24:07 drh Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   #include <ctype.h>
    19     19   
    20     20   char const *sqlite3AffinityString(char affinity){
    21     21     switch( affinity ){
    22     22       case SQLITE_AFF_INTEGER: return "i";
................................................................................
   200    200       return 0;
   201    201     }
   202    202     pNew->op = op;
   203    203     pNew->pLeft = pLeft;
   204    204     pNew->pRight = pRight;
   205    205     if( pToken ){
   206    206       assert( pToken->dyn==0 );
   207         -    pNew->token = *pToken;
   208         -    pNew->span = *pToken;
   209         -  }else{
   210         -    assert( pNew->token.dyn==0 );
   211         -    assert( pNew->token.z==0 );
   212         -    assert( pNew->token.n==0 );
   213         -    if( pLeft && pRight ){
   214         -      sqlite3ExprSpan(pNew, &pLeft->span, &pRight->span);
   215         -    }else{
   216         -      pNew->span = pNew->token;
   217         -    }
          207  +    pNew->span = pNew->token = *pToken;
          208  +  }else if( pLeft && pRight ){
          209  +    sqlite3ExprSpan(pNew, &pLeft->span, &pRight->span);
   218    210     }
   219    211     return pNew;
   220    212   }
   221    213   
   222    214   /*
   223    215   ** Join two expressions using an AND operator.  If either expression is
   224    216   ** NULL, then just return the other expression.
................................................................................
   238    230   ** text between the two given tokens.
   239    231   */
   240    232   void sqlite3ExprSpan(Expr *pExpr, Token *pLeft, Token *pRight){
   241    233     assert( pRight!=0 );
   242    234     assert( pLeft!=0 );
   243    235     if( !sqlite3_malloc_failed && pRight->z && pLeft->z ){
   244    236       assert( pLeft->dyn==0 || pLeft->z[pLeft->n]==0 );
   245         -    if( pLeft->z[pLeft->n]!=0 && pRight->dyn==0 ){
          237  +    if( pLeft->dyn==0 && pRight->dyn==0 ){
   246    238         pExpr->span.z = pLeft->z;
   247    239         pExpr->span.n = pRight->n + Addr(pRight->z) - Addr(pLeft->z);
   248    240       }else{
   249    241         pExpr->span.z = 0;
   250    242       }
   251    243     }
   252    244   }
................................................................................
   397    389       pTo->dyn = 1;
   398    390     }else{
   399    391       pTo->z = 0;
   400    392     }
   401    393   }
   402    394   ExprList *sqlite3ExprListDup(ExprList *p){
   403    395     ExprList *pNew;
   404         -  struct ExprList_item *pItem;
          396  +  struct ExprList_item *pItem, *pOldItem;
   405    397     int i;
   406    398     if( p==0 ) return 0;
   407    399     pNew = sqliteMalloc( sizeof(*pNew) );
   408    400     if( pNew==0 ) return 0;
   409    401     pNew->nExpr = pNew->nAlloc = p->nExpr;
   410    402     pNew->a = pItem = sqliteMalloc( p->nExpr*sizeof(p->a[0]) );
   411    403     if( pItem==0 ){
   412    404       sqliteFree(pNew);
   413    405       return 0;
   414    406     } 
   415         -  for(i=0; i<p->nExpr; i++, pItem++){
          407  +  pOldItem = p->a;
          408  +  for(i=0; i<p->nExpr; i++, pItem++, pOldItem++){
   416    409       Expr *pNewExpr, *pOldExpr;
   417         -    pItem->pExpr = pNewExpr = sqlite3ExprDup(pOldExpr = p->a[i].pExpr);
          410  +    pItem->pExpr = pNewExpr = sqlite3ExprDup(pOldExpr = pOldItem->pExpr);
   418    411       if( pOldExpr->span.z!=0 && pNewExpr ){
   419    412         /* Always make a copy of the span for top-level expressions in the
   420    413         ** expression list.  The logic in SELECT processing that determines
   421    414         ** the names of columns in the result set needs this information */
   422    415         sqlite3TokenCopy(&pNewExpr->span, &pOldExpr->span);
   423    416       }
   424    417       assert( pNewExpr==0 || pNewExpr->span.z!=0 
   425    418               || pOldExpr->span.z==0 || sqlite3_malloc_failed );
   426         -    pItem->zName = sqliteStrDup(p->a[i].zName);
   427         -    pItem->sortOrder = p->a[i].sortOrder;
   428         -    pItem->isAgg = p->a[i].isAgg;
          419  +    pItem->zName = sqliteStrDup(pOldItem->zName);
          420  +    pItem->sortOrder = pOldItem->sortOrder;
          421  +    pItem->isAgg = pOldItem->isAgg;
   429    422       pItem->done = 0;
   430    423     }
   431    424     return pNew;
   432    425   }
   433    426   SrcList *sqlite3SrcListDup(SrcList *p){
   434    427     SrcList *pNew;
   435    428     int i;
................................................................................
  1238   1231     }
  1239   1232     switch( pExpr->op ){
  1240   1233       case TK_COLUMN: {
  1241   1234         if( pParse->useAgg ){
  1242   1235           sqlite3VdbeAddOp(v, OP_AggGet, 0, pExpr->iAgg);
  1243   1236         }else if( pExpr->iColumn>=0 ){
  1244   1237           sqlite3VdbeAddOp(v, OP_Column, pExpr->iTable, pExpr->iColumn);
  1245         -        VdbeComment((v, "# %T", &pExpr->span));
         1238  +#ifndef NDEBUG
         1239  +        if( pExpr->span.z && pExpr->span.n>0 && pExpr->span.n<100 ){
         1240  +          VdbeComment((v, "# %T", &pExpr->span));
         1241  +        }
         1242  +#endif
  1246   1243         }else{
  1247   1244           sqlite3VdbeAddOp(v, OP_Recno, pExpr->iTable, 0);
  1248   1245         }
  1249   1246         break;
  1250   1247       }
  1251   1248       case TK_INTEGER: {
  1252   1249         codeInteger(v, pExpr->token.z, pExpr->token.n);