/ Check-in [1d04c2ab]
Login

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

Overview
Comment:Make sure integer primary keys larger than 2^31 are handled properly. Ticket #1188. (CVS 2436)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 1d04c2ab299430959b8a193d4679cbc4c0be31a4
User & Date: drh 2005-03-31 18:40:05
Context
2005-03-31
21:02
Update comments and documentation to give the true maximum page size as 32K, not 64K as was previously (and erroneously) reported. Ticket #1194. (CVS 2437) check-in: 58dd436b user: drh tags: trunk
18:40
Make sure integer primary keys larger than 2^31 are handled properly. Ticket #1188. (CVS 2436) check-in: 1d04c2ab user: drh tags: trunk
18:26
Fix a memory leak in the TCL bindings. (CVS 2435) check-in: c31ea633 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vdbe.c.

    39     39   **
    40     40   ** Various scripts scan this source file in order to generate HTML
    41     41   ** documentation, headers files, or other derived files.  The formatting
    42     42   ** of the code in this file is, therefore, important.  See other comments
    43     43   ** in this file for details.  If in doubt, do not deviate from existing
    44     44   ** commenting and indentation practices when changing or adding code.
    45     45   **
    46         -** $Id: vdbe.c,v 1.463 2005/03/29 13:07:00 danielk1977 Exp $
           46  +** $Id: vdbe.c,v 1.464 2005/03/31 18:40:05 drh Exp $
    47     47   */
    48     48   #include "sqliteInt.h"
    49     49   #include "os.h"
    50     50   #include <ctype.h>
    51     51   #include "vdbeInt.h"
    52     52   
    53     53   /*
................................................................................
  1312   1312   ** does not look like an integer or floating point number) then pop the
  1313   1313   ** stack and jump to P2.  If the top of the stack is numeric then
  1314   1314   ** convert it into the least integer that is greater than or equal to its
  1315   1315   ** current value if P1==0, or to the least integer that is strictly
  1316   1316   ** greater than its current value if P1==1.
  1317   1317   */
  1318   1318   case OP_ForceInt: {            /* no-push */
  1319         -  int v;
         1319  +  i64 v;
  1320   1320     assert( pTos>=p->aStack );
  1321   1321     applyAffinity(pTos, SQLITE_AFF_INTEGER, db->enc);
  1322   1322     if( (pTos->flags & (MEM_Int|MEM_Real))==0 ){
  1323   1323       Release(pTos);
  1324   1324       pTos--;
  1325   1325       pc = pOp->p2 - 1;
  1326   1326       break;

Changes to test/intpkey.test.

     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.
    12     12   #
    13     13   # This file implements tests for the special processing associated
    14     14   # with INTEGER PRIMARY KEY columns.
    15     15   #
    16         -# $Id: intpkey.test,v 1.21 2005/02/22 09:47:19 danielk1977 Exp $
           16  +# $Id: intpkey.test,v 1.22 2005/03/31 18:40:05 drh Exp $
    17     17   
    18     18   set testdir [file dirname $argv0]
    19     19   source $testdir/tester.tcl
    20     20   
    21     21   # Create a table with a primary key and a datatype other than
    22     22   # integer
    23     23   #
................................................................................
   553    553   } {1 1 one}
   554    554   do_test intpkey-14.6 {
   555    555     execsql {
   556    556       SELECT * FROM t3 WHERE a=c;
   557    557     }
   558    558   } {2 2 2 3 3 3}
   559    559   
   560         -finish_test
          560  +# Check for proper handling of primary keys greater than 2^31.
          561  +# Ticket #1188
          562  +#
          563  +do_test intpkey-15.1 {
          564  +  execsql {
          565  +    INSERT INTO t1 VALUES(2147483647, 'big-1', 123);
          566  +    SELECT * FROM t1 WHERE a>2147483648;
          567  +  }
          568  +} {}
          569  +do_test intpkey-15.2 {
          570  +  execsql {
          571  +    INSERT INTO t1 VALUES(NULL, 'big-2', 234);
          572  +    SELECT b FROM t1 WHERE a>=2147483648;
          573  +  }
          574  +} {big-2}
          575  +do_test intpkey-15.3 {
          576  +  execsql {
          577  +    SELECT b FROM t1 WHERE a>2147483648;
          578  +  }
          579  +} {}
          580  +do_test intpkey-15.4 {
          581  +  execsql {
          582  +    SELECT b FROM t1 WHERE a>=2147483647;
          583  +  }
          584  +} {big-1 big-2}
          585  +do_test intpkey-15.5 {
          586  +  execsql {
          587  +    SELECT b FROM t1 WHERE a<2147483648;
          588  +  }
          589  +} {y zero 2 hello second hello b-20 b-22 new 3 big-1}
          590  +do_test intpkey-15.6 {
          591  +  execsql {
          592  +    SELECT b FROM t1 WHERE a<12345678901;
          593  +  }
          594  +} {y zero 2 hello second hello b-20 b-22 new 3 big-1 big-2}
          595  +do_test intpkey-15.7 {
          596  +  execsql {
          597  +    SELECT b FROM t1 WHERE a>12345678901;
          598  +  }
          599  +} {}
          600  +
   561    601   
          602  +finish_test