/ Check-in [1f42a338]
Login

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

Overview
Comment:Do not name variables "operator" because some compilers do not realize that "operator" is not a reserved word in ANSI-C. Ticket #1625. (CVS 2997)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 1f42a338e2ee90f4c24a9eb19054c4b831dd661f
User & Date: drh 2006-01-23 13:22:09
Context
2006-01-23
13:28
Fix to sqlite3AllocMalloc() when it is a no-op macro. (CVS 2998) check-in: 8caa9f95 user: drh tags: trunk
13:22
Do not name variables "operator" because some compilers do not realize that "operator" is not a reserved word in ANSI-C. Ticket #1625. (CVS 2997) check-in: 1f42a338 user: drh tags: trunk
13:14
Work around buggy malloc() implementations that cause problems on malloc(0). Ticket #1572. (CVS 2996) check-in: ada5490f user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/parse.y.

    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains SQLite's grammar for SQL.  Process this file
    13     13   ** using the lemon parser generator to generate C code that runs
    14     14   ** the parser.  Lemon will also generate a header file containing
    15     15   ** numeric codes for all of the tokens.
    16     16   **
    17         -** @(#) $Id: parse.y,v 1.192 2006/01/07 14:02:27 danielk1977 Exp $
           17  +** @(#) $Id: parse.y,v 1.193 2006/01/23 13:22:09 drh Exp $
    18     18   */
    19     19   
    20     20   // All token codes are small integers with #defines that begin with "TK_"
    21     21   %token_prefix TK_
    22     22   
    23     23   // The type of the data attached to each token is Token.  This is also the
    24     24   // default type for non-terminals.
................................................................................
    62     62   };
    63     63   
    64     64   /*
    65     65   ** An instance of this structure is used to store the LIKE,
    66     66   ** GLOB, NOT LIKE, and NOT GLOB operators.
    67     67   */
    68     68   struct LikeOp {
    69         -  Token operator;  /* "like" or "glob" or "regexp" */
           69  +  Token eOperator;  /* "like" or "glob" or "regexp" */
    70     70     int not;         /* True if the NOT keyword is present */
    71     71   };
    72     72   
    73     73   /*
    74     74   ** An instance of the following structure describes the event of a
    75     75   ** TRIGGER.  "a" is the event type, one of TK_UPDATE, TK_INSERT,
    76     76   ** TK_DELETE, or TK_INSTEAD.  If the event is of the form
................................................................................
   678    678   expr(A) ::= expr(X) EQ|NE(OP) expr(Y).          {A = sqlite3Expr(@OP, X, Y, 0);}
   679    679   expr(A) ::= expr(X) BITAND|BITOR|LSHIFT|RSHIFT(OP) expr(Y).
   680    680                                                   {A = sqlite3Expr(@OP, X, Y, 0);}
   681    681   expr(A) ::= expr(X) PLUS|MINUS(OP) expr(Y).     {A = sqlite3Expr(@OP, X, Y, 0);}
   682    682   expr(A) ::= expr(X) STAR|SLASH|REM(OP) expr(Y). {A = sqlite3Expr(@OP, X, Y, 0);}
   683    683   expr(A) ::= expr(X) CONCAT(OP) expr(Y).         {A = sqlite3Expr(@OP, X, Y, 0);}
   684    684   %type likeop {struct LikeOp}
   685         -likeop(A) ::= LIKE_KW(X).     {A.operator = X; A.not = 0;}
   686         -likeop(A) ::= NOT LIKE_KW(X). {A.operator = X; A.not = 1;}
          685  +likeop(A) ::= LIKE_KW(X).     {A.eOperator = X; A.not = 0;}
          686  +likeop(A) ::= NOT LIKE_KW(X). {A.eOperator = X; A.not = 1;}
   687    687   %type escape {Expr*}
   688    688   %destructor escape {sqlite3ExprDelete($$);}
   689    689   escape(X) ::= ESCAPE expr(A). [ESCAPE] {X = A;}
   690    690   escape(X) ::= .               [ESCAPE] {X = 0;}
   691    691   expr(A) ::= expr(X) likeop(OP) expr(Y) escape(E).  [LIKE_KW]  {
   692    692     ExprList *pList = sqlite3ExprListAppend(0, Y, 0);
   693    693     pList = sqlite3ExprListAppend(pList, X, 0);
   694    694     if( E ){
   695    695       pList = sqlite3ExprListAppend(pList, E, 0);
   696    696     }
   697         -  A = sqlite3ExprFunction(pList, &OP.operator);
          697  +  A = sqlite3ExprFunction(pList, &OP.eOperator);
   698    698     if( OP.not ) A = sqlite3Expr(TK_NOT, A, 0, 0);
   699    699     sqlite3ExprSpan(A, &X->span, &Y->span);
   700    700   }
   701    701   
   702    702   expr(A) ::= expr(X) ISNULL|NOTNULL(E). {
   703    703     A = sqlite3Expr(@E, X, 0, 0);
   704    704     sqlite3ExprSpan(A,&X->span,&E);

Changes to src/where.c.

    12     12   ** This module contains C code that generates VDBE code used to process
    13     13   ** the WHERE clause of SQL statements.  This module is reponsible for
    14     14   ** generating the code that loops through a table looking for applicable
    15     15   ** rows.  Indices are selected and used to speed the search when doing
    16     16   ** so is applicable.  Because this module is responsible for selecting
    17     17   ** indices, you might also think of this module as the "query optimizer".
    18     18   **
    19         -** $Id: where.c,v 1.201 2006/01/23 13:00:38 drh Exp $
           19  +** $Id: where.c,v 1.202 2006/01/23 13:22:10 drh Exp $
    20     20   */
    21     21   #include "sqliteInt.h"
    22     22   
    23     23   /*
    24     24   ** The number of bits in a Bitmask.  "BMS" means "BitMask Size".
    25     25   */
    26     26   #define BMS  (sizeof(Bitmask)*8)
................................................................................
    79     79   */
    80     80   typedef struct WhereTerm WhereTerm;
    81     81   struct WhereTerm {
    82     82     Expr *pExpr;            /* Pointer to the subexpression */
    83     83     i16 iParent;            /* Disable pWC->a[iParent] when this term disabled */
    84     84     i16 leftCursor;         /* Cursor number of X in "X <op> <expr>" */
    85     85     i16 leftColumn;         /* Column number of X in "X <op> <expr>" */
    86         -  u16 operator;           /* A WO_xx value describing <op> */
           86  +  u16 eOperator;          /* A WO_xx value describing <op> */
    87     87     u8 flags;               /* Bit flags.  See below */
    88     88     u8 nChild;              /* Number of children that must disable us */
    89     89     WhereClause *pWC;       /* The clause this term is part of */
    90     90     Bitmask prereqRight;    /* Bitmask of tables used by pRight */
    91     91     Bitmask prereqAll;      /* Bitmask of tables referenced by p */
    92     92   };
    93     93   
................................................................................
   414    414   ){
   415    415     WhereTerm *pTerm;
   416    416     int k;
   417    417     for(pTerm=pWC->a, k=pWC->nTerm; k; k--, pTerm++){
   418    418       if( pTerm->leftCursor==iCur
   419    419          && (pTerm->prereqRight & notReady)==0
   420    420          && pTerm->leftColumn==iColumn
   421         -       && (pTerm->operator & op)!=0
          421  +       && (pTerm->eOperator & op)!=0
   422    422       ){
   423    423         if( iCur>=0 && pIdx ){
   424    424           Expr *pX = pTerm->pExpr;
   425    425           CollSeq *pColl;
   426    426           char idxaff;
   427    427           int k;
   428    428           Parse *pParse = pWC->pParse;
................................................................................
   569    569     prereqAll = exprTableUsage(pMaskSet, pExpr);
   570    570     if( ExprHasProperty(pExpr, EP_FromJoin) ){
   571    571       prereqAll |= getMask(pMaskSet, pExpr->iRightJoinTable);
   572    572     }
   573    573     pTerm->prereqAll = prereqAll;
   574    574     pTerm->leftCursor = -1;
   575    575     pTerm->iParent = -1;
   576         -  pTerm->operator = 0;
          576  +  pTerm->eOperator = 0;
   577    577     if( allowedOp(pExpr->op) && (pTerm->prereqRight & prereqLeft)==0 ){
   578    578       Expr *pLeft = pExpr->pLeft;
   579    579       Expr *pRight = pExpr->pRight;
   580    580       if( pLeft->op==TK_COLUMN ){
   581    581         pTerm->leftCursor = pLeft->iTable;
   582    582         pTerm->leftColumn = pLeft->iColumn;
   583         -      pTerm->operator = operatorMask(pExpr->op);
          583  +      pTerm->eOperator = operatorMask(pExpr->op);
   584    584       }
   585    585       if( pRight && pRight->op==TK_COLUMN ){
   586    586         WhereTerm *pNew;
   587    587         Expr *pDup;
   588    588         if( pTerm->leftCursor>=0 ){
   589    589           int idxNew;
   590    590           pDup = sqlite3ExprDup(pExpr);
................................................................................
   601    601         }
   602    602         exprCommute(pDup);
   603    603         pLeft = pDup->pLeft;
   604    604         pNew->leftCursor = pLeft->iTable;
   605    605         pNew->leftColumn = pLeft->iColumn;
   606    606         pNew->prereqRight = prereqLeft;
   607    607         pNew->prereqAll = prereqAll;
   608         -      pNew->operator = operatorMask(pDup->op);
          608  +      pNew->eOperator = operatorMask(pDup->op);
   609    609       }
   610    610     }
   611    611   
   612    612   #ifndef SQLITE_OMIT_BETWEEN_OPTIMIZATION
   613    613     /* If a term is the BETWEEN operator, create two new virtual terms
   614    614     ** that define the range that the BETWEEN implements.
   615    615     */
................................................................................
   660    660       assert( sOr.nTerm>0 );
   661    661       j = 0;
   662    662       do{
   663    663         iColumn = sOr.a[j].leftColumn;
   664    664         iCursor = sOr.a[j].leftCursor;
   665    665         ok = iCursor>=0;
   666    666         for(i=sOr.nTerm-1, pOrTerm=sOr.a; i>=0 && ok; i--, pOrTerm++){
   667         -        if( pOrTerm->operator!=WO_EQ ){
          667  +        if( pOrTerm->eOperator!=WO_EQ ){
   668    668             goto or_not_possible;
   669    669           }
   670    670           if( pOrTerm->leftCursor==iCursor && pOrTerm->leftColumn==iColumn ){
   671    671             pOrTerm->flags |= TERM_OR_OK;
   672    672           }else if( (pOrTerm->flags & TERM_COPIED)!=0 ||
   673    673                       ((pOrTerm->flags & TERM_VIRTUAL)!=0 &&
   674    674                        (sOr.a[pOrTerm->iParent].flags & TERM_OR_OK)!=0) ){
................................................................................
   931    931     /* Check for a rowid=EXPR or rowid IN (...) constraints
   932    932     */
   933    933     pTerm = findTerm(pWC, iCur, -1, notReady, WO_EQ|WO_IN, 0);
   934    934     if( pTerm ){
   935    935       Expr *pExpr;
   936    936       *ppIndex = 0;
   937    937       bestFlags = WHERE_ROWID_EQ;
   938         -    if( pTerm->operator & WO_EQ ){
          938  +    if( pTerm->eOperator & WO_EQ ){
   939    939         /* Rowid== is always the best pick.  Look no further.  Because only
   940    940         ** a single row is generated, output is always in sorted order */
   941    941         *pFlags = WHERE_ROWID_EQ | WHERE_UNIQUE;
   942    942         *pnEq = 1;
   943    943         TRACE(("... best is rowid\n"));
   944    944         return 0.0;
   945    945       }else if( (pExpr = pTerm->pExpr)->pList!=0 ){
................................................................................
  1012   1012       */
  1013   1013       flags = 0;
  1014   1014       for(i=0; i<pProbe->nColumn; i++){
  1015   1015         int j = pProbe->aiColumn[i];
  1016   1016         pTerm = findTerm(pWC, iCur, j, notReady, WO_EQ|WO_IN, pProbe);
  1017   1017         if( pTerm==0 ) break;
  1018   1018         flags |= WHERE_COLUMN_EQ;
  1019         -      if( pTerm->operator & WO_IN ){
         1019  +      if( pTerm->eOperator & WO_IN ){
  1020   1020           Expr *pExpr = pTerm->pExpr;
  1021   1021           flags |= WHERE_COLUMN_IN;
  1022   1022           if( pExpr->pSelect!=0 ){
  1023   1023             inMultiplier *= 100;
  1024   1024           }else if( pExpr->pList!=0 ){
  1025   1025             inMultiplier *= pExpr->pList->nExpr + 1;
  1026   1026           }
................................................................................
  1779   1779           Expr *pX;
  1780   1780           int k = pIdx->aiColumn[j];
  1781   1781           pTerm = findTerm(&wc, iCur, k, notReady, topOp, pIdx);
  1782   1782           assert( pTerm!=0 );
  1783   1783           pX = pTerm->pExpr;
  1784   1784           assert( (pTerm->flags & TERM_CODED)==0 );
  1785   1785           sqlite3ExprCode(pParse, pX->pRight);
  1786         -        topEq = pTerm->operator & (WO_LE|WO_GE);
         1786  +        topEq = pTerm->eOperator & (WO_LE|WO_GE);
  1787   1787           disableTerm(pLevel, pTerm);
  1788   1788           testOp = OP_IdxGE;
  1789   1789         }else{
  1790   1790           testOp = nEq>0 ? OP_IdxGE : OP_Noop;
  1791   1791           topEq = 1;
  1792   1792         }
  1793   1793         if( testOp!=OP_Noop ){
................................................................................
  1817   1817           Expr *pX;
  1818   1818           int k = pIdx->aiColumn[j];
  1819   1819           pTerm = findTerm(&wc, iCur, k, notReady, btmOp, pIdx);
  1820   1820           assert( pTerm!=0 );
  1821   1821           pX = pTerm->pExpr;
  1822   1822           assert( (pTerm->flags & TERM_CODED)==0 );
  1823   1823           sqlite3ExprCode(pParse, pX->pRight);
  1824         -        btmEq = pTerm->operator & (WO_LE|WO_GE);
         1824  +        btmEq = pTerm->eOperator & (WO_LE|WO_GE);
  1825   1825           disableTerm(pLevel, pTerm);
  1826   1826         }else{
  1827   1827           btmEq = 1;
  1828   1828         }
  1829   1829         if( nEq>0 || btmLimit ){
  1830   1830           int nCol = nEq + btmLimit;
  1831   1831           buildIndexProbe(v, nCol, 0, brk, pIdx);