diff options
author | drh <drh@noemail.net> | 2003-07-27 17:16:06 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2003-07-27 17:16:06 +0000 |
commit | dc2d94de56ae83b7a986de97caba7f64fcdade30 (patch) | |
tree | a90add03cb384669813d57b641a4ad28b025a292 /src | |
parent | 48647b390bad399bff0495032e111f09603d0f0f (diff) | |
download | sqlite-dc2d94de56ae83b7a986de97caba7f64fcdade30.tar.gz sqlite-dc2d94de56ae83b7a986de97caba7f64fcdade30.zip |
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)
FossilOrigin-Name: 7514c3db165e8cc5c696b2b345844949a0e45a61
Diffstat (limited to 'src')
-rw-r--r-- | src/vdbe.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/vdbe.c b/src/vdbe.c index 4c230d019..d6739dddb 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -36,7 +36,7 @@ ** 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 $ +** $Id: vdbe.c,v 1.235 2003/07/27 17:16:07 drh Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -997,8 +997,10 @@ static void hardRelease(Vdbe *p, int i){ } /* -** Return TRUE if zNum is an integer and write -** the value of the integer into *pNum. +** 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. @@ -1006,6 +1008,7 @@ static void hardRelease(Vdbe *p, int i){ static int toInt(const char *zNum, int *pNum){ int v = 0; int neg; + int i, c; if( *zNum=='-' ){ neg = 1; zNum++; @@ -1015,13 +1018,11 @@ static int toInt(const char *zNum, int *pNum){ }else{ neg = 0; } - if( *zNum==0 ) return 0; - while( isdigit(*zNum) ){ - v = v*10 + *zNum - '0'; - zNum++; + for(i=0; (c=zNum[i])>='0' && c<='9'; i++){ + v = v*10 + c - '0'; } *pNum = neg ? -v : v; - return *zNum==0; + return c==0 && i>0 && (i<10 || (i==10 && memcmp(zNum,"2147483647",10)<=0)); } /* |