/ Check-in [66bab856]
Login

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

Overview
Comment:Use #ifdefs to disable unused code when SQLITE_OMIT_FLOATING_POINT is defined.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 66bab8561926963a87f15ad559cba36545c9892c
User & Date: drh 2010-01-12 17:04:08
Context
2010-01-12
17:57
Update comments in fts3_snippet.c. check-in: dd9689b7 user: dan tags: trunk
17:04
Use #ifdefs to disable unused code when SQLITE_OMIT_FLOATING_POINT is defined. check-in: 66bab856 user: drh tags: trunk
2010-01-11
18:26
Add a few documentation evidence comments to the built-in function implementations. check-in: 8bd0f814 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/expr.c.

  1878   1878     char *out = sqlite3DbMallocRaw(sqlite3VdbeDb(v), 8);
  1879   1879     if( out ){
  1880   1880       memcpy(out, in, 8);
  1881   1881     }
  1882   1882     return out;
  1883   1883   }
  1884   1884   
         1885  +#ifndef SQLITE_OMIT_FLOATING_POINT
  1885   1886   /*
  1886   1887   ** Generate an instruction that will put the floating point
  1887   1888   ** value described by z[0..n-1] into register iMem.
  1888   1889   **
  1889   1890   ** The z[] string will probably not be zero-terminated.  But the 
  1890   1891   ** z[n] character is guaranteed to be something that does not look
  1891   1892   ** like the continuation of the number.
................................................................................
  1897   1898       sqlite3AtoF(z, &value);
  1898   1899       assert( !sqlite3IsNaN(value) ); /* The new AtoF never returns NaN */
  1899   1900       if( negateFlag ) value = -value;
  1900   1901       zV = dup8bytes(v, (char*)&value);
  1901   1902       sqlite3VdbeAddOp4(v, OP_Real, 0, iMem, 0, zV, P4_REAL);
  1902   1903     }
  1903   1904   }
         1905  +#endif
  1904   1906   
  1905   1907   
  1906   1908   /*
  1907   1909   ** Generate an instruction that will put the integer describe by
  1908   1910   ** text z[0..n-1] into register iMem.
  1909   1911   **
  1910   1912   ** The z[] string will probably not be zero-terminated.  But the 
  1911   1913   ** z[n] character is guaranteed to be something that does not look
  1912   1914   ** like the continuation of the number.
  1913   1915   */
  1914         -static void codeInteger(Vdbe *v, Expr *pExpr, int negFlag, int iMem){
         1916  +static void codeInteger(Parse *pParse, Expr *pExpr, int negFlag, int iMem){
         1917  +  Vdbe *v = pParse->pVdbe;
  1915   1918     if( pExpr->flags & EP_IntValue ){
  1916   1919       int i = pExpr->u.iValue;
  1917   1920       if( negFlag ) i = -i;
  1918   1921       sqlite3VdbeAddOp2(v, OP_Integer, i, iMem);
  1919   1922     }else{
  1920   1923       const char *z = pExpr->u.zToken;
  1921   1924       assert( z!=0 );
................................................................................
  1923   1926         i64 value;
  1924   1927         char *zV;
  1925   1928         sqlite3Atoi64(z, &value);
  1926   1929         if( negFlag ) value = -value;
  1927   1930         zV = dup8bytes(v, (char*)&value);
  1928   1931         sqlite3VdbeAddOp4(v, OP_Int64, 0, iMem, 0, zV, P4_INT64);
  1929   1932       }else{
         1933  +#ifdef SQLITE_OMIT_FLOATING_POINT
         1934  +      sqlite3ErrorMsg(pParse, "oversized integer: %s%s", negFlag ? "-" : "", z);
         1935  +#else
  1930   1936         codeReal(v, z, negFlag, iMem);
         1937  +#endif
  1931   1938       }
  1932   1939     }
  1933   1940   }
  1934   1941   
  1935   1942   /*
  1936   1943   ** Clear a cache entry.
  1937   1944   */
................................................................................
  2310   2317         }else{
  2311   2318           inReg = sqlite3ExprCodeGetColumn(pParse, pExpr->pTab,
  2312   2319                                    pExpr->iColumn, pExpr->iTable, target);
  2313   2320         }
  2314   2321         break;
  2315   2322       }
  2316   2323       case TK_INTEGER: {
  2317         -      codeInteger(v, pExpr, 0, target);
         2324  +      codeInteger(pParse, pExpr, 0, target);
  2318   2325         break;
  2319   2326       }
         2327  +#ifndef SQLITE_OMIT_FLOATING_POINT
  2320   2328       case TK_FLOAT: {
  2321   2329         assert( !ExprHasProperty(pExpr, EP_IntValue) );
  2322   2330         codeReal(v, pExpr->u.zToken, 0, target);
  2323   2331         break;
  2324   2332       }
         2333  +#endif
  2325   2334       case TK_STRING: {
  2326   2335         assert( !ExprHasProperty(pExpr, EP_IntValue) );
  2327   2336         sqlite3VdbeAddOp4(v, OP_String8, 0, target, 0, pExpr->u.zToken, 0);
  2328   2337         break;
  2329   2338       }
  2330   2339       case TK_NULL: {
  2331   2340         sqlite3VdbeAddOp2(v, OP_Null, 0, target);
................................................................................
  2487   2496         testcase( regFree1==0 );
  2488   2497         testcase( regFree2==0 );
  2489   2498         break;
  2490   2499       }
  2491   2500       case TK_UMINUS: {
  2492   2501         Expr *pLeft = pExpr->pLeft;
  2493   2502         assert( pLeft );
  2494         -      if( pLeft->op==TK_FLOAT ){
         2503  +      if( pLeft->op==TK_INTEGER ){
         2504  +        codeInteger(pParse, pLeft, 1, target);
         2505  +#ifndef SQLITE_OMIT_FLOATING_POINT
         2506  +      }else if( pLeft->op==TK_FLOAT ){
  2495   2507           assert( !ExprHasProperty(pExpr, EP_IntValue) );
  2496   2508           codeReal(v, pLeft->u.zToken, 1, target);
  2497         -      }else if( pLeft->op==TK_INTEGER ){
  2498         -        codeInteger(v, pLeft, 1, target);
         2509  +#endif
  2499   2510         }else{
  2500   2511           regFree1 = r1 = sqlite3GetTempReg(pParse);
  2501   2512           sqlite3VdbeAddOp2(v, OP_Integer, 0, r1);
  2502   2513           r2 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree2);
  2503   2514           sqlite3VdbeAddOp3(v, OP_Subtract, r2, r1, target);
  2504   2515           testcase( regFree2==0 );
  2505   2516         }

Changes to src/vdbe.c.

   880    880   */
   881    881   case OP_Int64: {           /* out2-prerelease */
   882    882     assert( pOp->p4.pI64!=0 );
   883    883     pOut->u.i = *pOp->p4.pI64;
   884    884     break;
   885    885   }
   886    886   
          887  +#ifndef SQLITE_OMIT_FLOATING_POINT
   887    888   /* Opcode: Real * P2 * P4 *
   888    889   **
   889    890   ** P4 is a pointer to a 64-bit floating point value.
   890    891   ** Write that value into register P2.
   891    892   */
   892    893   case OP_Real: {            /* same as TK_FLOAT, out2-prerelease */
   893    894     pOut->flags = MEM_Real;
   894    895     assert( !sqlite3IsNaN(*pOp->p4.pReal) );
   895    896     pOut->r = *pOp->p4.pReal;
   896    897     break;
   897    898   }
          899  +#endif
   898    900   
   899    901   /* Opcode: String8 * P2 * P4 *
   900    902   **
   901    903   ** P4 points to a nul terminated UTF-8 string. This opcode is transformed 
   902    904   ** into an OP_String before it is executed for the first time.
   903    905   */
   904    906   case OP_String8: {         /* same as TK_STRING, out2-prerelease */
................................................................................
  1526   1528       }
  1527   1529     }else{
  1528   1530       MemSetTypeFlag(pIn1, MEM_Int);
  1529   1531     }
  1530   1532     break;
  1531   1533   }
  1532   1534   
         1535  +#ifndef SQLITE_OMIT_FLOATING_POINT
  1533   1536   /* Opcode: RealAffinity P1 * * * *
  1534   1537   **
  1535   1538   ** If register P1 holds an integer convert it to a real value.
  1536   1539   **
  1537   1540   ** This opcode is used when extracting information from a column that
  1538   1541   ** has REAL affinity.  Such column values may still be stored as
  1539   1542   ** integers, for space efficiency, but after extraction we want them
................................................................................
  1542   1545   case OP_RealAffinity: {                  /* in1 */
  1543   1546     pIn1 = &aMem[pOp->p1];
  1544   1547     if( pIn1->flags & MEM_Int ){
  1545   1548       sqlite3VdbeMemRealify(pIn1);
  1546   1549     }
  1547   1550     break;
  1548   1551   }
         1552  +#endif
  1549   1553   
  1550   1554   #ifndef SQLITE_OMIT_CAST
  1551   1555   /* Opcode: ToText P1 * * * *
  1552   1556   **
  1553   1557   ** Force the value in register P1 to be text.
  1554   1558   ** If the value is numeric, convert it to a string using the
  1555   1559   ** equivalent of printf().  Blob values are unchanged and
................................................................................
  1625   1629     pIn1 = &aMem[pOp->p1];
  1626   1630     if( (pIn1->flags & MEM_Null)==0 ){
  1627   1631       sqlite3VdbeMemIntegerify(pIn1);
  1628   1632     }
  1629   1633     break;
  1630   1634   }
  1631   1635   
  1632         -#ifndef SQLITE_OMIT_CAST
         1636  +#if !defined(SQLITE_OMIT_CAST) && !defined(SQLITE_OMIT_FLOATING_POINT)
  1633   1637   /* Opcode: ToReal P1 * * * *
  1634   1638   **
  1635   1639   ** Force the value in register P1 to be a floating point number.
  1636   1640   ** If The value is currently an integer, convert it.
  1637   1641   ** If the value is text or blob, try to convert it to an integer using the
  1638   1642   ** equivalent of atoi() and store 0.0 if no such conversion is possible.
  1639   1643   **
................................................................................
  1642   1646   case OP_ToReal: {                  /* same as TK_TO_REAL, in1 */
  1643   1647     pIn1 = &aMem[pOp->p1];
  1644   1648     if( (pIn1->flags & MEM_Null)==0 ){
  1645   1649       sqlite3VdbeMemRealify(pIn1);
  1646   1650     }
  1647   1651     break;
  1648   1652   }
  1649         -#endif /* SQLITE_OMIT_CAST */
         1653  +#endif /* !defined(SQLITE_OMIT_CAST) && !defined(SQLITE_OMIT_FLOATING_POINT) */
  1650   1654   
  1651   1655   /* Opcode: Lt P1 P2 P3 P4 P5
  1652   1656   **
  1653   1657   ** Compare the values in register P1 and P3.  If reg(P3)<reg(P1) then
  1654   1658   ** jump to address P2.  
  1655   1659   **
  1656   1660   ** If the SQLITE_JUMPIFNULL bit of P5 is set and either reg(P1) or
................................................................................
  5660   5664   /*
  5661   5665   ** The magic Explain opcode are only inserted when explain==2 (which
  5662   5666   ** is to say when the EXPLAIN QUERY PLAN syntax is used.)
  5663   5667   ** This opcode records information from the optimizer.  It is the
  5664   5668   ** the same as a no-op.  This opcodesnever appears in a real VM program.
  5665   5669   */
  5666   5670   default: {          /* This is really OP_Noop and OP_Explain */
         5671  +  assert( pOp->opcode==OP_Noop || pOp->opcode==OP_Explain );
  5667   5672     break;
  5668   5673   }
  5669   5674   
  5670   5675   /*****************************************************************************
  5671   5676   ** The cases of the switch statement above this line should all be indented
  5672   5677   ** by 6 spaces.  But the left-most 6 spaces have been removed to improve the
  5673   5678   ** readability.  From this point on down, the normal indentation rules are