/ Check-in [1ad70ec5]
Login

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

Overview
Comment:Minor changes to the CAST logic to make it more testable.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:1ad70ec550c004160d9c0c57e6c416812cdead5e
User & Date: drh 2014-08-25 21:11:01
Context
2014-08-25
22:37
Add an assert() and five testcase() macros to the OP_Cast opcode implementation to help verify that it is fully tested. check-in: af364cce user: drh tags: trunk
21:11
Minor changes to the CAST logic to make it more testable. check-in: 1ad70ec5 user: drh tags: trunk
20:21
Test cases added for using unary "+" and CAST operators on the RHS of range constraints and verifying that STAT3/4 can use those constraints. check-in: 42505e5a user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vdbemem.c.

   405    405     if( flags & MEM_Int ){
   406    406       return pMem->u.i;
   407    407     }else if( flags & MEM_Real ){
   408    408       return doubleToInt64(pMem->r);
   409    409     }else if( flags & (MEM_Str|MEM_Blob) ){
   410    410       i64 value = 0;
   411    411       assert( pMem->z || pMem->n==0 );
   412         -    testcase( pMem->z==0 );
   413    412       sqlite3Atoi64(pMem->z, &value, pMem->n, pMem->enc);
   414    413       return value;
   415    414     }else{
   416    415       return 0;
   417    416     }
   418    417   }
   419    418   
................................................................................
  1062   1061     }
  1063   1062     while( (op = pExpr->op)==TK_UPLUS ) pExpr = pExpr->pLeft;
  1064   1063     if( NEVER(op==TK_REGISTER) ) op = pExpr->op2;
  1065   1064   
  1066   1065     if( op==TK_CAST ){
  1067   1066       u8 aff = sqlite3AffinityType(pExpr->u.zToken,0);
  1068   1067       rc = valueFromExpr(db, pExpr->pLeft, enc, aff, ppVal, pCtx);
  1069         -    if( rc==SQLITE_OK && *ppVal ){
         1068  +    testcase( rc!=SQLITE_OK );
         1069  +    if( *ppVal ){
  1070   1070         sqlite3VdbeMemCast(*ppVal, aff, SQLITE_UTF8);
  1071   1071         sqlite3ValueApplyAffinity(*ppVal, affinity, SQLITE_UTF8);
  1072   1072       }
  1073   1073       return rc;
  1074   1074     }
  1075   1075   
  1076   1076     /* Handle negative integers in a single step.  This is needed in the