SQLite

Check-in [18bfb2179c]
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
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 18bfb2179ce2c60cec8f5859a84b737731a5e53b28e35072cbb249f18b94262b
User & Date: drh 2019-07-11 19:50:18.474
Context
2019-07-13
16:15
Remove unreachable "break" statements to silence harmless compiler warnings from ICC. (check-in: 0d7287e1bf user: drh tags: trunk)
09:56
Merge latest trunk changes into this branch. (check-in: 86ab963cc5 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: 18bfb2179c user: drh tags: trunk)
19:27
Increase the version number to 3.30.0 for the next release cycle. (check-in: 2578e3c64b user: drh tags: trunk)
Changes
Side-by-Side Diff Ignore Whitespace Patch
Changes to src/vdbe.c.
2923
2924
2925
2926
2927
2928
2929
2930
























2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946

2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960





2961
2962
2963
2964
2965
2966
2967
2923
2924
2925
2926
2927
2928
2929

2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968

2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995







-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+















-
+














+
+
+
+
+







      pLast--;
      nField--;
    }
  }
#endif

  /* Loop through the elements that will make up the record to figure
  ** out how much space is required for the new record.
  ** out how much space is required for the new record.  After this loop,
  ** the Mem.uTemp field of each term should hold the serial-type that will
  ** be used for that term in the generated record:
  **
  **   Mem.uTemp value    type
  **   ---------------    ---------------
  **      0               NULL
  **      1               1-byte signed integer
  **      2               2-byte signed integer
  **      3               3-byte signed integer
  **      4               4-byte signed integer
  **      5               6-byte signed integer
  **      6               8-byte signed integer
  **      7               IEEE float
  **      8               Integer constant 0
  **      9               Integer constant 1
  **     10,11            reserved for expansion
  **    N>=12 and even    BLOB
  **    N>=13 and odd     text
  **
  ** The following additional values are computed:
  **     nHdr        Number of bytes needed for the record header
  **     nData       Number of bytes of data space needed for the record
  **     nZero       Zero bytes at the end of the record
  */
  pRec = pLast;
  do{
    assert( memIsValid(pRec) );
    if( pRec->flags & MEM_Null ){
      if( pRec->flags & MEM_Zero ){
        /* Values with MEM_Null and MEM_Zero are created by xColumn virtual
        ** table methods that never invoke sqlite3_result_xxxxx() while
        ** computing an unchanging column value in an UPDATE statement.
        ** Give such values a special internal-use-only serial-type of 10
        ** so that they can be passed through to xUpdate and have
        ** a true sqlite3_value_nochange(). */
        assert( pOp->p5==OPFLAG_NOCHNG_MAGIC || CORRUPT_DB );
        pRec->uTemp = 10;
      }else{
        pRec->uTemp = 0;  /* Serial-type 0 means NULL */
        pRec->uTemp = 0;
      }
      nHdr++;
    }else if( pRec->flags & (MEM_Int|MEM_IntReal) ){
      /* Figure out whether to use 1, 2, 4, 6 or 8 bytes. */
      i64 i = pRec->u.i;
      u64 u;
      testcase( pRec->flags & MEM_Int );
      testcase( pRec->flags & MEM_IntReal );
      if( i<0 ){
        u = ~i;
      }else{
        u = i;
      }
      nHdr++;
      testcase( u==127 );               testcase( u==128 );
      testcase( u==32767 );             testcase( u==32768 );
      testcase( u==8388607 );           testcase( u==8388608 );
      testcase( u==2147483647 );        testcase( u==2147483648 );
      testcase( u==140737488355327LL ); testcase( u==140737488355328LL );
      if( u<=127 ){
        if( (i&1)==i && file_format>=4 ){
          pRec->uTemp = 8+(u32)u;
        }else{
          nData++;
          pRec->uTemp = 1;
        }