/ Check-in [1a3554e1]
Login

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

Overview
Comment:Small size reduction and performance increase in the name resolver routine for expressions.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 1a3554e1d71b666325ff377fae5329d79ce5c05f
User & Date: drh 2017-03-07 03:25:52
Context
2017-03-07
03:40
More size and speed improvements in the expression name resolver. check-in: e0a3d39f user: drh tags: trunk
03:25
Small size reduction and performance increase in the name resolver routine for expressions. check-in: 1a3554e1 user: drh tags: trunk
2017-03-06
23:51
Make the default MASK argument for "PRAGMA optimize" be 0xfffe, to allow for future expansion of up to 14 new default-on optimizations. check-in: 73019a8b user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/parse.y.

   895    895   }
   896    896   term(A) ::= FLOAT|BLOB(X). {spanExpr(&A,pParse,@X,X);/*A-overwrites-X*/}
   897    897   term(A) ::= STRING(X).     {spanExpr(&A,pParse,@X,X);/*A-overwrites-X*/}
   898    898   term(A) ::= INTEGER(X). {
   899    899     A.pExpr = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &X, 1);
   900    900     A.zStart = X.z;
   901    901     A.zEnd = X.z + X.n;
   902         -  if( A.pExpr ) A.pExpr->flags |= EP_Leaf;
          902  +  if( A.pExpr ) A.pExpr->flags |= EP_Leaf|EP_Resolved;
   903    903   }
   904    904   expr(A) ::= VARIABLE(X).     {
   905    905     if( !(X.z[0]=='#' && sqlite3Isdigit(X.z[1])) ){
   906    906       u32 n = X.n;
   907    907       spanExpr(&A, pParse, TK_VARIABLE, X);
   908    908       sqlite3ExprAssignVarNumber(pParse, A.pExpr, n);
   909    909     }else{

Changes to src/resolve.c.

   604    604         pExpr->iColumn = -1;
   605    605         pExpr->affinity = SQLITE_AFF_INTEGER;
   606    606         break;
   607    607       }
   608    608   #endif /* defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT)
   609    609             && !defined(SQLITE_OMIT_SUBQUERY) */
   610    610   
   611         -    /* A lone identifier is the name of a column.
   612         -    */
   613         -    case TK_ID: {
   614         -      return lookupName(pParse, 0, 0, pExpr->u.zToken, pNC, pExpr);
   615         -    }
   616         -  
   617         -    /* A table name and column name:     ID.ID
          611  +    /* A column name:                    ID
          612  +    ** Or table name and column name:    ID.ID
   618    613       ** Or a database, table and column:  ID.ID.ID
          614  +    **
          615  +    ** The TK_ID and TK_OUT cases are combined so that there will only
          616  +    ** be one call to lookupName().  Then the compiler will in-line 
          617  +    ** lookupName() for a size reduction and performance increase.
   619    618       */
          619  +    case TK_ID:
   620    620       case TK_DOT: {
   621    621         const char *zColumn;
   622    622         const char *zTable;
   623    623         const char *zDb;
   624    624         Expr *pRight;
   625    625   
   626         -      /* if( pSrcList==0 ) break; */
   627         -      notValid(pParse, pNC, "the \".\" operator", NC_IdxExpr);
   628         -      pRight = pExpr->pRight;
   629         -      if( pRight->op==TK_ID ){
          626  +      if( pExpr->op==TK_ID ){
   630    627           zDb = 0;
   631         -        zTable = pExpr->pLeft->u.zToken;
   632         -        zColumn = pRight->u.zToken;
          628  +        zTable = 0;
          629  +        zColumn = pExpr->u.zToken;
   633    630         }else{
   634         -        assert( pRight->op==TK_DOT );
   635         -        zDb = pExpr->pLeft->u.zToken;
   636         -        zTable = pRight->pLeft->u.zToken;
   637         -        zColumn = pRight->pRight->u.zToken;
          631  +        notValid(pParse, pNC, "the \".\" operator", NC_IdxExpr);
          632  +        pRight = pExpr->pRight;
          633  +        if( pRight->op==TK_ID ){
          634  +          zDb = 0;
          635  +          zTable = pExpr->pLeft->u.zToken;
          636  +          zColumn = pRight->u.zToken;
          637  +        }else{
          638  +          assert( pRight->op==TK_DOT );
          639  +          zDb = pExpr->pLeft->u.zToken;
          640  +          zTable = pRight->pLeft->u.zToken;
          641  +          zColumn = pRight->pRight->u.zToken;
          642  +        }
   638    643         }
   639    644         return lookupName(pParse, zDb, zTable, zColumn, pNC, pExpr);
   640    645       }
   641    646   
   642    647       /* Resolve function names
   643    648       */
   644    649       case TK_FUNCTION: {