/ Check-in [18bfb217]
Login

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

Overview
Comment:Improved comments and extra testcase() macros on the serial-type computation logic in the OP_MakeRecord opcode.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 18bfb2179ce2c60cec8f5859a84b737731a5e53b28e35072cbb249f18b94262b
User & Date: drh 2019-07-11 19:50:18
Context
2019-07-13
16:15
Remove unreachable "break" statements to silence harmless compiler warnings from ICC. check-in: 0d7287e1 user: drh tags: trunk
09:56
Merge latest trunk changes into this branch. check-in: 86ab963c user: dan tags: filter-clause
2019-07-11
19:50
Improved comments and extra testcase() macros on the serial-type computation logic in the OP_MakeRecord opcode. check-in: 18bfb217 user: drh tags: trunk
19:27
Increase the version number to 3.30.0 for the next release cycle. check-in: 2578e3c6 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vdbe.c.

  2923   2923         pLast--;
  2924   2924         nField--;
  2925   2925       }
  2926   2926     }
  2927   2927   #endif
  2928   2928   
  2929   2929     /* Loop through the elements that will make up the record to figure
  2930         -  ** out how much space is required for the new record.
         2930  +  ** out how much space is required for the new record.  After this loop,
         2931  +  ** the Mem.uTemp field of each term should hold the serial-type that will
         2932  +  ** be used for that term in the generated record:
         2933  +  **
         2934  +  **   Mem.uTemp value    type
         2935  +  **   ---------------    ---------------
         2936  +  **      0               NULL
         2937  +  **      1               1-byte signed integer
         2938  +  **      2               2-byte signed integer
         2939  +  **      3               3-byte signed integer
         2940  +  **      4               4-byte signed integer
         2941  +  **      5               6-byte signed integer
         2942  +  **      6               8-byte signed integer
         2943  +  **      7               IEEE float
         2944  +  **      8               Integer constant 0
         2945  +  **      9               Integer constant 1
         2946  +  **     10,11            reserved for expansion
         2947  +  **    N>=12 and even    BLOB
         2948  +  **    N>=13 and odd     text
         2949  +  **
         2950  +  ** The following additional values are computed:
         2951  +  **     nHdr        Number of bytes needed for the record header
         2952  +  **     nData       Number of bytes of data space needed for the record
         2953  +  **     nZero       Zero bytes at the end of the record
  2931   2954     */
  2932   2955     pRec = pLast;
  2933   2956     do{
  2934   2957       assert( memIsValid(pRec) );
  2935   2958       if( pRec->flags & MEM_Null ){
  2936   2959         if( pRec->flags & MEM_Zero ){
  2937   2960           /* Values with MEM_Null and MEM_Zero are created by xColumn virtual
................................................................................
  2939   2962           ** computing an unchanging column value in an UPDATE statement.
  2940   2963           ** Give such values a special internal-use-only serial-type of 10
  2941   2964           ** so that they can be passed through to xUpdate and have
  2942   2965           ** a true sqlite3_value_nochange(). */
  2943   2966           assert( pOp->p5==OPFLAG_NOCHNG_MAGIC || CORRUPT_DB );
  2944   2967           pRec->uTemp = 10;
  2945   2968         }else{
  2946         -        pRec->uTemp = 0;  /* Serial-type 0 means NULL */
         2969  +        pRec->uTemp = 0;
  2947   2970         }
  2948   2971         nHdr++;
  2949   2972       }else if( pRec->flags & (MEM_Int|MEM_IntReal) ){
  2950   2973         /* Figure out whether to use 1, 2, 4, 6 or 8 bytes. */
  2951   2974         i64 i = pRec->u.i;
  2952   2975         u64 u;
  2953   2976         testcase( pRec->flags & MEM_Int );
................................................................................
  2954   2977         testcase( pRec->flags & MEM_IntReal );
  2955   2978         if( i<0 ){
  2956   2979           u = ~i;
  2957   2980         }else{
  2958   2981           u = i;
  2959   2982         }
  2960   2983         nHdr++;
         2984  +      testcase( u==127 );               testcase( u==128 );
         2985  +      testcase( u==32767 );             testcase( u==32768 );
         2986  +      testcase( u==8388607 );           testcase( u==8388608 );
         2987  +      testcase( u==2147483647 );        testcase( u==2147483648 );
         2988  +      testcase( u==140737488355327LL ); testcase( u==140737488355328LL );
  2961   2989         if( u<=127 ){
  2962   2990           if( (i&1)==i && file_format>=4 ){
  2963   2991             pRec->uTemp = 8+(u32)u;
  2964   2992           }else{
  2965   2993             nData++;
  2966   2994             pRec->uTemp = 1;
  2967   2995           }