OpenCoverage

pcache.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/sqlite/src/src/pcache.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/*-
2** 2008 August 05-
3**-
4** The author disclaims copyright to this source code. In place of-
5** a legal notice, here is a blessing:-
6**-
7** May you do good and not evil.-
8** May you find forgiveness for yourself and forgive others.-
9** May you share freely, never taking more than you give.-
10**-
11*************************************************************************-
12** This file implements that page cache.-
13*/-
14#include "sqliteInt.h"-
15-
16/*-
17** A complete page cache is an instance of this structure. Every-
18** entry in the cache holds a single page of the database file. The-
19** btree layer only operates on the cached copy of the database pages.-
20**-
21** A page cache entry is "clean" if it exactly matches what is currently-
22** on disk. A page is "dirty" if it has been modified and needs to be-
23** persisted to disk.-
24**-
25** pDirty, pDirtyTail, pSynced:-
26** All dirty pages are linked into the doubly linked list using-
27** PgHdr.pDirtyNext and pDirtyPrev. The list is maintained in LRU order-
28** such that p was added to the list more recently than p->pDirtyNext.-
29** PCache.pDirty points to the first (newest) element in the list and-
30** pDirtyTail to the last (oldest).-
31**-
32** The PCache.pSynced variable is used to optimize searching for a dirty-
33** page to eject from the cache mid-transaction. It is better to eject-
34** a page that does not require a journal sync than one that does. -
35** Therefore, pSynced is maintained so that it *almost* always points-
36** to either the oldest page in the pDirty/pDirtyTail list that has a-
37** clear PGHDR_NEED_SYNC flag or to a page that is older than this one-
38** (so that the right page to eject can be found by following pDirtyPrev-
39** pointers).-
40*/-
41struct PCache {-
42 PgHdr *pDirty, *pDirtyTail; /* List of dirty pages in LRU order */-
43 PgHdr *pSynced; /* Last synced page in dirty page list */-
44 int nRefSum; /* Sum of ref counts over all pages */-
45 int szCache; /* Configured cache size */-
46 int szSpill; /* Size before spilling occurs */-
47 int szPage; /* Size of every page in this cache */-
48 int szExtra; /* Size of extra space for each page */-
49 u8 bPurgeable; /* True if pages are on backing store */-
50 u8 eCreate; /* eCreate value for for xFetch() */-
51 int (*xStress)(void*,PgHdr*); /* Call to try make a page clean */-
52 void *pStress; /* Argument to xStress */-
53 sqlite3_pcache *pCache; /* Pluggable cache module */-
54};-
55-
56/********************************** Test and Debug Logic **********************/-
57/*-
58** Debug tracing macros. Enable by by changing the "0" to "1" and-
59** recompiling.-
60**-
61** When sqlite3PcacheTrace is 1, single line trace messages are issued.-
62** When sqlite3PcacheTrace is 2, a dump of the pcache showing all cache entries-
63** is displayed for many operations, resulting in a lot of output.-
64*/-
65#if defined(SQLITE_DEBUG) && 0-
66 int sqlite3PcacheTrace = 2; /* 0: off 1: simple 2: cache dumps */-
67 int sqlite3PcacheMxDump = 9999; /* Max cache entries for pcacheDump() */-
68# define pcacheTrace(X) if(sqlite3PcacheTrace){sqlite3DebugPrintf X;}-
69 void pcacheDump(PCache *pCache){-
70 int N;-
71 int i, j;-
72 sqlite3_pcache_page *pLower;-
73 PgHdr *pPg;-
74 unsigned char *a;-
75 -
76 if( sqlite3PcacheTrace<2 ) return;-
77 if( pCache->pCache==0 ) return;-
78 N = sqlite3PcachePagecount(pCache);-
79 if( N>sqlite3PcacheMxDump ) N = sqlite3PcacheMxDump;-
80 for(i=1; i<=N; i++){-
81 pLower = sqlite3GlobalConfig.pcache2.xFetch(pCache->pCache, i, 0);-
82 if( pLower==0 ) continue;-
83 pPg = (PgHdr*)pLower->pExtra;-
84 printf("%3d: nRef %2d flgs %02x data ", i, pPg->nRef, pPg->flags);-
85 a = (unsigned char *)pLower->pBuf;-
86 for(j=0; j<12; j++) printf("%02x", a[j]);-
87 printf("\n");-
88 if( pPg->pPage==0 ){-
89 sqlite3GlobalConfig.pcache2.xUnpin(pCache->pCache, pLower, 0);-
90 }-
91 }-
92 }-
93 #else-
94# define pcacheTrace(X)-
95# define pcacheDump(X)-
96#endif-
97-
98/*-
99** Check invariants on a PgHdr entry. Return true if everything is OK.-
100** Return false if any invariant is violated.-
101**-
102** This routine is for use inside of assert() statements only. For-
103** example:-
104**-
105** assert( sqlite3PcachePageSanity(pPg) );-
106*/-
107#ifdef SQLITE_DEBUG-
108int sqlite3PcachePageSanity(PgHdr *pPg){-
109 PCache *pCache;-
110 assert( pPg!=0 );-
111 assert( pPg->pgno>0 || pPg->pPager==0 ); /* Page number is 1 or more */-
112 pCache = pPg->pCache;-
113 assert( pCache!=0 ); /* Every page has an associated PCache */-
114 if( pPg->flags & PGHDR_CLEAN ){-
115 assert( (pPg->flags & PGHDR_DIRTY)==0 );/* Cannot be both CLEAN and DIRTY */-
116 assert( pCache->pDirty!=pPg ); /* CLEAN pages not on dirty list */-
117 assert( pCache->pDirtyTail!=pPg );-
118 }-
119 /* WRITEABLE pages must also be DIRTY */-
120 if( pPg->flags & PGHDR_WRITEABLE ){-
121 assert( pPg->flags & PGHDR_DIRTY ); /* WRITEABLE implies DIRTY */-
122 }-
123 /* NEED_SYNC can be set independently of WRITEABLE. This can happen,-
124 ** for example, when using the sqlite3PagerDontWrite() optimization:-
125 ** (1) Page X is journalled, and gets WRITEABLE and NEED_SEEK.-
126 ** (2) Page X moved to freelist, WRITEABLE is cleared-
127 ** (3) Page X reused, WRITEABLE is set again-
128 ** If NEED_SYNC had been cleared in step 2, then it would not be reset-
129 ** in step 3, and page might be written into the database without first-
130 ** syncing the rollback journal, which might cause corruption on a power-
131 ** loss.-
132 **-
133 ** Another example is when the database page size is smaller than the-
134 ** disk sector size. When any page of a sector is journalled, all pages-
135 ** in that sector are marked NEED_SYNC even if they are still CLEAN, just-
136 ** in case they are later modified, since all pages in the same sector-
137 ** must be journalled and synced before any of those pages can be safely-
138 ** written.-
139 */-
140 return 1;-
141}-
142#endif /* SQLITE_DEBUG */-
143-
144-
145/********************************** Linked List Management ********************/-
146-
147/* Allowed values for second argument to pcacheManageDirtyList() */-
148#define PCACHE_DIRTYLIST_REMOVE 1 /* Remove pPage from dirty list */-
149#define PCACHE_DIRTYLIST_ADD 2 /* Add pPage to the dirty list */-
150#define PCACHE_DIRTYLIST_FRONT 3 /* Move pPage to the front of the list */-
151-
152/*-
153** Manage pPage's participation on the dirty list. Bits of the addRemove-
154** argument determines what operation to do. The 0x01 bit means first-
155** remove pPage from the dirty list. The 0x02 means add pPage back to-
156** the dirty list. Doing both moves pPage to the front of the dirty list.-
157*/-
158static void pcacheManageDirtyList(PgHdr *pPage, u8 addRemove){-
159 PCache *p = pPage->pCache;-
160-
161 pcacheTrace(("%p.DIRTYLIST.%s %d\n", p,-
162 addRemove==1 ? "REMOVE" : addRemove==2 ? "ADD" : "FRONT",-
163 pPage->pgno));-
164 if( addRemove & PCACHE_DIRTYLIST_REMOVE ){
addRemove & 1Description
TRUEevaluated 14089472 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (11)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • Self test (128)
  • Self test (129)
  • Self test (13)
  • Self test (130)
  • Self test (131)
  • ...
FALSEevaluated 2010671 times by 403 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • ...
2010671-14089472
165 assert( pPage->pDirtyNext || pPage==p->pDirtyTail );-
166 assert( pPage->pDirtyPrev || pPage==p->pDirty );-
167 -
168 /* Update the PCache1.pSynced variable if necessary. */-
169 if( p->pSynced==pPage ){
p->pSynced==pPageDescription
TRUEevaluated 1918910 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (11)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • Self test (128)
  • Self test (129)
  • Self test (13)
  • Self test (130)
  • Self test (131)
  • ...
FALSEevaluated 12170562 times by 386 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (11)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • Self test (128)
  • Self test (129)
  • Self test (13)
  • Self test (130)
  • Self test (131)
  • Self test (132)
  • ...
1918910-12170562
170 p->pSynced = pPage->pDirtyPrev;-
171 }
executed 1918910 times by 394 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (11)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • Self test (128)
  • Self test (129)
  • Self test (13)
  • Self test (130)
  • Self test (131)
  • ...
1918910
172 -
173 if( pPage->pDirtyNext ){
pPage->pDirtyNextDescription
TRUEevaluated 13770115 times by 385 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (11)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • Self test (128)
  • Self test (129)
  • Self test (13)
  • Self test (130)
  • Self test (131)
  • Self test (132)
  • ...
FALSEevaluated 319357 times by 393 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (11)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • Self test (128)
  • Self test (129)
  • Self test (13)
  • Self test (130)
  • Self test (131)
  • ...
319357-13770115
174 pPage->pDirtyNext->pDirtyPrev = pPage->pDirtyPrev;-
175 }else{
executed 13770115 times by 385 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (11)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • Self test (128)
  • Self test (129)
  • Self test (13)
  • Self test (130)
  • Self test (131)
  • Self test (132)
  • ...
13770115
176 assert( pPage==p->pDirtyTail );-
177 p->pDirtyTail = pPage->pDirtyPrev;-
178 }
executed 319357 times by 393 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (11)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • Self test (128)
  • Self test (129)
  • Self test (13)
  • Self test (130)
  • Self test (131)
  • ...
319357
179 if( pPage->pDirtyPrev ){
pPage->pDirtyPrevDescription
TRUEevaluated 11848552 times by 366 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (11)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • Self test (128)
  • Self test (129)
  • Self test (13)
  • Self test (130)
  • Self test (131)
  • Self test (132)
  • Self test (133)
  • ...
FALSEevaluated 2240920 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (11)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • Self test (128)
  • Self test (129)
  • Self test (13)
  • Self test (130)
  • Self test (131)
  • ...
2240920-11848552
180 pPage->pDirtyPrev->pDirtyNext = pPage->pDirtyNext;-
181 }else{
executed 11848552 times by 366 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (11)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • Self test (128)
  • Self test (129)
  • Self test (13)
  • Self test (130)
  • Self test (131)
  • Self test (132)
  • Self test (133)
  • ...
11848552
182 /* If there are now no dirty pages in the cache, set eCreate to 2. -
183 ** This is an optimization that allows sqlite3PcacheFetch() to skip-
184 ** searching for a dirty page to eject from the cache when it might-
185 ** otherwise have to. */-
186 assert( pPage==p->pDirty );-
187 p->pDirty = pPage->pDirtyNext;-
188 assert( p->bPurgeable || p->eCreate==2 );-
189 if( p->pDirty==0 ){ /*OPTIMIZATION-IF-TRUE*/
p->pDirty==0Description
TRUEevaluated 265324 times by 71 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (11)
  • Self test (12)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • ...
FALSEevaluated 1975596 times by 385 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (11)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • Self test (128)
  • Self test (129)
  • Self test (13)
  • Self test (130)
  • Self test (131)
  • Self test (132)
  • ...
265324-1975596
190 assert( p->bPurgeable==0 || p->eCreate==1 );-
191 p->eCreate = 2;-
192 }
executed 265324 times by 71 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (11)
  • Self test (12)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • ...
265324
193 }
executed 2240920 times by 394 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (11)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • Self test (128)
  • Self test (129)
  • Self test (13)
  • Self test (130)
  • Self test (131)
  • ...
2240920
194 }-
195 if( addRemove & PCACHE_DIRTYLIST_ADD ){
addRemove & 2Description
TRUEevaluated 14106917 times by 403 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • ...
FALSEevaluated 1993226 times by 73 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (11)
  • Self test (12)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (20)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • ...
1993226-14106917
196 pPage->pDirtyPrev = 0;-
197 pPage->pDirtyNext = p->pDirty;-
198 if( pPage->pDirtyNext ){
pPage->pDirtyNextDescription
TRUEevaluated 13841255 times by 391 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • ...
FALSEevaluated 265662 times by 403 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • ...
265662-13841255
199 assert( pPage->pDirtyNext->pDirtyPrev==0 );-
200 pPage->pDirtyNext->pDirtyPrev = pPage;-
201 }else{
executed 13841255 times by 391 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • ...
13841255
202 p->pDirtyTail = pPage;-
203 if( p->bPurgeable ){
p->bPurgeableDescription
TRUEevaluated 264171 times by 403 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • ...
FALSEevaluated 1491 times by 1 test
Evaluated by:
  • Self test (438)
1491-264171
204 assert( p->eCreate==2 );-
205 p->eCreate = 1;-
206 }
executed 264171 times by 403 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • ...
264171
207 }
executed 265662 times by 403 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • ...
265662
208 p->pDirty = pPage;-
209-
210 /* If pSynced is NULL and this page has a clear NEED_SYNC flag, set-
211 ** pSynced to point to it. Checking the NEED_SYNC flag is an -
212 ** optimization, as if pSynced points to a page with the NEED_SYNC-
213 ** flag set sqlite3PcacheFetchStress() searches through all newer -
214 ** entries of the dirty-list for a page with NEED_SYNC clear anyway. */-
215 if( !p->pSynced
!p->pSyncedDescription
TRUEevaluated 532480 times by 403 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • ...
FALSEevaluated 13574437 times by 385 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • ...
532480-13574437
216 && 0==(pPage->flags&PGHDR_NEED_SYNC) /*OPTIMIZATION-IF-FALSE*/
0==(pPage->flags&0x008)Description
TRUEevaluated 432281 times by 403 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • ...
FALSEevaluated 100199 times by 29 tests
Evaluated by:
  • Self test (10)
  • Self test (11)
  • Self test (12)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (20)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (3)
  • Self test (31)
  • Self test (38)
  • Self test (39)
  • Self test (40)
  • Self test (438)
  • Self test (47)
  • Self test (52)
  • Self test (54)
  • Self test (55)
  • ...
100199-432281
217 ){-
218 p->pSynced = pPage;-
219 }
executed 432281 times by 403 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • ...
432281
220 }
executed 14106917 times by 403 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • ...
14106917
221 pcacheDump(p);-
222}
executed 16100143 times by 403 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • ...
16100143
223-
224/*-
225** Wrapper around the pluggable caches xUnpin method. If the cache is-
226** being used for an in-memory database, this function is a no-op.-
227*/-
228static void pcacheUnpin(PgHdr *p){-
229 if( p->pCache->bPurgeable ){
p->pCache->bPurgeableDescription
TRUEevaluated 12134310 times by 435 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 31628 times by 1 test
Evaluated by:
  • Self test (438)
31628-12134310
230 pcacheTrace(("%p.UNPIN %d\n", p->pCache, p->pgno));-
231 sqlite3GlobalConfig.pcache2.xUnpin(p->pCache->pCache, p->pPage, 0);-
232 pcacheDump(p->pCache);-
233 }
executed 12134310 times by 435 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
12134310
234}
executed 12165938 times by 435 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
12165938
235-
236/*-
237** Compute the number of pages of cache requested. p->szCache is the-
238** cache size requested by the "PRAGMA cache_size" statement.-
239*/-
240static int numberOfCachePages(PCache *p){-
241 if( p->szCache>=0 ){
p->szCache>=0Description
TRUEevaluated 96550 times by 438 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (102)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • ...
FALSEevaluated 118161 times by 438 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (102)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • ...
96550-118161
242 /* IMPLEMENTATION-OF: R-42059-47211 If the argument N is positive then the-
243 ** suggested cache size is set to N. */-
244 return p->szCache;
executed 96550 times by 438 tests: return p->szCache;
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (102)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • ...
96550
245 }else{-
246 /* IMPLEMENTATION-OF: R-61436-13639 If the argument N is negative, then-
247 ** the number of cache pages is adjusted to use approximately abs(N*1024)-
248 ** bytes of memory. */-
249 return (int)((-1024*(i64)p->szCache)/(p->szPage+p->szExtra));
executed 118161 times by 438 tests: return (int)((-1024*(i64)p->szCache)/(p->szPage+p->szExtra));
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (102)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • ...
118161
250 }-
251}-
252-
253/*************************************************** General Interfaces ******-
254**-
255** Initialize and shutdown the page cache subsystem. Neither of these -
256** functions are threadsafe.-
257*/-
258int sqlite3PcacheInitialize(void){-
259 if( sqlite3GlobalConfig.pcache2.xInit==0 ){
sqlite3Config.pcache2.xInit==0Description
TRUEevaluated 438 times by 438 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (102)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • ...
FALSEevaluated 94 times by 5 tests
Evaluated by:
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (438)
94-438
260 /* IMPLEMENTATION-OF: R-26801-64137 If the xInit() method is NULL, then the-
261 ** built-in default page cache is used instead of the application defined-
262 ** page cache. */-
263 sqlite3PCacheSetDefault();-
264 }
executed 438 times by 438 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (102)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • ...
438
265 return sqlite3GlobalConfig.pcache2.xInit(sqlite3GlobalConfig.pcache2.pArg);
executed 532 times by 438 tests: return sqlite3Config.pcache2.xInit(sqlite3Config.pcache2.pArg);
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (102)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • ...
532
266}-
267void sqlite3PcacheShutdown(void){-
268 if( sqlite3GlobalConfig.pcache2.xShutdown ){
sqlite3Config....che2.xShutdownDescription
TRUEevaluated 93 times by 6 tests
Evaluated by:
  • Self test (101)
  • Self test (102)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (438)
FALSEnever evaluated
0-93
269 /* IMPLEMENTATION-OF: R-26000-56589 The xShutdown() method may be NULL. */-
270 sqlite3GlobalConfig.pcache2.xShutdown(sqlite3GlobalConfig.pcache2.pArg);-
271 }
executed 93 times by 6 tests: end of block
Executed by:
  • Self test (101)
  • Self test (102)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (438)
93
272}
executed 93 times by 6 tests: end of block
Executed by:
  • Self test (101)
  • Self test (102)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (438)
93
273-
274/*-
275** Return the size in bytes of a PCache object.-
276*/-
277int sqlite3PcacheSize(void){ return sizeof(PCache); }
executed 96308 times by 438 tests: return sizeof(PCache);
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (102)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • ...
96308
278-
279/*-
280** Create a new PCache object. Storage space to hold the object-
281** has already been allocated and is passed in as the p pointer. -
282** The caller discovers how much space needs to be allocated by -
283** calling sqlite3PcacheSize().-
284**-
285** szExtra is some extra space allocated for each page. The first-
286** 8 bytes of the extra space will be zeroed as the page is allocated,-
287** but remaining content will be uninitialized. Though it is opaque-
288** to this module, the extra space really ends up being the MemPage-
289** structure in the pager.-
290*/-
291int sqlite3PcacheOpen(-
292 int szPage, /* Size of every page */-
293 int szExtra, /* Extra space associated with each page */-
294 int bPurgeable, /* True if pages are on backing store */-
295 int (*xStress)(void*,PgHdr*),/* Call to try to make pages clean */-
296 void *pStress, /* Argument to xStress */-
297 PCache *p /* Preallocated space for the PCache */-
298){-
299 memset(p, 0, sizeof(PCache));-
300 p->szPage = 1;-
301 p->szExtra = szExtra;-
302 assert( szExtra>=8 ); /* First 8 bytes will be zeroed */-
303 p->bPurgeable = bPurgeable;-
304 p->eCreate = 2;-
305 p->xStress = xStress;-
306 p->pStress = pStress;-
307 p->szCache = 100;-
308 p->szSpill = 1;-
309 pcacheTrace(("%p.OPEN szPage %d bPurgeable %d\n",p,szPage,bPurgeable));-
310 return sqlite3PcacheSetPageSize(p, szPage);
executed 95688 times by 438 tests: return sqlite3PcacheSetPageSize(p, szPage);
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (102)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • ...
95688
311}-
312-
313/*-
314** Change the page size for PCache object. The caller must ensure that there-
315** are no outstanding page references when this function is called.-
316*/-
317int sqlite3PcacheSetPageSize(PCache *pCache, int szPage){-
318 assert( pCache->nRefSum==0 && pCache->pDirty==0 );-
319 if( pCache->szPage ){
pCache->szPageDescription
TRUEevaluated 96091 times by 438 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (102)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • ...
FALSEevaluated 95688 times by 438 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (102)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • ...
95688-96091
320 sqlite3_pcache *pNew;-
321 pNew = sqlite3GlobalConfig.pcache2.xCreate(-
322 szPage, pCache->szExtra + ROUND8(sizeof(PgHdr)),-
323 pCache->bPurgeable-
324 );-
325 if( pNew==0 ) return SQLITE_NOMEM_BKPT;
executed 28 times by 1 test: return 7;
Executed by:
  • Self test (438)
pNew==0Description
TRUEevaluated 28 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 96063 times by 438 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (102)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • ...
28-96063
326 sqlite3GlobalConfig.pcache2.xCachesize(pNew, numberOfCachePages(pCache));-
327 if( pCache->pCache ){
pCache->pCacheDescription
TRUEevaluated 403 times by 40 tests
Evaluated by:
  • Self test (10)
  • Self test (100)
  • Self test (11)
  • Self test (12)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (20)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (3)
  • Self test (4)
  • Self test (41)
  • Self test (438)
  • Self test (5)
  • Self test (6)
  • Self test (65)
  • Self test (67)
  • Self test (68)
  • ...
FALSEevaluated 95660 times by 438 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (102)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • ...
403-95660
328 sqlite3GlobalConfig.pcache2.xDestroy(pCache->pCache);-
329 }
executed 403 times by 40 tests: end of block
Executed by:
  • Self test (10)
  • Self test (100)
  • Self test (11)
  • Self test (12)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (20)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (3)
  • Self test (4)
  • Self test (41)
  • Self test (438)
  • Self test (5)
  • Self test (6)
  • Self test (65)
  • Self test (67)
  • Self test (68)
  • ...
403
330 pCache->pCache = pNew;-
331 pCache->szPage = szPage;-
332 pcacheTrace(("%p.PAGESIZE %d\n",pCache,szPage));-
333 }
executed 96063 times by 438 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (102)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • ...
96063
334 return SQLITE_OK;
executed 191751 times by 438 tests: return 0;
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (102)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • ...
191751
335}-
336-
337/*-
338** Try to obtain a page from the cache.-
339**-
340** This routine returns a pointer to an sqlite3_pcache_page object if-
341** such an object is already in cache, or if a new one is created.-
342** This routine returns a NULL pointer if the object was not in cache-
343** and could not be created.-
344**-
345** The createFlags should be 0 to check for existing pages and should-
346** be 3 (not 1, but 3) to try to create a new page.-
347**-
348** If the createFlag is 0, then NULL is always returned if the page-
349** is not already in the cache. If createFlag is 1, then a new page-
350** is created only if that can be done without spilling dirty pages-
351** and without exceeding the cache size limit.-
352**-
353** The caller needs to invoke sqlite3PcacheFetchFinish() to properly-
354** initialize the sqlite3_pcache_page object and convert it into a-
355** PgHdr object. The sqlite3PcacheFetch() and sqlite3PcacheFetchFinish()-
356** routines are split this way for performance reasons. When separated-
357** they can both (usually) operate without having to push values to-
358** the stack on entry and pop them back off on exit, which saves a-
359** lot of pushing and popping.-
360*/-
361sqlite3_pcache_page *sqlite3PcacheFetch(-
362 PCache *pCache, /* Obtain the page from this cache */-
363 Pgno pgno, /* Page number to obtain */-
364 int createFlag /* If true, create page if it does not exist already */-
365){-
366 int eCreate;-
367 sqlite3_pcache_page *pRes;-
368-
369 assert( pCache!=0 );-
370 assert( pCache->pCache!=0 );-
371 assert( createFlag==3 || createFlag==0 );-
372 assert( pCache->eCreate==((pCache->bPurgeable && pCache->pDirty) ? 1 : 2) );-
373-
374 /* eCreate defines what to do if the page does not exist.-
375 ** 0 Do not allocate a new page. (createFlag==0)-
376 ** 1 Allocate a new page if doing so is inexpensive.-
377 ** (createFlag==1 AND bPurgeable AND pDirty)-
378 ** 2 Allocate a new page even it doing so is difficult.-
379 ** (createFlag==1 AND !(bPurgeable AND pDirty)-
380 */-
381 eCreate = createFlag & pCache->eCreate;-
382 assert( eCreate==0 || eCreate==1 || eCreate==2 );-
383 assert( createFlag==0 || pCache->eCreate==eCreate );-
384 assert( createFlag==0 || eCreate==1+(!pCache->bPurgeable||!pCache->pDirty) );-
385 pRes = sqlite3GlobalConfig.pcache2.xFetch(pCache->pCache, pgno, eCreate);-
386 pcacheTrace(("%p.FETCH %d%s (result: %p)\n",pCache,pgno,-
387 createFlag?" create":"",pRes));-
388 return pRes;
executed 23615916 times by 435 tests: return pRes;
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
23615916
389}-
390-
391/*-
392** If the sqlite3PcacheFetch() routine is unable to allocate a new-
393** page because no clean pages are available for reuse and the cache-
394** size limit has been reached, then this routine can be invoked to -
395** try harder to allocate a page. This routine might invoke the stress-
396** callback to spill dirty pages to the journal. It will then try to-
397** allocate the new page and will only fail to allocate a new page on-
398** an OOM error.-
399**-
400** This routine should be invoked only after sqlite3PcacheFetch() fails.-
401*/-
402int sqlite3PcacheFetchStress(-
403 PCache *pCache, /* Obtain the page from this cache */-
404 Pgno pgno, /* Page number to obtain */-
405 sqlite3_pcache_page **ppPage /* Write result here */-
406){-
407 PgHdr *pPg;-
408 if( pCache->eCreate==2 ) return 0;
executed 8 times by 1 test: return 0;
Executed by:
  • Self test (438)
pCache->eCreate==2Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1489717 times by 27 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (101)
  • Self test (11)
  • Self test (12)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (20)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (3)
  • Self test (438)
  • Self test (54)
  • Self test (57)
  • Self test (58)
  • Self test (6)
  • Self test (64)
  • Self test (7)
  • ...
8-1489717
409-
410 if( sqlite3PcachePagecount(pCache)>pCache->szSpill ){
sqlite3PcacheP...Cache->szSpillDescription
TRUEevaluated 1423394 times by 27 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (101)
  • Self test (11)
  • Self test (12)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (20)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (3)
  • Self test (438)
  • Self test (54)
  • Self test (57)
  • Self test (58)
  • Self test (6)
  • Self test (64)
  • Self test (7)
  • ...
FALSEevaluated 66323 times by 1 test
Evaluated by:
  • Self test (438)
66323-1423394
411 /* Find a dirty page to write-out and recycle. First try to find a -
412 ** page that does not require a journal-sync (one with PGHDR_NEED_SYNC-
413 ** cleared), but if that is not possible settle for any other -
414 ** unreferenced dirty page.-
415 **-
416 ** If the LRU page in the dirty list that has a clear PGHDR_NEED_SYNC-
417 ** flag is currently referenced, then the following may leave pSynced-
418 ** set incorrectly (pointing to other than the LRU page with NEED_SYNC-
419 ** cleared). This is Ok, as pSynced is just an optimization. */-
420 for(pPg=pCache->pSynced; -
421 pPg && (pPg->nRef || (pPg->flags&PGHDR_NEED_SYNC));
pPgDescription
TRUEevaluated 1906689 times by 27 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (101)
  • Self test (11)
  • Self test (12)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (20)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (3)
  • Self test (438)
  • Self test (54)
  • Self test (57)
  • Self test (58)
  • Self test (6)
  • Self test (64)
  • Self test (7)
  • ...
FALSEevaluated 107384 times by 25 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (11)
  • Self test (12)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (20)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (3)
  • Self test (438)
  • Self test (54)
  • Self test (57)
  • Self test (58)
  • Self test (6)
  • Self test (7)
  • Self test (8)
  • Self test (9)
pPg->nRefDescription
TRUEevaluated 376803 times by 27 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (101)
  • Self test (11)
  • Self test (12)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (20)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (3)
  • Self test (438)
  • Self test (54)
  • Self test (57)
  • Self test (58)
  • Self test (6)
  • Self test (64)
  • Self test (7)
  • ...
FALSEevaluated 1529886 times by 27 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (101)
  • Self test (11)
  • Self test (12)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (20)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (3)
  • Self test (438)
  • Self test (54)
  • Self test (57)
  • Self test (58)
  • Self test (6)
  • Self test (64)
  • Self test (7)
  • ...
(pPg->flags&0x008)Description
TRUEevaluated 213876 times by 25 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (11)
  • Self test (12)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (20)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (3)
  • Self test (438)
  • Self test (54)
  • Self test (57)
  • Self test (58)
  • Self test (6)
  • Self test (7)
  • Self test (8)
  • Self test (9)
FALSEevaluated 1316010 times by 21 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (101)
  • Self test (12)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (18)
  • Self test (2)
  • Self test (20)
  • Self test (22)
  • Self test (23)
  • Self test (3)
  • Self test (438)
  • Self test (54)
  • Self test (57)
  • Self test (58)
  • Self test (6)
  • Self test (64)
  • Self test (7)
  • Self test (8)
107384-1906689
422 pPg=pPg->pDirtyPrev-
423 );
executed 590679 times by 27 tests: ;
Executed by:
  • Self test
  • Self test (10)
  • Self test (101)
  • Self test (11)
  • Self test (12)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (20)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (3)
  • Self test (438)
  • Self test (54)
  • Self test (57)
  • Self test (58)
  • Self test (6)
  • Self test (64)
  • Self test (7)
  • ...
590679
424 pCache->pSynced = pPg;-
425 if( !pPg ){
!pPgDescription
TRUEevaluated 107384 times by 25 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (11)
  • Self test (12)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (20)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (3)
  • Self test (438)
  • Self test (54)
  • Self test (57)
  • Self test (58)
  • Self test (6)
  • Self test (7)
  • Self test (8)
  • Self test (9)
FALSEevaluated 1316010 times by 21 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (101)
  • Self test (12)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (18)
  • Self test (2)
  • Self test (20)
  • Self test (22)
  • Self test (23)
  • Self test (3)
  • Self test (438)
  • Self test (54)
  • Self test (57)
  • Self test (58)
  • Self test (6)
  • Self test (64)
  • Self test (7)
  • Self test (8)
107384-1316010
426 for(pPg=pCache->pDirtyTail; pPg && pPg->nRef; pPg=pPg->pDirtyPrev);
executed 436347 times by 25 tests: ;
Executed by:
  • Self test
  • Self test (10)
  • Self test (11)
  • Self test (12)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (20)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (3)
  • Self test (438)
  • Self test (54)
  • Self test (57)
  • Self test (58)
  • Self test (6)
  • Self test (7)
  • Self test (8)
  • Self test (9)
pPgDescription
TRUEevaluated 472602 times by 25 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (11)
  • Self test (12)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (20)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (3)
  • Self test (438)
  • Self test (54)
  • Self test (57)
  • Self test (58)
  • Self test (6)
  • Self test (7)
  • Self test (8)
  • Self test (9)
FALSEevaluated 71129 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (54)
pPg->nRefDescription
TRUEevaluated 436347 times by 25 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (11)
  • Self test (12)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (20)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (3)
  • Self test (438)
  • Self test (54)
  • Self test (57)
  • Self test (58)
  • Self test (6)
  • Self test (7)
  • Self test (8)
  • Self test (9)
FALSEevaluated 36255 times by 25 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (11)
  • Self test (12)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (20)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (3)
  • Self test (438)
  • Self test (54)
  • Self test (57)
  • Self test (58)
  • Self test (6)
  • Self test (7)
  • Self test (8)
  • Self test (9)
36255-472602
427 }
executed 107384 times by 25 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (11)
  • Self test (12)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (20)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (3)
  • Self test (438)
  • Self test (54)
  • Self test (57)
  • Self test (58)
  • Self test (6)
  • Self test (7)
  • Self test (8)
  • Self test (9)
107384
428 if( pPg ){
pPgDescription
TRUEevaluated 1352265 times by 27 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (101)
  • Self test (11)
  • Self test (12)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (20)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (3)
  • Self test (438)
  • Self test (54)
  • Self test (57)
  • Self test (58)
  • Self test (6)
  • Self test (64)
  • Self test (7)
  • ...
FALSEevaluated 71129 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (54)
71129-1352265
429 int rc;-
430#ifdef SQLITE_LOG_CACHE_SPILL-
431 sqlite3_log(SQLITE_FULL, -
432 "spill page %d making room for %d - cache used: %d/%d",-
433 pPg->pgno, pgno,-
434 sqlite3GlobalConfig.pcache2.xPagecount(pCache->pCache),-
435 numberOfCachePages(pCache));-
436#endif-
437 pcacheTrace(("%p.SPILL %d\n",pCache,pPg->pgno));-
438 rc = pCache->xStress(pCache->pStress, pPg);-
439 pcacheDump(pCache);-
440 if( rc!=SQLITE_OK && rc!=SQLITE_BUSY ){
rc!=0Description
TRUEevaluated 1816 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1350449 times by 27 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (101)
  • Self test (11)
  • Self test (12)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (20)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (3)
  • Self test (438)
  • Self test (54)
  • Self test (57)
  • Self test (58)
  • Self test (6)
  • Self test (64)
  • Self test (7)
  • ...
rc!=5Description
TRUEnever evaluated
FALSEevaluated 1816 times by 1 test
Evaluated by:
  • Self test (438)
0-1350449
441 return rc;
never executed: return rc;
0
442 }-
443 }
executed 1352265 times by 27 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (101)
  • Self test (11)
  • Self test (12)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (20)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (3)
  • Self test (438)
  • Self test (54)
  • Self test (57)
  • Self test (58)
  • Self test (6)
  • Self test (64)
  • Self test (7)
  • ...
1352265
444 }
executed 1423394 times by 27 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (101)
  • Self test (11)
  • Self test (12)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (20)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (3)
  • Self test (438)
  • Self test (54)
  • Self test (57)
  • Self test (58)
  • Self test (6)
  • Self test (64)
  • Self test (7)
  • ...
1423394
445 *ppPage = sqlite3GlobalConfig.pcache2.xFetch(pCache->pCache, pgno, 2);-
446 return *ppPage==0 ? SQLITE_NOMEM_BKPT : SQLITE_OK;
executed 1489717 times by 27 tests: return *ppPage==0 ? 7 : 0;
Executed by:
  • Self test
  • Self test (10)
  • Self test (101)
  • Self test (11)
  • Self test (12)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (20)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (3)
  • Self test (438)
  • Self test (54)
  • Self test (57)
  • Self test (58)
  • Self test (6)
  • Self test (64)
  • Self test (7)
  • ...
*ppPage==0Description
TRUEnever evaluated
FALSEevaluated 1489717 times by 27 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (101)
  • Self test (11)
  • Self test (12)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (20)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (3)
  • Self test (438)
  • Self test (54)
  • Self test (57)
  • Self test (58)
  • Self test (6)
  • Self test (64)
  • Self test (7)
  • ...
0-1489717
447}-
448-
449/*-
450** This is a helper routine for sqlite3PcacheFetchFinish()-
451**-
452** In the uncommon case where the page being fetched has not been-
453** initialized, this routine is invoked to do the initialization.-
454** This routine is broken out into a separate function since it-
455** requires extra stack manipulation that can be avoided in the common-
456** case.-
457*/-
458static SQLITE_NOINLINE PgHdr *pcacheFetchFinishWithInit(-
459 PCache *pCache, /* Obtain the page from this cache */-
460 Pgno pgno, /* Page number obtained */-
461 sqlite3_pcache_page *pPage /* Page obtained by prior PcacheFetch() call */-
462){-
463 PgHdr *pPgHdr;-
464 assert( pPage!=0 );-
465 pPgHdr = (PgHdr*)pPage->pExtra;-
466 assert( pPgHdr->pPage==0 );-
467 memset(&pPgHdr->pDirty, 0, sizeof(PgHdr) - offsetof(PgHdr,pDirty));-
468 pPgHdr->pPage = pPage;-
469 pPgHdr->pData = pPage->pBuf;-
470 pPgHdr->pExtra = (void *)&pPgHdr[1];-
471 memset(pPgHdr->pExtra, 0, 8);-
472 pPgHdr->pCache = pCache;-
473 pPgHdr->pgno = pgno;-
474 pPgHdr->flags = PGHDR_CLEAN;-
475 return sqlite3PcacheFetchFinish(pCache,pgno,pPage);
executed 6712926 times by 435 tests: return sqlite3PcacheFetchFinish(pCache,pgno,pPage);
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
6712926
476}-
477-
478/*-
479** This routine converts the sqlite3_pcache_page object returned by-
480** sqlite3PcacheFetch() into an initialized PgHdr object. This routine-
481** must be called after sqlite3PcacheFetch() in order to get a usable-
482** result.-
483*/-
484PgHdr *sqlite3PcacheFetchFinish(-
485 PCache *pCache, /* Obtain the page from this cache */-
486 Pgno pgno, /* Page number obtained */-
487 sqlite3_pcache_page *pPage /* Page obtained by prior PcacheFetch() call */-
488){-
489 PgHdr *pPgHdr;-
490-
491 assert( pPage!=0 );-
492 pPgHdr = (PgHdr *)pPage->pExtra;-
493-
494 if( !pPgHdr->pPage ){
!pPgHdr->pPageDescription
TRUEevaluated 6712926 times by 435 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 23473519 times by 435 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
6712926-23473519
495 return pcacheFetchFinishWithInit(pCache, pgno, pPage);
executed 6712926 times by 435 tests: return pcacheFetchFinishWithInit(pCache, pgno, pPage);
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
6712926
496 }-
497 pCache->nRefSum++;-
498 pPgHdr->nRef++;-
499 assert( sqlite3PcachePageSanity(pPgHdr) );-
500 return pPgHdr;
executed 23473519 times by 435 tests: return pPgHdr;
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
23473519
501}-
502-
503/*-
504** Decrement the reference count on a page. If the page is clean and the-
505** reference count drops to 0, then it is made eligible for recycling.-
506*/-
507void SQLITE_NOINLINE sqlite3PcacheRelease(PgHdr *p){-
508 assert( p->nRef>0 );-
509 p->pCache->nRefSum--;-
510 if( (--p->nRef)==0 ){
(--p->nRef)==0Description
TRUEevaluated 22246497 times by 435 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 1504283 times by 434 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
1504283-22246497
511 if( p->flags&PGHDR_CLEAN ){
p->flags&0x001Description
TRUEevaluated 10235038 times by 435 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 12011459 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (11)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • Self test (128)
  • Self test (129)
  • Self test (13)
  • Self test (130)
  • Self test (131)
  • ...
10235038-12011459
512 pcacheUnpin(p);-
513 }else{
executed 10235038 times by 435 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
10235038
514 pcacheManageDirtyList(p, PCACHE_DIRTYLIST_FRONT);-
515 }
executed 12011459 times by 394 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (11)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • Self test (128)
  • Self test (129)
  • Self test (13)
  • Self test (130)
  • Self test (131)
  • ...
12011459
516 }-
517}
executed 23750780 times by 435 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
23750780
518-
519/*-
520** Increase the reference count of a supplied page by 1.-
521*/-
522void sqlite3PcacheRef(PgHdr *p){-
523 assert(p->nRef>0);-
524 assert( sqlite3PcachePageSanity(p) );-
525 p->nRef++;-
526 p->pCache->nRefSum++;-
527}
executed 283690 times by 350 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • Self test (128)
  • Self test (129)
  • Self test (130)
  • Self test (131)
  • ...
283690
528-
529/*-
530** Drop a page from the cache. There must be exactly one reference to the-
531** page. This function deletes that reference, so after it returns the-
532** page pointed to by p is invalid.-
533*/-
534void sqlite3PcacheDrop(PgHdr *p){-
535 assert( p->nRef==1 );-
536 assert( sqlite3PcachePageSanity(p) );-
537 if( p->flags&PGHDR_DIRTY ){
p->flags&0x002Description
TRUEevaluated 4535 times by 6 tests
Evaluated by:
  • Self test
  • Self test (32)
  • Self test (33)
  • Self test (438)
  • Self test (79)
  • Self test (88)
FALSEevaluated 76 times by 2 tests
Evaluated by:
  • Self test (39)
  • Self test (438)
76-4535
538 pcacheManageDirtyList(p, PCACHE_DIRTYLIST_REMOVE);-
539 }
executed 4535 times by 6 tests: end of block
Executed by:
  • Self test
  • Self test (32)
  • Self test (33)
  • Self test (438)
  • Self test (79)
  • Self test (88)
4535
540 p->pCache->nRefSum--;-
541 sqlite3GlobalConfig.pcache2.xUnpin(p->pCache->pCache, p->pPage, 1);-
542}
executed 4611 times by 7 tests: end of block
Executed by:
  • Self test
  • Self test (32)
  • Self test (33)
  • Self test (39)
  • Self test (438)
  • Self test (79)
  • Self test (88)
4611
543-
544/*-
545** Make sure the page is marked as dirty. If it isn't dirty already,-
546** make it so.-
547*/-
548void sqlite3PcacheMakeDirty(PgHdr *p){-
549 assert( p->nRef>0 );-
550 assert( sqlite3PcachePageSanity(p) );-
551 if( p->flags & (PGHDR_CLEAN|PGHDR_DONT_WRITE) ){ /*OPTIMIZATION-IF-FALSE*/
p->flags & (0x001|0x010)Description
TRUEevaluated 2011541 times by 403 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • ...
FALSEevaluated 21870 times by 24 tests
Evaluated by:
  • Self test (10)
  • Self test (100)
  • Self test (12)
  • Self test (13)
  • Self test (14)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (22)
  • Self test (32)
  • Self test (33)
  • Self test (438)
  • Self test (6)
  • Self test (8)
  • Self test (9)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • Self test (97)
  • Self test (98)
  • Self test (99)
21870-2011541
552 p->flags &= ~PGHDR_DONT_WRITE;-
553 if( p->flags & PGHDR_CLEAN ){
p->flags & 0x001Description
TRUEevaluated 2010671 times by 403 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • ...
FALSEevaluated 870 times by 3 tests
Evaluated by:
  • Self test (32)
  • Self test (33)
  • Self test (438)
870-2010671
554 p->flags ^= (PGHDR_DIRTY|PGHDR_CLEAN);-
555 pcacheTrace(("%p.DIRTY %d\n",p->pCache,p->pgno));-
556 assert( (p->flags & (PGHDR_DIRTY|PGHDR_CLEAN))==PGHDR_DIRTY );-
557 pcacheManageDirtyList(p, PCACHE_DIRTYLIST_ADD);-
558 }
executed 2010671 times by 403 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • ...
2010671
559 assert( sqlite3PcachePageSanity(p) );-
560 }
executed 2011541 times by 403 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • ...
2011541
561}
executed 2033411 times by 403 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • ...
2033411
562-
563/*-
564** Make sure the page is marked as clean. If it isn't clean already,-
565** make it so.-
566*/-
567void sqlite3PcacheMakeClean(PgHdr *p){-
568 assert( sqlite3PcachePageSanity(p) );-
569 assert( (p->flags & PGHDR_DIRTY)!=0 );-
570 assert( (p->flags & PGHDR_CLEAN)==0 );-
571 pcacheManageDirtyList(p, PCACHE_DIRTYLIST_REMOVE);-
572 p->flags &= ~(PGHDR_DIRTY|PGHDR_NEED_SYNC|PGHDR_WRITEABLE);-
573 p->flags |= PGHDR_CLEAN;-
574 pcacheTrace(("%p.CLEAN %d\n",p->pCache,p->pgno));-
575 assert( sqlite3PcachePageSanity(p) );-
576 if( p->nRef==0 ){
p->nRef==0Description
TRUEevaluated 1930900 times by 71 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (11)
  • Self test (12)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (20)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • ...
FALSEevaluated 57791 times by 57 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (11)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (31)
  • Self test (32)
  • Self test (33)
  • ...
57791-1930900
577 pcacheUnpin(p);-
578 }
executed 1930900 times by 71 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (11)
  • Self test (12)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (20)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • ...
1930900
579}
executed 1988691 times by 71 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (11)
  • Self test (12)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (20)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • ...
1988691
580-
581/*-
582** Make every page in the cache clean.-
583*/-
584void sqlite3PcacheCleanAll(PCache *pCache){-
585 PgHdr *p;-
586 pcacheTrace(("%p.CLEAN-ALL\n",pCache));-
587 while( (p = pCache->pDirty)!=0 ){
(p = pCache->pDirty)!=0Description
TRUEevaluated 398420 times by 66 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (11)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (31)
  • Self test (32)
  • ...
FALSEevaluated 193325 times by 68 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (11)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (31)
  • Self test (32)
  • ...
193325-398420
588 sqlite3PcacheMakeClean(p);-
589 }
executed 398420 times by 66 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (11)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (31)
  • Self test (32)
  • ...
398420
590}
executed 193325 times by 68 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (11)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (31)
  • Self test (32)
  • ...
193325
591-
592/*-
593** Clear the PGHDR_NEED_SYNC and PGHDR_WRITEABLE flag from all dirty pages.-
594*/-
595void sqlite3PcacheClearWritable(PCache *pCache){-
596 PgHdr *p;-
597 pcacheTrace(("%p.CLEAR-WRITEABLE\n",pCache));-
598 for(p=pCache->pDirty; p; p=p->pDirtyNext){
pDescription
TRUEevaluated 275226 times by 6 tests
Evaluated by:
  • Self test (101)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (438)
  • Self test (64)
FALSEevaluated 127375 times by 17 tests
Evaluated by:
  • Self test (101)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (43)
  • Self test (438)
  • Self test (45)
  • Self test (53)
  • Self test (64)
  • Self test (65)
  • Self test (66)
  • Self test (67)
  • Self test (68)
  • Self test (69)
  • Self test (70)
  • Self test (71)
  • Self test (74)
127375-275226
599 p->flags &= ~(PGHDR_NEED_SYNC|PGHDR_WRITEABLE);-
600 }
executed 275226 times by 6 tests: end of block
Executed by:
  • Self test (101)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (438)
  • Self test (64)
275226
601 pCache->pSynced = pCache->pDirtyTail;-
602}
executed 127375 times by 17 tests: end of block
Executed by:
  • Self test (101)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (43)
  • Self test (438)
  • Self test (45)
  • Self test (53)
  • Self test (64)
  • Self test (65)
  • Self test (66)
  • Self test (67)
  • Self test (68)
  • Self test (69)
  • Self test (70)
  • Self test (71)
  • Self test (74)
127375
603-
604/*-
605** Clear the PGHDR_NEED_SYNC flag from all dirty pages.-
606*/-
607void sqlite3PcacheClearSyncFlags(PCache *pCache){-
608 PgHdr *p;-
609 for(p=pCache->pDirty; p; p=p->pDirtyNext){
pDescription
TRUEevaluated 659440 times by 132 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (101)
  • Self test (104)
  • Self test (11)
  • Self test (12)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (20)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (3)
  • Self test (31)
  • Self test (32)
  • ...
FALSEevaluated 72077 times by 132 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (101)
  • Self test (104)
  • Self test (11)
  • Self test (12)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (20)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (3)
  • Self test (31)
  • Self test (32)
  • ...
72077-659440
610 p->flags &= ~PGHDR_NEED_SYNC;-
611 }
executed 659440 times by 132 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (101)
  • Self test (104)
  • Self test (11)
  • Self test (12)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (20)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (3)
  • Self test (31)
  • Self test (32)
  • ...
659440
612 pCache->pSynced = pCache->pDirtyTail;-
613}
executed 72077 times by 132 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (101)
  • Self test (104)
  • Self test (11)
  • Self test (12)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (20)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (3)
  • Self test (31)
  • Self test (32)
  • ...
72077
614-
615/*-
616** Change the page number of page p to newPgno. -
617*/-
618void sqlite3PcacheMove(PgHdr *p, Pgno newPgno){-
619 PCache *pCache = p->pCache;-
620 assert( p->nRef>0 );-
621 assert( newPgno>0 );-
622 assert( sqlite3PcachePageSanity(p) );-
623 pcacheTrace(("%p.MOVE %d -> %d\n",pCache,p->pgno,newPgno));-
624 sqlite3GlobalConfig.pcache2.xRekey(pCache->pCache, p->pPage, p->pgno,newPgno);-
625 p->pgno = newPgno;-
626 if( (p->flags&PGHDR_DIRTY) && (p->flags&PGHDR_NEED_SYNC) ){
(p->flags&0x002)Description
TRUEevaluated 238519 times by 151 tests
Evaluated by:
  • Self test (10)
  • Self test (12)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (18)
  • Self test (20)
  • Self test (22)
  • Self test (302)
  • Self test (303)
  • Self test (304)
  • Self test (305)
  • Self test (306)
  • Self test (307)
  • Self test (308)
  • Self test (309)
  • Self test (310)
  • Self test (311)
  • Self test (312)
  • Self test (313)
  • Self test (314)
  • Self test (315)
  • Self test (316)
  • Self test (317)
  • Self test (318)
  • ...
FALSEevaluated 112667 times by 152 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (12)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (18)
  • Self test (20)
  • Self test (22)
  • Self test (302)
  • Self test (303)
  • Self test (304)
  • Self test (305)
  • Self test (306)
  • Self test (307)
  • Self test (308)
  • Self test (309)
  • Self test (310)
  • Self test (311)
  • Self test (312)
  • Self test (313)
  • Self test (314)
  • Self test (315)
  • Self test (316)
  • Self test (317)
  • ...
(p->flags&0x008)Description
TRUEevaluated 84787 times by 146 tests
Evaluated by:
  • Self test (10)
  • Self test (12)
  • Self test (14)
  • Self test (15)
  • Self test (302)
  • Self test (303)
  • Self test (304)
  • Self test (305)
  • Self test (306)
  • Self test (307)
  • Self test (308)
  • Self test (309)
  • Self test (310)
  • Self test (311)
  • Self test (312)
  • Self test (313)
  • Self test (314)
  • Self test (315)
  • Self test (316)
  • Self test (317)
  • Self test (318)
  • Self test (319)
  • Self test (32)
  • Self test (320)
  • Self test (321)
  • ...
FALSEevaluated 153732 times by 11 tests
Evaluated by:
  • Self test (10)
  • Self test (12)
  • Self test (14)
  • Self test (16)
  • Self test (18)
  • Self test (20)
  • Self test (22)
  • Self test (438)
  • Self test (54)
  • Self test (6)
  • Self test (8)
84787-238519
627 pcacheManageDirtyList(p, PCACHE_DIRTYLIST_FRONT);-
628 }
executed 84787 times by 146 tests: end of block
Executed by:
  • Self test (10)
  • Self test (12)
  • Self test (14)
  • Self test (15)
  • Self test (302)
  • Self test (303)
  • Self test (304)
  • Self test (305)
  • Self test (306)
  • Self test (307)
  • Self test (308)
  • Self test (309)
  • Self test (310)
  • Self test (311)
  • Self test (312)
  • Self test (313)
  • Self test (314)
  • Self test (315)
  • Self test (316)
  • Self test (317)
  • Self test (318)
  • Self test (319)
  • Self test (32)
  • Self test (320)
  • Self test (321)
  • ...
84787
629}
executed 351186 times by 152 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (12)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (18)
  • Self test (20)
  • Self test (22)
  • Self test (302)
  • Self test (303)
  • Self test (304)
  • Self test (305)
  • Self test (306)
  • Self test (307)
  • Self test (308)
  • Self test (309)
  • Self test (310)
  • Self test (311)
  • Self test (312)
  • Self test (313)
  • Self test (314)
  • Self test (315)
  • Self test (316)
  • Self test (317)
  • ...
351186
630-
631/*-
632** Drop every cache entry whose page number is greater than "pgno". The-
633** caller must ensure that there are no outstanding references to any pages-
634** other than page 1 with a page number greater than pgno.-
635**-
636** If there is a reference to page 1 and the pgno parameter passed to this-
637** function is 0, then the data area associated with page 1 is zeroed, but-
638** the page object is not dropped.-
639*/-
640void sqlite3PcacheTruncate(PCache *pCache, Pgno pgno){-
641 if( pCache->pCache ){
pCache->pCacheDescription
TRUEevaluated 325991 times by 105 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (102)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (11)
  • Self test (12)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (20)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (25)
  • Self test (26)
  • ...
FALSEevaluated 95688 times by 438 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (102)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • ...
95688-325991
642 PgHdr *p;-
643 PgHdr *pNext;-
644 pcacheTrace(("%p.TRUNCATE %d\n",pCache,pgno));-
645 for(p=pCache->pDirty; p; p=pNext){
pDescription
TRUEevaluated 482760 times by 6 tests
Evaluated by:
  • Self test (101)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (438)
  • Self test (64)
FALSEevaluated 325991 times by 105 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (102)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (11)
  • Self test (12)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (20)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (25)
  • Self test (26)
  • ...
325991-482760
646 pNext = p->pDirtyNext;-
647 /* This routine never gets call with a positive pgno except right-
648 ** after sqlite3PcacheCleanAll(). So if there are dirty pages,-
649 ** it must be that pgno==0.-
650 */-
651 assert( p->pgno>0 );-
652 if( p->pgno>pgno ){
p->pgno>pgnoDescription
TRUEevaluated 241980 times by 6 tests
Evaluated by:
  • Self test (101)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (438)
  • Self test (64)
FALSEevaluated 240780 times by 6 tests
Evaluated by:
  • Self test (101)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (438)
  • Self test (64)
240780-241980
653 assert( p->flags&PGHDR_DIRTY );-
654 sqlite3PcacheMakeClean(p);-
655 }
executed 241980 times by 6 tests: end of block
Executed by:
  • Self test (101)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (438)
  • Self test (64)
241980
656 }
executed 482760 times by 6 tests: end of block
Executed by:
  • Self test (101)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (438)
  • Self test (64)
482760
657 if( pgno==0 && pCache->nRefSum ){
pgno==0Description
TRUEevaluated 102531 times by 99 tests
Evaluated by:
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (102)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (11)
  • Self test (12)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (20)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (25)
  • Self test (26)
  • Self test (27)
  • ...
FALSEevaluated 223460 times by 62 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (11)
  • Self test (14)
  • Self test (15)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (31)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (38)
  • ...
pCache->nRefSumDescription
TRUEevaluated 803 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 101728 times by 99 tests
Evaluated by:
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (102)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (11)
  • Self test (12)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (20)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (25)
  • Self test (26)
  • Self test (27)
  • ...
803-223460
658 sqlite3_pcache_page *pPage1;-
659 pPage1 = sqlite3GlobalConfig.pcache2.xFetch(pCache->pCache,1,0);-
660 if( ALWAYS(pPage1) ){ /* Page 1 is always available in cache, because
(pPage1)Description
TRUEevaluated 803 times by 1 test
Evaluated by:
  • Self test (438)
FALSEnever evaluated
0-803
661 ** pCache->nRefSum>0 */-
662 memset(pPage1->pBuf, 0, pCache->szPage);-
663 pgno = 1;-
664 }
executed 803 times by 1 test: end of block
Executed by:
  • Self test (438)
803
665 }
executed 803 times by 1 test: end of block
Executed by:
  • Self test (438)
803
666 sqlite3GlobalConfig.pcache2.xTruncate(pCache->pCache, pgno+1);-
667 }
executed 325991 times by 105 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (102)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (11)
  • Self test (12)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (20)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (25)
  • Self test (26)
  • ...
325991
668}
executed 421679 times by 438 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (102)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • ...
421679
669-
670/*-
671** Close a cache.-
672*/-
673void sqlite3PcacheClose(PCache *pCache){-
674 assert( pCache->pCache!=0 );-
675 pcacheTrace(("%p.CLOSE\n",pCache));-
676 sqlite3GlobalConfig.pcache2.xDestroy(pCache->pCache);-
677}
executed 95285 times by 67 tests: end of block
Executed by:
  • Self test (101)
  • Self test (102)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (24)
  • Self test (25)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (31)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (35)
  • Self test (36)
  • Self test (37)
  • Self test (38)
  • Self test (39)
  • Self test (40)
  • Self test (41)
  • Self test (42)
  • Self test (43)
  • ...
95285
678-
679/* -
680** Discard the contents of the cache.-
681*/-
682void sqlite3PcacheClear(PCache *pCache){-
683 sqlite3PcacheTruncate(pCache, 0);-
684}
executed 194667 times by 438 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (102)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • ...
194667
685-
686/*-
687** Merge two lists of pages connected by pDirty and in pgno order.-
688** Do not bother fixing the pDirtyPrev pointers.-
689*/-
690static PgHdr *pcacheMergeDirtyList(PgHdr *pA, PgHdr *pB){-
691 PgHdr result, *pTail;-
692 pTail = &result;-
693 assert( pA!=0 && pB!=0 );-
694 for(;;){-
695 if( pA->pgno<pB->pgno ){
pA->pgno<pB->pgnoDescription
TRUEevaluated 295092 times by 125 tests
Evaluated by:
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (11)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (3)
  • Self test (31)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (354)
  • Self test (355)
  • Self test (356)
  • Self test (357)
  • Self test (358)
  • Self test (359)
  • ...
FALSEevaluated 781103 times by 133 tests
Evaluated by:
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (11)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (354)
  • ...
295092-781103
696 pTail->pDirty = pA;-
697 pTail = pA;-
698 pA = pA->pDirty;-
699 if( pA==0 ){
pA==0Description
TRUEevaluated 102898 times by 125 tests
Evaluated by:
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (11)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (3)
  • Self test (31)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (354)
  • Self test (355)
  • Self test (356)
  • Self test (357)
  • Self test (358)
  • Self test (359)
  • ...
FALSEevaluated 192194 times by 118 tests
Evaluated by:
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (11)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (3)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (354)
  • Self test (355)
  • Self test (356)
  • Self test (357)
  • Self test (358)
  • Self test (359)
  • Self test (360)
  • ...
102898-192194
700 pTail->pDirty = pB;-
701 break;
executed 102898 times by 125 tests: break;
Executed by:
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (11)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (3)
  • Self test (31)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (354)
  • Self test (355)
  • Self test (356)
  • Self test (357)
  • Self test (358)
  • Self test (359)
  • ...
102898
702 }-
703 }else{
executed 192194 times by 118 tests: end of block
Executed by:
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (11)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (3)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (354)
  • Self test (355)
  • Self test (356)
  • Self test (357)
  • Self test (358)
  • Self test (359)
  • Self test (360)
  • ...
192194
704 pTail->pDirty = pB;-
705 pTail = pB;-
706 pB = pB->pDirty;-
707 if( pB==0 ){
pB==0Description
TRUEevaluated 190525 times by 133 tests
Evaluated by:
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (11)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (354)
  • ...
FALSEevaluated 590578 times by 118 tests
Evaluated by:
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (11)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (3)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (354)
  • Self test (355)
  • Self test (356)
  • Self test (357)
  • Self test (358)
  • Self test (359)
  • Self test (360)
  • ...
190525-590578
708 pTail->pDirty = pA;-
709 break;
executed 190525 times by 133 tests: break;
Executed by:
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (11)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (354)
  • ...
190525
710 }-
711 }
executed 590578 times by 118 tests: end of block
Executed by:
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (11)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (3)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (354)
  • Self test (355)
  • Self test (356)
  • Self test (357)
  • Self test (358)
  • Self test (359)
  • Self test (360)
  • ...
590578
712 }-
713 return result.pDirty;
executed 293423 times by 139 tests: return result.pDirty;
Executed by:
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (11)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (31)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • ...
293423
714}-
715-
716/*-
717** Sort the list of pages in accending order by pgno. Pages are-
718** connected by pDirty pointers. The pDirtyPrev pointers are-
719** corrupted by this sort.-
720**-
721** Since there cannot be more than 2^31 distinct pages in a database,-
722** there cannot be more than 31 buckets required by the merge sorter.-
723** One extra bucket is added to catch overflow in case something-
724** ever changes to make the previous sentence incorrect.-
725*/-
726#define N_SORT_BUCKET 32-
727static PgHdr *pcacheSortDirtyList(PgHdr *pIn){-
728 PgHdr *a[N_SORT_BUCKET], *p;-
729 int i;-
730 memset(a, 0, sizeof(a));-
731 while( pIn ){
pInDescription
TRUEevaluated 387423 times by 150 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (11)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (31)
  • Self test (32)
  • ...
FALSEevaluated 94033 times by 150 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (11)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (31)
  • Self test (32)
  • ...
94033-387423
732 p = pIn;-
733 pIn = p->pDirty;-
734 p->pDirty = 0;-
735 for(i=0; ALWAYS(i<N_SORT_BUCKET-1); i++){
(i<32 -1)Description
TRUEevaluated 649220 times by 150 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (11)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (31)
  • Self test (32)
  • ...
FALSEnever evaluated
0-649220
736 if( a[i]==0 ){
a[i]==0Description
TRUEevaluated 387423 times by 150 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (11)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (31)
  • Self test (32)
  • ...
FALSEevaluated 261797 times by 139 tests
Evaluated by:
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (11)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (31)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • ...
261797-387423
737 a[i] = p;-
738 break;
executed 387423 times by 150 tests: break;
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (11)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (31)
  • Self test (32)
  • ...
387423
739 }else{-
740 p = pcacheMergeDirtyList(a[i], p);-
741 a[i] = 0;-
742 }
executed 261797 times by 139 tests: end of block
Executed by:
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (11)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (31)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • ...
261797
743 }-
744 if( NEVER(i==N_SORT_BUCKET-1) ){
(i==32 -1)Description
TRUEnever evaluated
FALSEevaluated 387423 times by 150 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (11)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (31)
  • Self test (32)
  • ...
0-387423
745 /* To get here, there need to be 2^(N_SORT_BUCKET) elements in-
746 ** the input list. But that is impossible.-
747 */-
748 a[i] = pcacheMergeDirtyList(a[i], p);-
749 }
never executed: end of block
0
750 }
executed 387423 times by 150 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (11)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (31)
  • Self test (32)
  • ...
387423
751 p = a[0];-
752 for(i=1; i<N_SORT_BUCKET; i++){
i<32Description
TRUEevaluated 2915023 times by 150 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (11)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (31)
  • Self test (32)
  • ...
FALSEevaluated 94033 times by 150 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (11)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (31)
  • Self test (32)
  • ...
94033-2915023
753 if( a[i]==0 ) continue;
executed 2857538 times by 150 tests: continue;
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (11)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (31)
  • Self test (32)
  • ...
a[i]==0Description
TRUEevaluated 2857538 times by 150 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (11)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (31)
  • Self test (32)
  • ...
FALSEevaluated 57485 times by 139 tests
Evaluated by:
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (11)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (31)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • ...
57485-2857538
754 p = p ? pcacheMergeDirtyList(p, a[i]) : a[i];
pDescription
TRUEevaluated 31626 times by 114 tests
Evaluated by:
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (11)
  • Self test (13)
  • Self test (14)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (3)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (354)
  • Self test (355)
  • Self test (356)
  • Self test (357)
  • Self test (358)
  • Self test (359)
  • Self test (360)
  • Self test (361)
  • ...
FALSEevaluated 25859 times by 39 tests
Evaluated by:
  • Self test (10)
  • Self test (101)
  • Self test (104)
  • Self test (15)
  • Self test (2)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (31)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (38)
  • Self test (39)
  • Self test (4)
  • Self test (40)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
  • Self test (48)
  • ...
25859-31626
755 }
executed 57485 times by 139 tests: end of block
Executed by:
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (11)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (31)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • ...
57485
756 return p;
executed 94033 times by 150 tests: return p;
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (11)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (31)
  • Self test (32)
  • ...
94033
757}-
758-
759/*-
760** Return a list of all dirty pages in the cache, sorted by page number.-
761*/-
762PgHdr *sqlite3PcacheDirtyList(PCache *pCache){-
763 PgHdr *p;-
764 for(p=pCache->pDirty; p; p=p->pDirtyNext){
pDescription
TRUEevaluated 387423 times by 150 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (11)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (31)
  • Self test (32)
  • ...
FALSEevaluated 94033 times by 150 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (11)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (31)
  • Self test (32)
  • ...
94033-387423
765 p->pDirty = p->pDirtyNext;-
766 }
executed 387423 times by 150 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (11)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (31)
  • Self test (32)
  • ...
387423
767 return pcacheSortDirtyList(pCache->pDirty);
executed 94033 times by 150 tests: return pcacheSortDirtyList(pCache->pDirty);
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (11)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (31)
  • Self test (32)
  • ...
94033
768}-
769-
770/* -
771** Return the total number of references to all pages held by the cache.-
772**-
773** This is not the total number of pages referenced, but the sum of the-
774** reference count for all pages.-
775*/-
776int sqlite3PcacheRefCount(PCache *pCache){-
777 return pCache->nRefSum;
executed 469301 times by 438 tests: return pCache->nRefSum;
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (102)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • ...
469301
778}-
779-
780/*-
781** Return the number of references to the page supplied as an argument.-
782*/-
783int sqlite3PcachePageRefcount(PgHdr *p){-
784 return p->nRef;
executed 1261142 times by 385 tests: return p->nRef;
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • ...
1261142
785}-
786-
787/* -
788** Return the total number of pages in the cache.-
789*/-
790int sqlite3PcachePagecount(PCache *pCache){-
791 assert( pCache->pCache!=0 );-
792 return sqlite3GlobalConfig.pcache2.xPagecount(pCache->pCache);
executed 1489788 times by 27 tests: return sqlite3Config.pcache2.xPagecount(pCache->pCache);
Executed by:
  • Self test
  • Self test (10)
  • Self test (101)
  • Self test (11)
  • Self test (12)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (20)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (3)
  • Self test (438)
  • Self test (54)
  • Self test (57)
  • Self test (58)
  • Self test (6)
  • Self test (64)
  • Self test (7)
  • ...
1489788
793}-
794-
795#ifdef SQLITE_TEST-
796/*-
797** Get the suggested cache-size value.-
798*/-
799int sqlite3PcacheGetCachesize(PCache *pCache){-
800 return numberOfCachePages(pCache);
executed 52 times by 1 test: return numberOfCachePages(pCache);
Executed by:
  • Self test (438)
52
801}-
802#endif-
803-
804/*-
805** Set the suggested cache-size value.-
806*/-
807void sqlite3PcacheSetCachesize(PCache *pCache, int mxPage){-
808 assert( pCache->pCache!=0 );-
809 pCache->szCache = mxPage;-
810 sqlite3GlobalConfig.pcache2.xCachesize(pCache->pCache,-
811 numberOfCachePages(pCache));-
812}
executed 116524 times by 438 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (102)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • ...
116524
813-
814/*-
815** Set the suggested cache-spill value. Make no changes if if the-
816** argument is zero. Return the effective cache-spill size, which will-
817** be the larger of the szSpill and szCache.-
818*/-
819int sqlite3PcacheSetSpillsize(PCache *p, int mxPage){-
820 int res;-
821 assert( p->pCache!=0 );-
822 if( mxPage ){
mxPageDescription
TRUEevaluated 874 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
FALSEevaluated 878 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
874-878
823 if( mxPage<0 ){
mxPage<0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 872 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
2-872
824 mxPage = (int)((-1024*(i64)mxPage)/(p->szPage+p->szExtra));-
825 }
executed 2 times by 1 test: end of block
Executed by:
  • Self test (438)
2
826 p->szSpill = mxPage;-
827 }
executed 874 times by 2 tests: end of block
Executed by:
  • Self test (34)
  • Self test (438)
874
828 res = numberOfCachePages(p);-
829 if( res<p->szSpill ) res = p->szSpill;
executed 9 times by 1 test: res = p->szSpill;
Executed by:
  • Self test (438)
res<p->szSpillDescription
TRUEevaluated 9 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1743 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
9-1743
830 return res;
executed 1752 times by 2 tests: return res;
Executed by:
  • Self test (34)
  • Self test (438)
1752
831}-
832-
833/*-
834** Free up as much memory as possible from the page cache.-
835*/-
836void sqlite3PcacheShrink(PCache *pCache){-
837 assert( pCache->pCache!=0 );-
838 sqlite3GlobalConfig.pcache2.xShrink(pCache->pCache);-
839}
executed 6 times by 1 test: end of block
Executed by:
  • Self test (438)
6
840-
841/*-
842** Return the size of the header added by this middleware layer-
843** in the page-cache hierarchy.-
844*/-
845int sqlite3HeaderSizePcache(void){ return ROUND8(sizeof(PgHdr)); }
never executed: return (((sizeof(PgHdr))+7)&~7);
0
846-
847/*-
848** Return the number of dirty pages currently in the cache, as a percentage-
849** of the configured cache size.-
850*/-
851int sqlite3PCachePercentDirty(PCache *pCache){-
852 PgHdr *pDirty;-
853 int nDirty = 0;-
854 int nCache = numberOfCachePages(pCache);-
855 for(pDirty=pCache->pDirty; pDirty; pDirty=pDirty->pDirtyNext) nDirty++;
executed 4881 times by 1 test: nDirty++;
Executed by:
  • Self test (438)
pDirtyDescription
TRUEevaluated 4881 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 320 times by 1 test
Evaluated by:
  • Self test (438)
320-4881
856 return nCache ? (int)(((i64)nDirty * 100) / nCache) : 0;
executed 320 times by 1 test: return nCache ? (int)(((i64)nDirty * 100) / nCache) : 0;
Executed by:
  • Self test (438)
nCacheDescription
TRUEevaluated 320 times by 1 test
Evaluated by:
  • Self test (438)
FALSEnever evaluated
0-320
857}-
858-
859#if defined(SQLITE_CHECK_PAGES) || defined(SQLITE_DEBUG)-
860/*-
861** For all dirty pages currently in the cache, invoke the specified-
862** callback. This is only used if the SQLITE_CHECK_PAGES macro is-
863** defined.-
864*/-
865void sqlite3PcacheIterateDirty(PCache *pCache, void (*xIter)(PgHdr *)){-
866 PgHdr *pDirty;-
867 for(pDirty=pCache->pDirty; pDirty; pDirty=pDirty->pDirtyNext){-
868 xIter(pDirty);-
869 }-
870}-
871#endif-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2