/ Check-in [c085d6df]
Login

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

Overview
Comment:Add comments, assertions, and test cases to demonstrate that the problem described in ticket #2742 is not a real problem. (CVS 4510)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c085d6dfc0f5849113986cb2a25e64d0c95b3dfb
User & Date: drh 2007-10-23 18:55:49
Context
2007-10-24
21:52
fts3.c buildTerms() passes -1 for nInput. (CVS 4511) check-in: e87c883a user: shess tags: trunk
2007-10-23
18:55
Add comments, assertions, and test cases to demonstrate that the problem described in ticket #2742 is not a real problem. (CVS 4510) check-in: c085d6df user: drh tags: trunk
15:59
Add comments to the code warning that _XOPEN_SOURCE might need to be defined manually if using USE_PREAD or USE_PREAD64. (CVS 4509) check-in: d7ed7cd0 user: drh 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.314 2007/10/23 15:39:45 drh Exp $
           15  +** $Id: expr.c,v 1.315 2007/10/23 18:55:49 drh Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   #include <ctype.h>
    19     19   
    20     20   /*
    21     21   ** Return the 'affinity' of the expression pExpr if any.
    22     22   **
................................................................................
  1690   1690     }
  1691   1691     return out;
  1692   1692   }
  1693   1693   
  1694   1694   /*
  1695   1695   ** Generate an instruction that will put the floating point
  1696   1696   ** value described by z[0..n-1] on the stack.
         1697  +**
         1698  +** The z[] string will probably not be zero-terminated.  But the 
         1699  +** z[n] character is guaranteed to be something that does not look
         1700  +** like the continuation of the number.
  1697   1701   */
  1698   1702   static void codeReal(Vdbe *v, const char *z, int n, int negateFlag){
  1699   1703     assert( z || v==0 || sqlite3VdbeDb(v)->mallocFailed );
  1700   1704     if( z ){
  1701   1705       double value;
  1702   1706       char *zV;
         1707  +    assert( !isdigit(z[n]) );
  1703   1708       sqlite3AtoF(z, &value);
  1704   1709       if( negateFlag ) value = -value;
  1705   1710       zV = dup8bytes(v, (char*)&value);
  1706   1711       sqlite3VdbeOp3(v, OP_Real, 0, 0, zV, P3_REAL);
  1707   1712     }
  1708   1713   }
  1709   1714   
  1710   1715   
  1711   1716   /*
  1712   1717   ** Generate an instruction that will put the integer describe by
  1713   1718   ** text z[0..n-1] on the stack.
         1719  +**
         1720  +** The z[] string will probably not be zero-terminated.  But the 
         1721  +** z[n] character is guaranteed to be something that does not look
         1722  +** like the continuation of the number.
  1714   1723   */
  1715   1724   static void codeInteger(Vdbe *v, const char *z, int n, int negateFlag){
  1716   1725     assert( z || v==0 || sqlite3VdbeDb(v)->mallocFailed );
  1717   1726     if( z ){
  1718   1727       int i;
         1728  +    assert( !isdigit(z[n]) );
  1719   1729       if( sqlite3GetInt32(z, &i) ){
  1720   1730         if( negateFlag ) i = -i;
  1721   1731         sqlite3VdbeAddOp(v, OP_Integer, i, 0);
  1722   1732       }else if( sqlite3FitsIn64Bits(z, negateFlag) ){
  1723   1733         i64 value;
  1724   1734         char *zV;
  1725   1735         sqlite3Atoi64(z, &value);

Changes to test/capi3.test.

     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this script testing the callback-free C/C++ API.
    13     13   #
    14         -# $Id: capi3.test,v 1.55 2007/08/29 19:15:09 drh Exp $
           14  +# $Id: capi3.test,v 1.56 2007/10/23 18:55:50 drh Exp $
    15     15   #
    16     16   
    17     17   set testdir [file dirname $argv0]
    18     18   source $testdir/tester.tcl
    19     19   
    20     20   # Return the UTF-16 representation of the supplied UTF-8 string $str.
    21     21   # If $nt is true, append two 0x00 bytes as a nul terminator.
................................................................................
  1016   1016   do_test capi3-15.2 {
  1017   1017     sqlite3_step $STMT
  1018   1018     sqlite3_column_int $STMT 0
  1019   1019   } {2}
  1020   1020   do_test capi3-15.3 {
  1021   1021     sqlite3_finalize $STMT
  1022   1022   } {SQLITE_OK}
         1023  +do_test capi3-15.4 {
         1024  +  #        123456789 1234567
         1025  +  set sql {SELECT 1234567890}
         1026  +  set STMT [sqlite3_prepare $DB $sql 8 TAIL]
         1027  +  sqlite3_step $STMT
         1028  +  set v1 [sqlite3_column_int $STMT 0]
         1029  +  sqlite3_finalize $STMT
         1030  +  set v1
         1031  +} {1}
         1032  +do_test capi3-15.5 {
         1033  +  #        123456789 1234567
         1034  +  set sql {SELECT 1234567890}
         1035  +  set STMT [sqlite3_prepare $DB $sql 9 TAIL]
         1036  +  sqlite3_step $STMT
         1037  +  set v1 [sqlite3_column_int $STMT 0]
         1038  +  sqlite3_finalize $STMT
         1039  +  set v1
         1040  +} {12}
         1041  +do_test capi3-15.6 {
         1042  +  #        123456789 1234567
         1043  +  set sql {SELECT 1234567890}
         1044  +  set STMT [sqlite3_prepare $DB $sql 12 TAIL]
         1045  +  sqlite3_step $STMT
         1046  +  set v1 [sqlite3_column_int $STMT 0]
         1047  +  sqlite3_finalize $STMT
         1048  +  set v1
         1049  +} {12345}
         1050  +do_test capi3-15.7 {
         1051  +  #        123456789 1234567
         1052  +  set sql {SELECT 12.34567890}
         1053  +  set STMT [sqlite3_prepare $DB $sql 12 TAIL]
         1054  +  sqlite3_step $STMT
         1055  +  set v1 [sqlite3_column_double $STMT 0]
         1056  +  sqlite3_finalize $STMT
         1057  +  set v1
         1058  +} {12.34}
         1059  +do_test capi3-15.8 {
         1060  +  #        123456789 1234567
         1061  +  set sql {SELECT 12.34567890}
         1062  +  set STMT [sqlite3_prepare $DB $sql 14 TAIL]
         1063  +  sqlite3_step $STMT
         1064  +  set v1 [sqlite3_column_double $STMT 0]
         1065  +  sqlite3_finalize $STMT
         1066  +  set v1
         1067  +} {12.3456}
  1023   1068   
  1024   1069   # Make sure code is always generated even if an IF EXISTS or 
  1025   1070   # IF NOT EXISTS clause is present that the table does not or
  1026   1071   # does exists.  That way we will always have a prepared statement
  1027   1072   # to expire when the schema changes.
  1028   1073   #
  1029   1074   do_test capi3-16.1 {