diff options
Diffstat (limited to 'src/bitvec.c')
-rw-r--r-- | src/bitvec.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/bitvec.c b/src/bitvec.c index e91131500..976d2ce82 100644 --- a/src/bitvec.c +++ b/src/bitvec.c @@ -12,12 +12,14 @@ ** This file implements an object that represents a fixed-length ** bitmap. Bits are numbered starting with 1. ** -** A bitmap is used to record what pages a database file have been -** journalled during a transaction. Usually only a few pages are -** journalled. So the bitmap is usually sparse and has low cardinality. +** A bitmap is used to record which pages of a database file have been +** journalled during a transaction, or which pages have the "dont-write" +** property. Usually only a few pages are meet either condition. +** So the bitmap is usually sparse and has low cardinality. ** But sometimes (for example when during a DROP of a large table) most -** or all of the pages get journalled. In those cases, the bitmap becomes -** dense. The algorithm needs to handle both cases well. +** or all of the pages in a database can get journalled. In those cases, +** the bitmap becomes dense with high cardinality. The algorithm needs +** to handle both cases well. ** ** The size of the bitmap is fixed when the object is created. ** @@ -32,7 +34,7 @@ ** start of a transaction, and is thus usually less than a few thousand, ** but can be as large as 2 billion for a really big database. ** -** @(#) $Id: bitvec.c,v 1.6 2008/06/20 14:59:51 danielk1977 Exp $ +** @(#) $Id: bitvec.c,v 1.7 2008/11/03 20:55:07 drh Exp $ */ #include "sqliteInt.h" @@ -125,6 +127,14 @@ int sqlite3BitvecTest(Bitvec *p, u32 i){ /* ** Set the i-th bit. Return 0 on success and an error code if ** anything goes wrong. +** +** This routine might cause sub-bitmaps to be allocated. Failing +** to get the memory needed to hold the sub-bitmap is the only +** that can go wrong with an insert, assuming p and i are valid. +** +** The calling function must ensure that p is a valid Bitvec object +** and that the value for "i" is within range of the Bitvec object. +** Otherwise the behavior is undefined. */ int sqlite3BitvecSet(Bitvec *p, u32 i){ u32 h; |