1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

Merge latest changes from the trunk into the sessions branch.

FossilOrigin-Name: c00e45ede7cbf71a3a6d1ccad0b9275010ca8493
This commit is contained in:
dan
2011-09-14 19:41:44 +00:00
42 changed files with 931 additions and 572 deletions

View File

@ -2066,7 +2066,37 @@ static int fts3DoclistOrMerge(
*paOut = 0;
*pnOut = 0;
aOut = sqlite3_malloc(n1+n2);
/* Allocate space for the output. Both the input and output doclists
** are delta encoded. If they are in ascending order (bDescDoclist==0),
** then the first docid in each list is simply encoded as a varint. For
** each subsequent docid, the varint stored is the difference between the
** current and previous docid (a positive number - since the list is in
** ascending order).
**
** The first docid written to the output is therefore encoded using the
** same number of bytes as it is in whichever of the input lists it is
** read from. And each subsequent docid read from the same input list
** consumes either the same or less bytes as it did in the input (since
** the difference between it and the previous value in the output must
** be a positive value less than or equal to the delta value read from
** the input list). The same argument applies to all but the first docid
** read from the 'other' list. And to the contents of all position lists
** that will be copied and merged from the input to the output.
**
** However, if the first docid copied to the output is a negative number,
** then the encoding of the first docid from the 'other' input list may
** be larger in the output than it was in the input (since the delta value
** may be a larger positive integer than the actual docid).
**
** The space required to store the output is therefore the sum of the
** sizes of the two inputs, plus enough space for exactly one of the input
** docids to grow.
**
** A symetric argument may be made if the doclists are in descending
** order.
*/
aOut = sqlite3_malloc(n1+n2+FTS3_VARINT_MAX-1);
if( !aOut ) return SQLITE_NOMEM;
p = aOut;
@ -2093,6 +2123,7 @@ static int fts3DoclistOrMerge(
*paOut = aOut;
*pnOut = (p-aOut);
assert( *pnOut<=n1+n2+FTS3_VARINT_MAX-1 );
return SQLITE_OK;
}