/ Check-in [4becc47e]
Login

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

Overview
Comment:Avoid 32-bit integer overflow when evaluating the exponent of a floating point value during ascii to binary conversion.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 4becc47eb4d48686faca4f61e93e5f379b227fcc
User & Date: drh 2011-10-17 20:41:46
Context
2011-10-17
23:15
Change the OP_JournalMode implementation so that it works even if a substitute sqlite3PagerFilename() that might return NULL is used. check-in: 491ff5fb user: drh tags: trunk
20:41
Avoid 32-bit integer overflow when evaluating the exponent of a floating point value during ascii to binary conversion. check-in: 4becc47e user: drh tags: trunk
12:14
Performance improvement for ascii to floating-point conversions with very large exponents. check-in: 59bb999c user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/util.c.

   327    327         esign = -1;
   328    328         z+=incr;
   329    329       }else if( *z=='+' ){
   330    330         z+=incr;
   331    331       }
   332    332       /* copy digits to exponent */
   333    333       while( z<zEnd && sqlite3Isdigit(*z) ){
   334         -      e = e*10 + (*z - '0');
          334  +      e = e<10000 ? (e*10 + (*z - '0')) : 10000;
   335    335         z+=incr;
   336    336         eValid = 1;
   337    337       }
   338    338     }
   339    339   
   340    340     /* skip trailing spaces */
   341    341     if( nDigits && eValid ){

Changes to test/nan.test.

   315    315   
   316    316   do_realnum_test nan-4.20 {
   317    317     db eval {DELETE FROM t1}
   318    318     set big [string repeat 9 10000].0e-9000
   319    319     db eval "INSERT INTO t1 VALUES($big)"
   320    320     db eval {SELECT x, typeof(x) FROM t1}
   321    321   } {inf real}
          322  +
          323  +do_realnum_test nan-4.30 {
          324  +  db eval {
          325  +    DELETE FROM t1;
          326  +    INSERT INTO t1 VALUES('2.5e+9999');
          327  +    SELECT x, typeof(x) FROM t1;
          328  +  }
          329  +} {inf real}
          330  +do_realnum_test nan-4.31 {
          331  +  db eval {
          332  +    DELETE FROM t1;
          333  +    INSERT INTO t1 VALUES('2.5e+10000');
          334  +    SELECT x, typeof(x) FROM t1;
          335  +  }
          336  +} {inf real}
          337  +
          338  +do_realnum_test nan-4.32 {
          339  +  db eval {
          340  +    DELETE FROM t1;
          341  +    INSERT INTO t1 VALUES('2.5e-9999');
          342  +    SELECT x, typeof(x) FROM t1;
          343  +  }
          344  +} {0.0 real}
          345  +do_realnum_test nan-4.33 {
          346  +  db eval {
          347  +    DELETE FROM t1;
          348  +    INSERT INTO t1 VALUES('2.5e-10000');
          349  +    SELECT x, typeof(x) FROM t1;
          350  +  }
          351  +} {0.0 real}
          352  +do_realnum_test nan-4.34 {
          353  +  db eval {
          354  +    DELETE FROM t1;
          355  +    INSERT INTO t1 VALUES('2.5e2147483650');
          356  +    SELECT x, typeof(x) FROM t1;
          357  +  }
          358  +} {inf real}
          359  +do_realnum_test nan-4.35 {
          360  +  db eval {
          361  +    DELETE FROM t1;
          362  +    INSERT INTO t1 VALUES('2.5e-2147483650');
          363  +    SELECT x, typeof(x) FROM t1;
          364  +  }
          365  +} {0.0 real}
          366  +
          367  +  
   322    368   
   323    369   
   324    370   
   325    371   finish_test