/ Check-in [48889530]
Login

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

Overview
Comment:Ensure that the typeof() function always returns SQLITE_FLOAT for floating point values even when the value is stored as an integer to save space.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 48889530a9de22fee536edfd1627be62396ed18d842d5fd6d91e010b4337be95
User & Date: drh 2019-05-02 17:45:52
Context
2019-05-03
02:41
Fix the ".open --hexdb" command in the CLI so that it works even with terminal input. check-in: 9b5d9434 user: drh tags: trunk
2019-05-02
21:36
Make MEM_IntReal a completely independent type, meaning a floating point value stored as an integer. This fixes a problem with arithmetic within arguments to string functions on indexes of expressions. But it is a big change and needs lots of new testcase() macros for MC/DC and so it is initially put on this branch. check-in: dba836e3 user: drh tags: int-real
17:45
Ensure that the typeof() function always returns SQLITE_FLOAT for floating point values even when the value is stored as an integer to save space. check-in: 48889530 user: drh tags: trunk
17:06
Add options to wapptest.tcl similar to those supported by releasetest.tcl. Also add the -noui switch, for running without wapp altogether. check-in: 005a1694 user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vdbeInt.h.

   241    241   ** flags may coexist with the MEM_Str flag.
   242    242   */
   243    243   #define MEM_Null      0x0001   /* Value is NULL (or a pointer) */
   244    244   #define MEM_Str       0x0002   /* Value is a string */
   245    245   #define MEM_Int       0x0004   /* Value is an integer */
   246    246   #define MEM_Real      0x0008   /* Value is a real number */
   247    247   #define MEM_Blob      0x0010   /* Value is a BLOB */
   248         -#define MEM_AffMask   0x001f   /* Mask of affinity bits */
   249         -#define MEM_FromBind  0x0020   /* Value originates from sqlite3_bind() */
   250         -#define MEM_IntReal   0x0040   /* MEM_Int that stringifies like MEM_Real */
          248  +#define MEM_IntReal   0x0020   /* MEM_Int that stringifies like MEM_Real */
          249  +#define MEM_AffMask   0x003f   /* Mask of affinity bits */
          250  +#define MEM_FromBind  0x0040   /* Value originates from sqlite3_bind() */
   251    251   #define MEM_Undefined 0x0080   /* Value is undefined */
   252    252   #define MEM_Cleared   0x0100   /* NULL set by OP_Null, not from data */
   253         -#define MEM_TypeMask  0xc1df   /* Mask of type bits */
          253  +#define MEM_TypeMask  0xc1bf   /* Mask of type bits */
   254    254   
   255    255   
   256    256   /* Whenever Mem contains a valid string or blob representation, one of
   257    257   ** the following flags must be set to determine the memory management
   258    258   ** policy for Mem.z.  The MEM_Term flag tells us whether or not the
   259    259   ** string is \000 or \u0000 terminated
   260    260   */

Changes to src/vdbeapi.c.

   262    262        SQLITE_NULL,     /* 0x19 */
   263    263        SQLITE_FLOAT,    /* 0x1a */
   264    264        SQLITE_NULL,     /* 0x1b */
   265    265        SQLITE_INTEGER,  /* 0x1c */
   266    266        SQLITE_NULL,     /* 0x1d */
   267    267        SQLITE_INTEGER,  /* 0x1e */
   268    268        SQLITE_NULL,     /* 0x1f */
          269  +     SQLITE_BLOB,     /* 0x20 */
          270  +     SQLITE_NULL,     /* 0x21 */
          271  +     SQLITE_TEXT,     /* 0x22 */
          272  +     SQLITE_NULL,     /* 0x23 */
          273  +     SQLITE_FLOAT,    /* 0x24 */
          274  +     SQLITE_NULL,     /* 0x25 */
          275  +     SQLITE_FLOAT,    /* 0x26 */
          276  +     SQLITE_NULL,     /* 0x27 */
          277  +     SQLITE_FLOAT,    /* 0x28 */
          278  +     SQLITE_NULL,     /* 0x29 */
          279  +     SQLITE_FLOAT,    /* 0x2a */
          280  +     SQLITE_NULL,     /* 0x2b */
          281  +     SQLITE_FLOAT,    /* 0x2c */
          282  +     SQLITE_NULL,     /* 0x2d */
          283  +     SQLITE_FLOAT,    /* 0x2e */
          284  +     SQLITE_NULL,     /* 0x2f */
          285  +     SQLITE_BLOB,     /* 0x30 */
          286  +     SQLITE_NULL,     /* 0x31 */
          287  +     SQLITE_TEXT,     /* 0x32 */
          288  +     SQLITE_NULL,     /* 0x33 */
          289  +     SQLITE_FLOAT,    /* 0x34 */
          290  +     SQLITE_NULL,     /* 0x35 */
          291  +     SQLITE_FLOAT,    /* 0x36 */
          292  +     SQLITE_NULL,     /* 0x37 */
          293  +     SQLITE_FLOAT,    /* 0x38 */
          294  +     SQLITE_NULL,     /* 0x39 */
          295  +     SQLITE_FLOAT,    /* 0x3a */
          296  +     SQLITE_NULL,     /* 0x3b */
          297  +     SQLITE_FLOAT,    /* 0x3c */
          298  +     SQLITE_NULL,     /* 0x3d */
          299  +     SQLITE_FLOAT,    /* 0x3e */
          300  +     SQLITE_NULL,     /* 0x3f */
   269    301     };
          302  +#ifdef SQLITE_DEBUG
          303  +  {
          304  +    int eType = SQLITE_BLOB;
          305  +    if( pVal->flags & MEM_Null ){
          306  +      eType = SQLITE_NULL;
          307  +    }else if( pVal->flags & MEM_Int ){
          308  +      eType = (pVal->flags & MEM_IntReal) ? SQLITE_FLOAT : SQLITE_INTEGER;
          309  +    }else if( pVal->flags & MEM_Real ){
          310  +      eType = SQLITE_FLOAT;
          311  +    }else if( pVal->flags & MEM_Str ){
          312  +      eType = SQLITE_TEXT;
          313  +    }
          314  +    assert( eType == aType[pVal->flags&MEM_AffMask] );
          315  +  }
          316  +#endif
   270    317     return aType[pVal->flags&MEM_AffMask];
   271    318   }
   272    319   
   273    320   /* Return true if a parameter to xUpdate represents an unchanged column */
   274    321   int sqlite3_value_nochange(sqlite3_value *pVal){
   275    322     return (pVal->flags&(MEM_Null|MEM_Zero))==(MEM_Null|MEM_Zero);
   276    323   }

Changes to test/index.test.

   753    753     DROP TABLE t1;
   754    754     CREATE TABLE t1(a TEXT, b REAL);
   755    755     CREATE UNIQUE INDEX t1x1 ON t1(a GLOB b);
   756    756     INSERT INTO t1(a,b) VALUES('0.0','1'),('1.0','1');
   757    757     SELECT * FROM t1;
   758    758     REINDEX;
   759    759   } {0.0 1.0 1.0 1.0}
          760  +do_execsql_test index-23.1 {
          761  +  DROP TABLE t1;
          762  +  CREATE TABLE t1(a REAL);
          763  +  CREATE UNIQUE INDEX index_0 ON t1(TYPEOF(a));
          764  +  INSERT OR IGNORE INTO t1(a) VALUES (0.1),(FALSE);
          765  +  SELECT * FROM t1;
          766  +  REINDEX;
          767  +} {0.1}
   760    768   
   761    769   finish_test