/ Check-in [14c00b10]
Login

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

Overview
Comment:Always store a REAL value in a column with REAL affinity if the integer equivalent would require 8 bytes of storage. Fix for [3c27b97e3].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 14c00b1016ba53ab2dc177c59a27b6b9209202973685f0f274112d296ba7dfcb
User & Date: dan 2019-05-17 15:59:11
Context
2019-05-17
20:37
Disable PRAGMA journal_mode=OFF when SQLITE_DBCONFIG_DEFENSIVE is turned on. Ticket [f4ec250930342e0c]. check-in: a0f5eb5c user: drh tags: trunk
15:59
Always store a REAL value in a column with REAL affinity if the integer equivalent would require 8 bytes of storage. Fix for [3c27b97e3]. check-in: 14c00b10 user: dan tags: trunk
2019-05-16
20:40
Add test cases to test/fuzzdata7.db for (harmless) dbfuzz2 finds. check-in: 1eb2a628 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vdbe.c.

  2880   2880     /* Apply the requested affinity to all inputs
  2881   2881     */
  2882   2882     assert( pData0<=pLast );
  2883   2883     if( zAffinity ){
  2884   2884       pRec = pData0;
  2885   2885       do{
  2886   2886         applyAffinity(pRec, zAffinity[0], encoding);
         2887  +      if( zAffinity[0]==SQLITE_AFF_REAL && (pRec->flags & MEM_Int) ){
         2888  +        pRec->flags |= MEM_IntReal;
         2889  +        pRec->flags &= ~(MEM_Int);
         2890  +      }
  2887   2891         REGISTER_TRACE((int)(pRec-aMem), pRec);
  2888   2892         zAffinity++;
  2889   2893         pRec++;
  2890   2894         assert( zAffinity[0]==0 || pRec<=pLast );
  2891   2895       }while( zAffinity[0] );
  2892   2896     }
  2893   2897   

Changes to test/intreal.test.

    42     42            max(1,intreal(2),intreal(3),4);
    43     43   } {4.0 4}
    44     44   do_execsql_test 180 {
    45     45     SELECT max(1.0,intreal(5),intreal(3),4.0),
    46     46            max(1,intreal(5),intreal(3),4);
    47     47   } {5.0 5.0}
    48     48   
           49  +#-------------------------------------------------------------------------
           50  +do_execsql_test 2.1 {
           51  +  CREATE TABLE t2(a REAL);
           52  +  INSERT INTO t2 VALUES( 836627109860825358 );
           53  +  SELECT substr(a,1,4) FROM t2 WHERE a = CAST(836627109860825358 AS REAL);
           54  +} {8.36}
           55  +
           56  +do_execsql_test 2.2 {
           57  +  CREATE INDEX i2 ON t2(a);
           58  +  SELECT substr(a,1,4) FROM t2 WHERE a = CAST(836627109860825358 AS REAL);
           59  +} {8.36}
           60  +
           61  +do_execsql_test 2.3 {
           62  +  CREATE TABLE t0 (c0);
           63  +  CREATE TABLE t1 (c1 REAL);
           64  +  INSERT INTO t1(c1) VALUES (8366271098608253588);
           65  +  INSERT INTO t0(c0) VALUES ('a');
           66  +}
           67  +set D [db one {SELECT c1 FROM t1}]
           68  +
           69  +do_execsql_test 2.4 {
           70  +  SELECT * FROM t1 WHERE (t1.c1 = CAST(8366271098608253588 AS REAL));
           71  +} $D
           72  +
           73  +do_execsql_test 2.5 {
           74  +  SELECT * FROM t0, t1 WHERE (t1.c1 = CAST(8366271098608253588 AS REAL));
           75  +} [list a $D]
    49     76   
           77  +do_execsql_test 2.6 {
           78  +  SELECT * FROM t0, t1 
           79  +  WHERE (
           80  +        t1.c1 >= CAST(8366271098608253588 AS REAL) 
           81  +    AND t1.c1 <= CAST(8366271098608253588 AS REAL)
           82  +  );
           83  +} [list a $D]
    50     84   
    51     85   
    52     86   finish_test