mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-12 13:01:09 +03:00
Code simplifications and comment improvements in support of structural
coverage testing. (CVS 6899) FossilOrigin-Name: 945251798144110787b197f9eb552a2dd4a25cb4
This commit is contained in:
28
src/pcache.c
28
src/pcache.c
@@ -11,7 +11,7 @@
|
||||
*************************************************************************
|
||||
** This file implements that page cache.
|
||||
**
|
||||
** @(#) $Id: pcache.c,v 1.44 2009/03/31 01:32:18 drh Exp $
|
||||
** @(#) $Id: pcache.c,v 1.45 2009/07/16 18:21:18 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
|
||||
@@ -470,24 +470,22 @@ static PgHdr *pcacheMergeDirtyList(PgHdr *pA, PgHdr *pB){
|
||||
** Sort the list of pages in accending order by pgno. Pages are
|
||||
** connected by pDirty pointers. The pDirtyPrev pointers are
|
||||
** corrupted by this sort.
|
||||
**
|
||||
** Since there cannot be more than 2^31 distinct pages in a database,
|
||||
** there cannot be more than 31 buckets required by the merge sorter.
|
||||
** One extra bucket is added to catch overflow in case something
|
||||
** ever changes to make the previous sentence incorrect.
|
||||
*/
|
||||
#define N_SORT_BUCKET_ALLOC 25
|
||||
#define N_SORT_BUCKET 25
|
||||
#ifdef SQLITE_TEST
|
||||
int sqlite3_pager_n_sort_bucket = 0;
|
||||
#undef N_SORT_BUCKET
|
||||
#define N_SORT_BUCKET \
|
||||
(sqlite3_pager_n_sort_bucket?sqlite3_pager_n_sort_bucket:N_SORT_BUCKET_ALLOC)
|
||||
#endif
|
||||
#define N_SORT_BUCKET 32
|
||||
static PgHdr *pcacheSortDirtyList(PgHdr *pIn){
|
||||
PgHdr *a[N_SORT_BUCKET_ALLOC], *p;
|
||||
PgHdr *a[N_SORT_BUCKET], *p;
|
||||
int i;
|
||||
memset(a, 0, sizeof(a));
|
||||
while( pIn ){
|
||||
p = pIn;
|
||||
pIn = p->pDirty;
|
||||
p->pDirty = 0;
|
||||
for(i=0; i<N_SORT_BUCKET-1; i++){
|
||||
for(i=0; ALWAYS(i<N_SORT_BUCKET-1); i++){
|
||||
if( a[i]==0 ){
|
||||
a[i] = p;
|
||||
break;
|
||||
@@ -496,11 +494,9 @@ static PgHdr *pcacheSortDirtyList(PgHdr *pIn){
|
||||
a[i] = 0;
|
||||
}
|
||||
}
|
||||
if( i==N_SORT_BUCKET-1 ){
|
||||
/* Coverage: To get here, there need to be 2^(N_SORT_BUCKET)
|
||||
** elements in the input list. This is possible, but impractical.
|
||||
** Testing this line is the point of global variable
|
||||
** sqlite3_pager_n_sort_bucket.
|
||||
if( NEVER(i==N_SORT_BUCKET-1) ){
|
||||
/* To get here, there need to be 2^(N_SORT_BUCKET) elements in
|
||||
** the input list. But that is impossible.
|
||||
*/
|
||||
a[i] = pcacheMergeDirtyList(a[i], p);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user