/ Check-in [ad962479]
Login

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

Overview
Comment:Fix for ticket #65: If an integer value is too big to be represented as a 32-bit integer, then treat it as a string. (CVS 611)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:ad9624798edbd6d0c4652fed3d74fe87498844ff
User & Date: drh 2002-06-09 01:16:01
Context
2002-06-09
01:55
Added tests for the new IN operator optimizer and fixed a bug that the new tests found. This completes the implementation of enhancement #63. (CVS 612) check-in: 2a710e18 user: drh tags: trunk
01:16
Fix for ticket #65: If an integer value is too big to be represented as a 32-bit integer, then treat it as a string. (CVS 611) check-in: ad962479 user: drh tags: trunk
2002-06-08
23:25
Add optimizations for the IN operator in WHERE clauses. This is a partial implementation of enhancement #63. Still need to add test cases. (CVS 610) check-in: 8481e841 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.69 2002/06/02 18:22:06 drh Exp $
           15  +** $Id: expr.c,v 1.70 2002/06/09 01:16:01 drh Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   #include <ctype.h>
    19     19   
    20     20   /*
    21     21   ** Construct a new expression node and return a pointer to it.  Memory
    22     22   ** for this node is obtained from sqliteMalloc().  The calling function
................................................................................
   820    820           sqliteVdbeAddOp(v, OP_Column, pExpr->iTable, pExpr->iColumn);
   821    821         }else{
   822    822           sqliteVdbeAddOp(v, OP_Recno, pExpr->iTable, 0);
   823    823         }
   824    824         break;
   825    825       }
   826    826       case TK_INTEGER: {
   827         -      sqliteVdbeAddOp(v, OP_Integer, atoi(pExpr->token.z), 0);
          827  +      int iVal = atoi(pExpr->token.z);
          828  +      char zBuf[30];
          829  +      sprintf(zBuf,"%d",iVal);
          830  +      if( strlen(zBuf)!=pExpr->token.n 
          831  +            || strncmp(pExpr->token.z,zBuf,pExpr->token.n)!=0 ){
          832  +        /* If the integer value cannot be represented exactly in 32 bits,
          833  +        ** then code it as a string instead. */
          834  +        sqliteVdbeAddOp(v, OP_String, 0, 0);
          835  +      }else{
          836  +        sqliteVdbeAddOp(v, OP_Integer, iVal, 0);
          837  +      }
   828    838         sqliteVdbeChangeP3(v, -1, pExpr->token.z, pExpr->token.n);
   829    839         break;
   830    840       }
   831    841       case TK_FLOAT: {
   832    842         sqliteVdbeAddOp(v, OP_String, 0, 0);
   833    843         assert( pExpr->token.z );
   834    844         sqliteVdbeChangeP3(v, -1, pExpr->token.z, pExpr->token.n);

Changes to test/misc1.test.

     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.
    12     12   #
    13     13   # This file implements tests for miscellanous features that were
    14     14   # left out of other test files.
    15     15   #
    16         -# $Id: misc1.test,v 1.7 2002/06/06 23:42:28 drh Exp $
           16  +# $Id: misc1.test,v 1.8 2002/06/09 01:16:01 drh Exp $
    17     17   
    18     18   set testdir [file dirname $argv0]
    19     19   source $testdir/tester.tcl
    20     20   
    21     21   # Test the creation and use of tables that have a large number
    22     22   # of columns.
    23     23   #
................................................................................
   234    234   } {1 {no tables specified}}
   235    235   do_test misc1-8.2 {
   236    236     catchsql {
   237    237       SELECT t1.*;
   238    238     }
   239    239   } {1 {no such table: t1}}
   240    240   
          241  +execsql {
          242  +  DROP TABLE t1;
          243  +  DROP TABLE t2;
          244  +  DROP TABLE t3;
          245  +  DROP TABLE t4;
          246  +}
          247  +
          248  +# If an integer is too big to be represented as a 32-bit machine integer,
          249  +# then treat it as a string.
          250  +#
          251  +do_test misc1-9.1 {
          252  +  catchsql {
          253  +    CREATE TABLE t1(a unique not null, b unique not null);
          254  +    INSERT INTO t1 VALUES('a',12345678901234567890);
          255  +    INSERT INTO t1 VALUES('b',12345678911234567890);
          256  +    INSERT INTO t1 VALUES('c',12345678921234567890);
          257  +    SELECT * FROM t1;
          258  +  }
          259  +} {0 {a 12345678901234567890 b 12345678911234567890 c 12345678921234567890}}
          260  +
   241    261   
   242    262   finish_test