SQLite

Check-in [7514c3db16]
Login

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

Overview
Comment:In the VDBE, when an integer value will not fit into a 32-bit int, store it in a double instead. Ticket #408. (CVS 1064)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 7514c3db165e8cc5c696b2b345844949a0e45a61
User & Date: drh 2003-07-27 17:16:07.000
Context
2003-07-27
17:26
Make sure the schema loader callback can handle EMPTY_RESULT_CALLBACKS being on. Ticket #406. (CVS 1065) (check-in: 8c163fc0c7 user: drh tags: trunk)
17:16
In the VDBE, when an integer value will not fit into a 32-bit int, store it in a double instead. Ticket #408. (CVS 1064) (check-in: 7514c3db16 user: drh tags: trunk)
2003-07-22
13:20
Version 2.8.5 (CVS 1063) (check-in: 95fba440e7 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/vdbe.c.
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
**
** Various scripts scan this source file in order to generate HTML
** documentation, headers files, or other derived files.  The formatting
** of the code in this file is, therefore, important.  See other comments
** in this file for details.  If in doubt, do not deviate from existing
** commenting and indentation practices when changing or adding code.
**
** $Id: vdbe.c,v 1.234 2003/07/22 09:24:45 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "os.h"
#include <ctype.h>

/*
** The makefile scans this source file and creates the following







|







32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
**
** Various scripts scan this source file in order to generate HTML
** documentation, headers files, or other derived files.  The formatting
** of the code in this file is, therefore, important.  See other comments
** in this file for details.  If in doubt, do not deviate from existing
** commenting and indentation practices when changing or adding code.
**
** $Id: vdbe.c,v 1.235 2003/07/27 17:16:07 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
#include <ctype.h>

/*
** The makefile scans this source file and creates the following
993
994
995
996
997
998
999
1000
1001


1002
1003
1004
1005
1006
1007
1008

1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
static void hardRelease(Vdbe *p, int i){
  sqliteFree(p->zStack[i]);
  p->zStack[i] = 0;
  p->aStack[i].flags &= ~(STK_Str|STK_Dyn|STK_Static|STK_Ephem);
}

/*
** Return TRUE if zNum is an integer and write
** the value of the integer into *pNum.


**
** Under Linux (RedHat 7.2) this routine is much faster than atoi()
** for converting strings into integers.
*/
static int toInt(const char *zNum, int *pNum){
  int v = 0;
  int neg;

  if( *zNum=='-' ){
    neg = 1;
    zNum++;
  }else if( *zNum=='+' ){
    neg = 0;
    zNum++;
  }else{
    neg = 0;
  }
  if( *zNum==0 ) return 0;
  while( isdigit(*zNum) ){
    v = v*10 + *zNum - '0';
    zNum++;
  }
  *pNum = neg ? -v : v;
  return *zNum==0;
}

/*
** Convert the given stack entity into a integer if it isn't one
** already.
**
** Any prior string or real representation is invalidated.  







|
|
>
>







>









|
<
|
<


|







993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021

1022

1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
static void hardRelease(Vdbe *p, int i){
  sqliteFree(p->zStack[i]);
  p->zStack[i] = 0;
  p->aStack[i].flags &= ~(STK_Str|STK_Dyn|STK_Static|STK_Ephem);
}

/*
** Return TRUE if zNum is a 32-bit signed integer and write
** the value of the integer into *pNum.  If zNum is not an integer
** or is an integer that is too large to be expressed with just 32
** bits, then return false.
**
** Under Linux (RedHat 7.2) this routine is much faster than atoi()
** for converting strings into integers.
*/
static int toInt(const char *zNum, int *pNum){
  int v = 0;
  int neg;
  int i, c;
  if( *zNum=='-' ){
    neg = 1;
    zNum++;
  }else if( *zNum=='+' ){
    neg = 0;
    zNum++;
  }else{
    neg = 0;
  }
  for(i=0; (c=zNum[i])>='0' && c<='9'; i++){

    v = v*10 + c - '0';

  }
  *pNum = neg ? -v : v;
  return c==0 && i>0 && (i<10 || (i==10 && memcmp(zNum,"2147483647",10)<=0));
}

/*
** Convert the given stack entity into a integer if it isn't one
** already.
**
** Any prior string or real representation is invalidated.  
Changes to test/misc2.test.
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# This file implements tests for miscellanous features that were
# left out of other test files.
#
# $Id: misc2.test,v 1.4 2003/07/09 16:34:56 drh Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# Test for ticket #360
#
do_test misc2-1.1 {







|







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# This file implements tests for miscellanous features that were
# left out of other test files.
#
# $Id: misc2.test,v 1.5 2003/07/27 17:16:08 drh Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# Test for ticket #360
#
do_test misc2-1.1 {
57
58
59
60
61
62
63





































# Check name binding precedence.  Ticket #387
#
do_test misc2-3.1 {
  catchsql {
    SELECT t1.b+t2.b AS a, t1.a, t2.a FROM t1, t2 WHERE a==10
  }
} {1 {ambiguous column name: a}}












































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# Check name binding precedence.  Ticket #387
#
do_test misc2-3.1 {
  catchsql {
    SELECT t1.b+t2.b AS a, t1.a, t2.a FROM t1, t2 WHERE a==10
  }
} {1 {ambiguous column name: a}}

# Make sure 32-bit integer overflow is handled properly in queries.
# ticket #408
#
do_test misc2-4.1 {
  execsql {
    INSERT INTO t1 VALUES(4000000000,'a','b');
    SELECT a FROM t1 WHERE a>1;
  }
} {4000000000}
do_test misc2-4.2 {
  execsql {
    INSERT INTO t1 VALUES(2147483648,'b2','c2');
    INSERT INTO t1 VALUES(2147483647,'b3','c3');
    SELECT a FROM t1 WHERE a>2147483647;
  }
} {4000000000 2147483648}
do_test misc2-4.3 {
  execsql {
    SELECT a FROM t1 WHERE a<2147483648;
  }
} {1 2147483647}
do_test misc2-4.4 {
  execsql {
    SELECT a FROM t1 WHERE a<=2147483648;
  }
} {1 2147483648 2147483647}
do_test misc2-4.5 {
  execsql {
    SELECT a FROM t1 WHERE a<10000000000;
  }
} {1 4000000000 2147483648 2147483647}
do_test misc2-4.6 {
  execsql {
    SELECT a FROM t1 WHERE a<1000000000000 ORDER BY 1;
  }
} {1 2147483647 2147483648 4000000000}