SQLite4
Check-in [b7ac369ba7]
Not logged in

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

Overview
Comment:Add two new value-encoding header codes to represent REAL-IN-KEY and NONREAL-IN-KEY. This is an incompatible file format change.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: b7ac369ba71903a58e1b686fe408aa6bea4d06a1
User & Date: drh 2013-07-22 20:12:23
Context
2013-07-23
16:50
Change where.c to read values from covering indexes instead of tables whenever possible. Modify OP_SeekPk to defer seeks (as OP_Seek does in sqlite3). check-in: 7f6b4708c2 user: dan tags: trunk
2013-07-22
20:12
Add two new value-encoding header codes to represent REAL-IN-KEY and NONREAL-IN-KEY. This is an incompatible file format change. check-in: b7ac369ba7 user: drh tags: trunk
19:49
Fix compiler warnings. check-in: 610033d7f5 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/vdbecodec.c.

87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105


106

107



108
109
110
111
112
113
114
...
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
  ofst += n;
  endHdr = ofst;
  if( endHdr>p->n ) return SQLITE4_CORRUPT;
  for(i=0; i<=iVal && n<endHdr; i++){
    sz = sqlite4GetVarint64(p->a+n, p->n-n, &type);
    if( sz==0 ) return SQLITE4_CORRUPT;
    n += sz;
    if( type>=22 ){
      cclass = (type-22)%3;
      if( cclass==2 ){
         sz = sqlite4GetVarint64(p->a+n, p->n-n, &subtype);
         if( sz==0 ) return SQLITE4_CORRUPT;
         n += sz;
      }
      size = (type-22)/3;
    }else if( type<=2 ){
      size = 0;
    }else if( type<=10 ){
      size = type - 2;


    }else{

      size = type - 9;



    }
    if( i<iVal ){
      ofst += size;
    }else if( type==0 ){
      /* no-op */
    }else if( type<=2 ){
      sqlite4VdbeMemSetInt64(pOut, type-1);
................................................................................
      aAux[i].n = n;
      aOut[nOut++] = n+9;
      nPayload += n;
    }else if( flags & MEM_Str ){
      n = aIn[i].n;
      if( n && (encoding!=SQLITE4_UTF8 || aIn[i].z[0]<3) ) n++;
      nPayload += n;
      nOut += sqlite4PutVarint64(aOut+nOut, 22+3*(sqlite4_int64)n);
    }else{
      n = aIn[i].n;
      assert( flags & MEM_Blob );
      nPayload += n;
      nOut += sqlite4PutVarint64(aOut+nOut, 23+3*(sqlite4_int64)n);
    }
  }
  nHdr = nOut - 9;
  n = sqlite4PutVarint64(aOut, nHdr);
  for(i=n, j=9; j<nOut; j++) aOut[i++] = aOut[j];
  nOut = i;
  aOut = sqlite4DbReallocOrFree(db, aOut, nOut + nPayload);







|
|





|




>
>

>
|
>
>
>







 







|




|







87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
...
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
  ofst += n;
  endHdr = ofst;
  if( endHdr>p->n ) return SQLITE4_CORRUPT;
  for(i=0; i<=iVal && n<endHdr; i++){
    sz = sqlite4GetVarint64(p->a+n, p->n-n, &type);
    if( sz==0 ) return SQLITE4_CORRUPT;
    n += sz;
    if( type>=24 ){
      cclass = (type-24)%3;
      if( cclass==2 ){
         sz = sqlite4GetVarint64(p->a+n, p->n-n, &subtype);
         if( sz==0 ) return SQLITE4_CORRUPT;
         n += sz;
      }
      size = (type-24)/3;
    }else if( type<=2 ){
      size = 0;
    }else if( type<=10 ){
      size = type - 2;
    }else if( type<=22 ){
      size = type - 9;
    }else{
      /* value in key */
      size = 0;
      sz = sqlite4GetVarint64(p->a+n, p->n-n, &subtype);
      if( sz==0 ) return SQLITE4_CORRUPT;
      n += sz;
    }
    if( i<iVal ){
      ofst += size;
    }else if( type==0 ){
      /* no-op */
    }else if( type<=2 ){
      sqlite4VdbeMemSetInt64(pOut, type-1);
................................................................................
      aAux[i].n = n;
      aOut[nOut++] = n+9;
      nPayload += n;
    }else if( flags & MEM_Str ){
      n = aIn[i].n;
      if( n && (encoding!=SQLITE4_UTF8 || aIn[i].z[0]<3) ) n++;
      nPayload += n;
      nOut += sqlite4PutVarint64(aOut+nOut, 24+3*(sqlite4_int64)n);
    }else{
      n = aIn[i].n;
      assert( flags & MEM_Blob );
      nPayload += n;
      nOut += sqlite4PutVarint64(aOut+nOut, 25+3*(sqlite4_int64)n);
    }
  }
  nHdr = nOut - 9;
  n = sqlite4PutVarint64(aOut, nHdr);
  for(i=n, j=9; j<nOut; j++) aOut[i++] = aOut[j];
  nOut = i;
  aOut = sqlite4DbReallocOrFree(db, aOut, nOut + nPayload);

Changes to www/data_encoding.wiki.

16
17
18
19
20
21
22


23
24
25
26
27
28
29
30
31
32
..
54
55
56
57
58
59
60
61

<blockquote><table border=1 cellpadding=5>
<tr><td>  0       <td>   NULL
<tr><td>  1       <td>   zero
<tr><td>  2       <td>   one
<tr><td>  3..10   <td>   (N-2)-byte signed integer
<tr><td>  11..21  <td>   (N-9)-byte number (two varints: min 2, max 12 bytes)


<tr><td>  22+3*K  <td>   K-byte string
<tr><td>  23+3*K  <td>   K-byte inline blob
<tr><td>  24+3*K  <td>   K-byte typed blob, followed by a single varint type code
</table></blockquote>

Strings can be either UTF8, UTF16le, or UTF16be.  If the first byte of the
payload is 0x00, 0x01, or 0x02 then that byte is ignored and the remaining
bytes are UTF8, UTF16le, or UTF16be respectively.  If the first byte is 0x03
or larger, then the entire string including the first byte is UTF8.

................................................................................
Initially, the followed typed blobs are defined:

<blockquote><table border=0>
<tr><td>   0  <td>    external blob
<tr><td>   1  <td>    big int
<tr><td>   2  <td>    date/time
</table></blockquote>








>
>
|
|
|







 







<
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
..
56
57
58
59
60
61
62


<blockquote><table border=1 cellpadding=5>
<tr><td>  0       <td>   NULL
<tr><td>  1       <td>   zero
<tr><td>  2       <td>   one
<tr><td>  3..10   <td>   (N-2)-byte signed integer
<tr><td>  11..21  <td>   (N-9)-byte number (two varints: min 2, max 12 bytes)
<tr><td>  22      <td>   non-REAL value in key, followed by varint key offset
<tr><td>  23      <td>   REAL value in key, followed by varint key offset
<tr><td>  24+3*K  <td>   K-byte string
<tr><td>  25+3*K  <td>   K-byte inline blob
<tr><td>  26+3*K  <td>   K-byte typed blob, followed by a single varint type code
</table></blockquote>

Strings can be either UTF8, UTF16le, or UTF16be.  If the first byte of the
payload is 0x00, 0x01, or 0x02 then that byte is ignored and the remaining
bytes are UTF8, UTF16le, or UTF16be respectively.  If the first byte is 0x03
or larger, then the entire string including the first byte is UTF8.

................................................................................
Initially, the followed typed blobs are defined:

<blockquote><table border=0>
<tr><td>   0  <td>    external blob
<tr><td>   1  <td>    big int
<tr><td>   2  <td>    date/time
</table></blockquote>