line |
true |
false |
branch |
406
|
0 |
409 |
int n = NKEY(pBt, pCell->h) + NDATA(pBt, pCell->h); |
|
0 |
409 |
int n = NKEY(pBt, pCell->h) + NDATA(pBt, pCell->h); |
407
|
3 |
406 |
if( n>MX_LOCAL_PAYLOAD ){ |
429
|
0 |
0 |
pPage->u.hdr.firstCell = SWAB16(pBt, pc); |
431
|
0 |
0 |
for(i=0; inCell; i++){ |
440
|
0 |
0 |
pCell->h.iNext = SWAB16(pBt, pc + n); |
447
|
0 |
0 |
if( pPage->nCell>0 ){ |
451
|
0 |
0 |
pFBlk->iSize = SWAB16(pBt, SQLITE_USABLE_SIZE - pc); |
453
|
0 |
0 |
pPage->u.hdr.firstFree = SWAB16(pBt, pc); |
482
|
132 |
1 |
if( pPage->nFreeisOverfull ) return 0; |
|
0 |
132 |
if( pPage->nFreeisOverfull ) return 0; |
484
|
0 |
132 |
p = (FreeBlk*)&pPage->u.aDisk[SWAB16(pBt, *pIdx)]; |
485
|
0 |
135 |
while( (iSize = SWAB16(pBt, p->iSize))
|
|
3 |
132 |
while( (iSize = SWAB16(pBt, p->iSize))
|
487
|
0 |
3 |
if( p->iNext==0 ){ |
493
|
0 |
3 |
p = (FreeBlk*)&pPage->u.aDisk[SWAB16(pBt, *pIdx)]; |
495
|
3 |
129 |
if( iSize==nByte ){ |
496
|
0 |
3 |
start = SWAB16(pBt, *pIdx); |
500
|
0 |
129 |
start = SWAB16(pBt, *pIdx); |
503
|
0 |
129 |
pNew->iSize = SWAB16(pBt, iSize - nByte); |
504
|
0 |
129 |
*pIdx = SWAB16(pBt, start + nByte); |
532
|
0 |
39 |
idx = SWAB16(pBt, *pIdx); |
533
|
39 |
0 |
while( idx!=0 && idx
|
|
2 |
37 |
while( idx!=0 && idx
|
535
|
0 |
2 |
iSize = SWAB16(pBt, pFBlk->iSize); |
536
|
2 |
0 |
if( idx + iSize == start ){ |
537
|
0 |
2 |
pFBlk->iSize = SWAB16(pBt, iSize + size); |
538
|
0 |
2 |
if( idx + iSize + size == SWAB16(pBt, pFBlk->iNext) ){ |
|
1 |
1 |
if( idx + iSize + size == SWAB16(pBt, pFBlk->iNext) ){ |
540
|
0 |
1 |
if( pBt->needSwab ){ |
551
|
0 |
0 |
idx = SWAB16(pBt, *pIdx); |
554
|
5 |
32 |
if( idx != end ){ |
555
|
0 |
5 |
pNew->iSize = SWAB16(pBt, size); |
556
|
0 |
5 |
pNew->iNext = SWAB16(pBt, idx); |
559
|
0 |
32 |
pNew->iSize = SWAB16(pBt, size + SWAB16(pBt, pNext->iSize)); |
|
0 |
0 |
pNew->iSize = SWAB16(pBt, size + SWAB16(pBt, pNext->iSize)); |
|
0 |
32 |
pNew->iSize = SWAB16(pBt, size + SWAB16(pBt, pNext->iSize)); |
562
|
0 |
37 |
*pIdx = SWAB16(pBt, start); |
587
|
1 |
629 |
if( pPage->pParent ){ |
591
|
4 |
625 |
if( pParent ){ |
595
|
413 |
216 |
if( pPage->isInit ) return SQLITE_OK; |
599
|
0 |
216 |
idx = SWAB16(pBt, pPage->u.hdr.firstCell); |
600
|
237 |
216 |
while( idx!=0 ){ |
601
|
0 |
237 |
if( idx>SQLITE_USABLE_SIZE-MIN_CELL_SIZE ) goto page_format_error; |
602
|
0 |
237 |
if( idx
|
603
|
0 |
237 |
if( idx!=ROUNDUP(idx) ) goto page_format_error; |
606
|
0 |
237 |
if( idx+sz > SQLITE_USABLE_SIZE ) goto page_format_error; |
609
|
0 |
237 |
idx = SWAB16(pBt, pCell->h.iNext); |
612
|
0 |
216 |
idx = SWAB16(pBt, pPage->u.hdr.firstFree); |
613
|
190 |
216 |
while( idx!=0 ){ |
615
|
0 |
190 |
if( idx>SQLITE_USABLE_SIZE-sizeof(FreeBlk) ) goto page_format_error; |
616
|
0 |
190 |
if( idx
|
618
|
0 |
190 |
pPage->nFree += SWAB16(pBt, pFBlk->iSize); |
619
|
0 |
190 |
iNext = SWAB16(pBt, pFBlk->iNext); |
620
|
4 |
186 |
if( iNext>0 && iNext <= idx ) goto page_format_error; |
|
0 |
4 |
if( iNext>0 && iNext <= idx ) goto page_format_error; |
623
|
111 |
105 |
if( pPage->nCell==0 && pPage->nFree==0 ){ |
|
30 |
81 |
if( pPage->nCell==0 && pPage->nFree==0 ){ |
628
|
0 |
186 |
if( pPage->nFree!=freeSpace ) goto page_format_error; |
646
|
0 |
68 |
pHdr->firstFree = SWAB16(pBt, sizeof(*pHdr)); |
650
|
0 |
68 |
pFBlk->iSize = SWAB16(pBt, pPage->nFree); |
662
|
6 |
685 |
if( pPage->pParent ){ |
706
|
0 |
53 |
if( pBt==0 ){ |
710
|
0 |
53 |
if( nCache<10 ) nCache = 10; |
713
|
0 |
53 |
if( rc!=SQLITE_OK ){ |
714
|
0 |
0 |
if( pBt->pPager ) sqlitepager_close(pBt->pPager); |
732
|
0 |
53 |
while( pBt->pCursor ){ |
785
|
0 |
259 |
if( pBt->page1 ) return SQLITE_OK; |
787
|
0 |
259 |
if( rc!=SQLITE_OK ) return rc; |
792
|
202 |
57 |
if( sqlitepager_pagecount(pBt->pPager)>0 ){ |
794
|
202 |
0 |
if( strcmp(pP1->zMagic,zMagicHeader)!=0 || |
|
0 |
202 |
if( strcmp(pP1->zMagic,zMagicHeader)!=0 || |
795
|
0 |
0 |
(pP1->iMagic!=MAGIC && swab32(pP1->iMagic)!=MAGIC) ){ |
820
|
310 |
115 |
if( pBt->inTrans==0 && pBt->pCursor==0 && pBt->page1!=0 ){ |
|
256 |
54 |
if( pBt->inTrans==0 && pBt->pCursor==0 && pBt->page1!=0 ){ |
|
256 |
0 |
if( pBt->inTrans==0 && pBt->pCursor==0 && pBt->page1!=0 ){ |
836
|
129 |
27 |
if( sqlitepager_pagecount(pBt->pPager)>1 ) return SQLITE_OK; |
839
|
0 |
27 |
if( rc ) return rc; |
841
|
0 |
27 |
if( rc ) return rc; |
843
|
0 |
27 |
if( rc ){ |
877
|
0 |
156 |
if( pBt->inTrans ) return SQLITE_ERROR; |
878
|
0 |
156 |
if( pBt->readOnly ) return SQLITE_READONLY; |
879
|
156 |
0 |
if( pBt->page1==0 ){ |
881
|
0 |
156 |
if( rc!=SQLITE_OK ){ |
886
|
156 |
0 |
if( rc==SQLITE_OK ){ |
889
|
156 |
0 |
if( rc==SQLITE_OK ){ |
906
|
143 |
0 |
rc = pBt->readOnly ? SQLITE_OK : sqlitepager_commit(pBt->pPager); |
925
|
0 |
10 |
if( pBt->inTrans==0 ) return SQLITE_OK; |
928
|
10 |
0 |
rc = pBt->readOnly ? SQLITE_OK : sqlitepager_rollback(pBt->pPager); |
929
|
0 |
10 |
for(pCur=pBt->pCursor; pCur; pCur=pCur->pNext){ |
930
|
0 |
0 |
if( pCur->pPage && pCur->pPage->isInit==0 ){ |
|
0 |
0 |
if( pCur->pPage && pCur->pPage->isInit==0 ){ |
951
|
0 |
0 |
if( !pBt->inTrans || pBt->inCkpt ){ |
|
0 |
0 |
if( !pBt->inTrans || pBt->inCkpt ){ |
952
|
0 |
0 |
return pBt->readOnly ? SQLITE_READONLY : SQLITE_ERROR; |
954
|
0 |
0 |
rc = pBt->readOnly ? SQLITE_OK : sqlitepager_ckpt_begin(pBt->pPager); |
966
|
0 |
0 |
if( pBt->inCkpt && !pBt->readOnly ){ |
|
0 |
0 |
if( pBt->inCkpt && !pBt->readOnly ){ |
986
|
0 |
2 |
if( pBt->inCkpt==0 || pBt->readOnly ) return SQLITE_OK; |
|
0 |
0 |
if( pBt->inCkpt==0 || pBt->readOnly ) return SQLITE_OK; |
988
|
0 |
0 |
for(pCur=pBt->pCursor; pCur; pCur=pCur->pNext){ |
989
|
0 |
0 |
if( pCur->pPage && pCur->pPage->isInit==0 ){ |
|
0 |
0 |
if( pCur->pPage && pCur->pPage->isInit==0 ){ |
1039
|
0 |
272 |
if( pBt->readOnly && wrFlag ){ |
|
0 |
0 |
if( pBt->readOnly && wrFlag ){ |
1043
|
103 |
169 |
if( pBt->page1==0 ){ |
1045
|
0 |
103 |
if( rc!=SQLITE_OK ){ |
1051
|
0 |
272 |
if( pCur==0 ){ |
1057
|
0 |
272 |
if( rc!=SQLITE_OK ){ |
1061
|
0 |
272 |
if( rc!=SQLITE_OK ){ |
1070
|
59 |
213 |
if( pCur->pNext ){ |
1075
|
60 |
218 |
while( pRing && pRing->pgnoRoot!=pCur->pgnoRoot ){ pRing = pRing->pNext; } |
|
6 |
54 |
while( pRing && pRing->pgnoRoot!=pCur->pgnoRoot ){ pRing = pRing->pNext; } |
1076
|
54 |
218 |
if( pRing ){ |
1088
|
0 |
0 |
if( pCur ){ |
1089
|
0 |
0 |
if( pCur->pPage ) sqlitepager_unref(pCur->pPage); |
1102
|
3 |
269 |
if( pCur->pPrev ){ |
1107
|
56 |
216 |
if( pCur->pNext ){ |
1110
|
272 |
0 |
if( pCur->pPage ){ |
1113
|
54 |
218 |
if( pCur->pShared!=pCur ){ |
1115
|
0 |
54 |
while( pRing->pShared!=pCur ){ pRing = pRing->pShared; } |
1131
|
0 |
0 |
if( pTempCur->pPage ){ |
1141
|
0 |
0 |
if( pCur->pPage ){ |
1159
|
3 |
1 |
if( pCur->idx >= pPage->nCell ){ |
1163
|
0 |
1 |
*pSize = NKEY(pCur->pBt, pCell->h); |
1184
|
798 |
0 |
if( offset
|
1186
|
1 |
797 |
if( a+offset>MX_LOCAL_PAYLOAD ){ |
1190
|
797 |
1 |
if( a==amt ){ |
1199
|
1 |
0 |
if( amt>0 ){ |
1200
|
0 |
1 |
nextPage = SWAB32(pBt, pCur->pPage->apCell[pCur->idx]->ovfl); |
1202
|
33 |
1 |
while( amt>0 && nextPage ){ |
|
33 |
0 |
while( amt>0 && nextPage ){ |
1205
|
0 |
33 |
if( rc!=0 ){ |
1208
|
0 |
33 |
nextPage = SWAB32(pBt, pOvfl->iNext); |
1209
|
33 |
0 |
if( offset
|
1211
|
32 |
1 |
if( a + offset > OVERFLOW_SIZE ){ |
1223
|
0 |
1 |
if( amt>0 ){ |
1249
|
0 |
44 |
if( pCur->idx >= pPage->nCell ){ |
1270
|
0 |
386 |
if( pCur->idx >= pPage->nCell ){ |
1274
|
0 |
386 |
*pSize = NDATA(pCur->pBt, pCell->h); |
1295
|
0 |
754 |
if( pCur->idx >= pPage->nCell ){ |
1300
|
0 |
754 |
getPayload(pCur, offset + NKEY(pCur->pBt, pCell->h), amt, zBuf); |
1341
|
0 |
182 |
nLocal = NKEY(pBt, pCell->h) - nIgnore; |
1342
|
0 |
182 |
if( nLocal<0 ) nLocal = 0; |
1344
|
0 |
182 |
if( n>MX_LOCAL_PAYLOAD ){ |
1348
|
152 |
30 |
if( c!=0 ){ |
1355
|
0 |
30 |
nextPage = SWAB32(pBt, pCell->ovfl); |
1356
|
0 |
30 |
while( nKey>0 && nLocal>0 ){ |
|
0 |
0 |
while( nKey>0 && nLocal>0 ){ |
1358
|
0 |
0 |
if( nextPage==0 ){ |
1362
|
0 |
0 |
if( rc ){ |
1365
|
0 |
0 |
nextPage = SWAB32(pBt, pOvfl->iNext); |
1367
|
0 |
0 |
if( n>OVERFLOW_SIZE ){ |
1372
|
0 |
0 |
if( c!=0 ){ |
1380
|
30 |
0 |
if( c==0 ){ |
1396
|
0 |
4 |
newPgno = SWAB32(pBt, newPgno); |
1398
|
0 |
4 |
if( rc ) return rc; |
1400
|
0 |
4 |
if( rc ) return rc; |
1410
|
0 |
4 |
if( pNewPage->nCell<1 ){ |
1438
|
4 |
0 |
if( pParent->idxShift==0 ){ |
1459
|
0 |
0 |
oldPgno = SWAB32(pCur->pBt, sqlitepager_pagenumber(pPage)); |
1460
|
0 |
0 |
for(i=0; inCell; i++){ |
1461
|
0 |
0 |
if( pParent->apCell[i]->h.leftChild==oldPgno ){ |
1478
|
0 |
342 |
if( rc ) return rc; |
1480
|
0 |
342 |
if( rc ) return rc; |
1495
|
2 |
71 |
while( (pgno = pCur->pPage->apCell[pCur->idx]->h.leftChild)!=0 ){ |
1497
|
0 |
2 |
if( rc ) return rc; |
1513
|
0 |
35 |
while( (pgno = pCur->pPage->u.hdr.rightChild)!=0 ){ |
1516
|
0 |
0 |
if( rc ) return rc; |
1528
|
0 |
141 |
if( pCur->pPage==0 ) return SQLITE_ABORT; |
1530
|
0 |
141 |
if( rc ) return rc; |
1531
|
72 |
69 |
if( pCur->pPage->nCell==0 ){ |
1547
|
0 |
70 |
if( pCur->pPage==0 ) return SQLITE_ABORT; |
1549
|
0 |
70 |
if( rc ) return rc; |
1551
|
35 |
35 |
if( pCur->pPage->nCell==0 ){ |
1587
|
0 |
131 |
if( pCur->pPage==0 ) return SQLITE_ABORT; |
1590
|
0 |
131 |
if( rc ) return rc; |
1598
|
180 |
103 |
while( lwr<=upr ){ |
1601
|
0 |
180 |
if( rc ) return rc; |
1602
|
28 |
152 |
if( c==0 ){ |
1604
|
28 |
0 |
if( pRes ) *pRes = 0; |
1607
|
151 |
1 |
if( c<0 ){ |
1615
|
102 |
1 |
if( lwr>=pPage->nCell ){ |
1620
|
103 |
0 |
if( chldPg==0 ){ |
1622
|
103 |
0 |
if( pRes ) *pRes = c; |
1627
|
0 |
0 |
if( rc ) return rc; |
1642
|
0 |
170 |
if( pPage==0 ){ |
1648
|
13 |
157 |
if( pPage->nCell==0 ){ |
1653
|
0 |
157 |
if( pCur->eSkip==SKIP_NEXT ){ |
1660
|
59 |
98 |
if( pCur->idx>=pPage->nCell ){ |
1661
|
2 |
57 |
if( pPage->u.hdr.rightChild ){ |
1663
|
0 |
2 |
if( rc ) return rc; |
1669
|
55 |
4 |
if( pPage->pParent==0 ){ |
1675
|
2 |
2 |
}while( pCur->idx>=pPage->nCell ); |
1680
|
98 |
0 |
if( pPage->u.hdr.rightChild==0 ){ |
1698
|
0 |
0 |
if( pPage==0 ){ |
1704
|
0 |
0 |
if( pPage->nCell==0 ){ |
1708
|
0 |
0 |
if( pCur->eSkip==SKIP_PREV ){ |
1715
|
0 |
0 |
if( (pgno = pPage->apCell[pCur->idx]->h.leftChild)!=0 ){ |
1717
|
0 |
0 |
if( rc ) return rc; |
1720
|
0 |
0 |
while( pCur->idx==0 ){ |
1721
|
0 |
0 |
if( pPage->pParent==0 ){ |
1722
|
0 |
0 |
if( pRes ) *pRes = 1; |
1755
|
10 |
52 |
if( pPage1->freeList ){ |
1760
|
0 |
10 |
if( rc ) return rc; |
1761
|
0 |
10 |
SWAB_ADD(pBt, pPage1->nFree, -1); |
1762
|
0 |
10 |
rc = sqlitepager_get(pBt->pPager, SWAB32(pBt, pPage1->freeList), |
1764
|
0 |
10 |
if( rc ) return rc; |
1766
|
0 |
10 |
if( rc ){ |
1771
|
3 |
7 |
if( pInfo->nFree==0 ){ |
1772
|
0 |
3 |
*pPgno = SWAB32(pBt, pPage1->freeList); |
1777
|
0 |
7 |
n = SWAB32(pBt, pInfo->nFree); |
1778
|
7 |
0 |
if( n>1 && nearby>0 ){ |
|
0 |
7 |
if( n>1 && nearby>0 ){ |
1781
|
0 |
0 |
dist = SWAB32(pBt, pInfo->aFree[0]) - nearby; |
1782
|
0 |
0 |
if( dist<0 ) dist = -dist; |
1783
|
0 |
0 |
for(i=1; i
|
1784
|
0 |
0 |
int d2 = SWAB32(pBt, pInfo->aFree[i]) - nearby; |
1785
|
0 |
0 |
if( d2<0 ) d2 = -d2; |
1786
|
0 |
0 |
if( d2
|
1791
|
0 |
7 |
SWAB_ADD(pBt, pInfo->nFree, -1); |
1792
|
0 |
7 |
*pPgno = SWAB32(pBt, pInfo->aFree[closest]); |
1796
|
7 |
0 |
if( rc==SQLITE_OK ){ |
1804
|
0 |
52 |
if( rc ) return rc; |
1823
|
0 |
44 |
if( pgno==0 ){ |
1831
|
0 |
44 |
if( pMemPage->pParent ){ |
1836
|
0 |
44 |
if( rc ){ |
1839
|
0 |
44 |
SWAB_ADD(pBt, pPage1->nFree, 1); |
1840
|
44 |
0 |
if( pPage1->nFree!=0 && pPage1->freeList!=0 ){ |
|
40 |
4 |
if( pPage1->nFree!=0 && pPage1->freeList!=0 ){ |
1842
|
0 |
40 |
rc = sqlitepager_get(pBt->pPager, SWAB32(pBt, pPage1->freeList), |
1844
|
40 |
0 |
if( rc==SQLITE_OK ){ |
1846
|
0 |
40 |
int n = SWAB32(pBt, pInfo->nFree); |
1847
|
40 |
0 |
if( n<(sizeof(pInfo->aFree)/sizeof(pInfo->aFree[0])) ){ |
1849
|
40 |
0 |
if( rc==SQLITE_OK ){ |
1850
|
0 |
40 |
pInfo->aFree[n] = SWAB32(pBt, pgno); |
1851
|
0 |
40 |
SWAB_ADD(pBt, pInfo->nFree, 1); |
1860
|
0 |
4 |
if( pOvfl==0 ){ |
1863
|
0 |
0 |
if( rc ) return rc; |
1867
|
0 |
4 |
if( rc ){ |
1868
|
0 |
0 |
if( needUnref ) sqlitepager_unref(pOvfl); |
1872
|
0 |
4 |
pPage1->freeList = SWAB32(pBt, pgno); |
1874
|
0 |
4 |
if( needUnref ) rc = sqlitepager_unref(pOvfl); |
1888
|
0 |
58 |
if( NKEY(pBt, pCell->h) + NDATA(pBt, pCell->h) <= MX_LOCAL_PAYLOAD ){ |
|
0 |
58 |
if( NKEY(pBt, pCell->h) + NDATA(pBt, pCell->h) <= MX_LOCAL_PAYLOAD ){ |
|
57 |
1 |
if( NKEY(pBt, pCell->h) + NDATA(pBt, pCell->h) <= MX_LOCAL_PAYLOAD ){ |
1891
|
0 |
1 |
ovfl = SWAB32(pBt, pCell->ovfl); |
1893
|
33 |
1 |
while( ovfl ){ |
1895
|
0 |
33 |
if( rc ) return rc; |
1896
|
0 |
33 |
nextOvfl = SWAB32(pBt, pOvfl->iNext); |
1898
|
0 |
33 |
if( rc ) return rc; |
1925
|
0 |
121 |
pCell->h.nKey = SWAB16(pBt, nKey & 0xffff); |
1927
|
0 |
121 |
pCell->h.nData = SWAB16(pBt, nData & 0xffff); |
1938
|
250 |
121 |
while( nPayload>0 ){ |
1939
|
33 |
217 |
if( spaceLeft==0 ){ |
1941
|
0 |
33 |
if( rc ){ |
1946
|
32 |
1 |
if( pPrior ) sqlitepager_unref(pPrior); |
1947
|
0 |
33 |
if( rc ){ |
1951
|
0 |
33 |
if( pBt->needSwab ) *pNext = swab32(*pNext); |
1958
|
33 |
217 |
if( n>spaceLeft ) n = spaceLeft; |
1961
|
217 |
33 |
if( nPayload==0 && pData ){ |
|
99 |
118 |
if( nPayload==0 && pData ){ |
1972
|
1 |
120 |
if( pPrior ){ |
1986
|
13 |
2 |
if( pgno==0 ) return; |
1989
|
2 |
0 |
if( pThis && pThis->isInit ){ |
|
2 |
0 |
if( pThis && pThis->isInit ){ |
1990
|
1 |
1 |
if( pThis->pParent!=pNewParent ){ |
1991
|
0 |
1 |
if( pThis->pParent ) sqlitepager_unref(pThis->pParent); |
1993
|
1 |
0 |
if( pNewParent ) sqlitepager_ref(pNewParent); |
2011
|
12 |
3 |
for(i=0; inCell; i++){ |
2012
|
0 |
12 |
reparentPage(pPager, SWAB32(pBt, pPage->apCell[i]->h.leftChild), pPage, i); |
2014
|
0 |
3 |
reparentPage(pPager, SWAB32(pBt, pPage->u.hdr.rightChild), pPage, i); |
2037
|
7 |
39 |
for(j=idx; jnCell-1; j++){ |
2063
|
4 |
133 |
for(j=pPage->nCell; j>i; j--){ |
2067
|
1 |
132 |
if( idx<=0 ){ |
2088
|
383 |
140 |
for(i=0; inCell; i++){ |
2091
|
0 |
383 |
*pIdx = SWAB16(pBt, idx); |
2114
|
24 |
2 |
for(i=0; inCell; i++){ |
2116
|
24 |
0 |
if( x>from && x
|
|
22 |
2 |
if( x>from && x
|
2211
|
138 |
1 |
if( !pPage->isOverfull && pPage->nFree
|
|
20 |
118 |
if( !pPage->isOverfull && pPage->nFree
|
2212
|
20 |
0 |
&& pPage->nCell>=2){ |
2223
|
119 |
0 |
if( pParent==0 ){ |
2227
|
13 |
106 |
if( pPage->nCell==0 ){ |
2228
|
0 |
13 |
if( pPage->u.hdr.rightChild ){ |
2234
|
0 |
0 |
pgnoChild = SWAB32(pBt, pPage->u.hdr.rightChild); |
2236
|
0 |
0 |
if( rc ) return rc; |
2242
|
0 |
0 |
if( pCur && pCur->pPage==pChild ){ |
|
0 |
0 |
if( pCur && pCur->pPage==pChild ){ |
2254
|
105 |
1 |
if( !pPage->isOverfull ){ |
2269
|
0 |
1 |
if( rc ) return rc; |
2271
|
0 |
1 |
if( rc ) return rc; |
2278
|
1 |
0 |
if( pCur && pCur->pPage==pPage ){ |
|
1 |
0 |
if( pCur && pCur->pPage==pPage ){ |
2285
|
0 |
1 |
pPage->u.hdr.rightChild = SWAB32(pBt, pgnoChild); |
2290
|
0 |
1 |
if( rc ) return rc; |
2298
|
1 |
0 |
if( pParent->idxShift ){ |
2301
|
0 |
1 |
swabPgno = SWAB32(pBt, pgno); |
2302
|
0 |
1 |
for(idx=0; idxnCell; idx++){ |
2303
|
0 |
0 |
if( pParent->apCell[idx]->h.leftChild==swabPgno ){ |
2327
|
1 |
0 |
if( nxDiv + NB > pParent->nCell ){ |
2330
|
1 |
0 |
if( nxDiv<0 ){ |
2334
|
2 |
0 |
for(i=0, k=nxDiv; i
|
2335
|
0 |
2 |
if( knCell ){ |
2339
|
0 |
0 |
pgnoOld[i] = SWAB32(pBt, apDiv[i]->h.leftChild); |
2340
|
1 |
1 |
}else if( k==pParent->nCell ){ |
2341
|
0 |
1 |
pgnoOld[i] = SWAB32(pBt, pParent->u.hdr.rightChild); |
2346
|
0 |
1 |
if( rc ) goto balance_cleanup; |
2348
|
0 |
1 |
if( rc ) goto balance_cleanup; |
2361
|
1 |
0 |
if( pCur ){ |
2363
|
1 |
0 |
for(i=0; i
|
2364
|
1 |
0 |
if( pCur->pPage==apOld[i] ){ |
2369
|
0 |
0 |
if( ipPage==pParent && pCur->idx==idxDiv[i] ){ |
|
0 |
0 |
if( ipPage==pParent && pCur->idx==idxDiv[i] ){ |
|
0 |
0 |
if( ipPage==pParent && pCur->idx==idxDiv[i] ){ |
2383
|
1 |
1 |
for(i=0; i
|
2393
|
1 |
1 |
for(i=0; i
|
2395
|
12 |
1 |
for(j=0; jnCell; j++){ |
2400
|
0 |
1 |
if( i
|
2421
|
12 |
1 |
for(subtotal=k=i=0; i
|
2423
|
1 |
11 |
if( subtotal > USABLE_SPACE ){ |
2433
|
1 |
1 |
for(i=k-1; i>0; i--){ |
2434
|
7 |
1 |
while( szNew[i]
|
2446
|
2 |
1 |
for(i=0; i
|
2447
|
1 |
1 |
if( i
|
2454
|
0 |
1 |
if( rc ) goto balance_cleanup; |
2463
|
0 |
1 |
while( i
|
2465
|
0 |
0 |
if( rc ) goto balance_cleanup; |
2485
|
1 |
1 |
for(i=0; i
|
2488
|
1 |
1 |
for(j=i+1; j
|
2489
|
0 |
1 |
if( pgnoNew[j]<(unsigned)minV ){ |
2494
|
0 |
1 |
if( minI>i ){ |
2511
|
2 |
1 |
for(i=0; i
|
2513
|
11 |
2 |
while( j
|
2515
|
11 |
0 |
if( pCur && iCur==j ){ pCur->pPage = pNew; pCur->idx = pNew->nCell; } |
|
1 |
10 |
if( pCur && iCur==j ){ pCur->pPage = pNew; pCur->idx = pNew->nCell; } |
2522
|
1 |
1 |
if( i
|
|
1 |
0 |
if( i
|
2524
|
0 |
1 |
apCell[j]->h.leftChild = SWAB32(pBt, pgnoNew[i]); |
2525
|
1 |
0 |
if( pCur && iCur==j ){ pCur->pPage = pParent; pCur->idx = nxDiv; } |
|
0 |
1 |
if( pCur && iCur==j ){ pCur->pPage = pParent; pCur->idx = nxDiv; } |
2533
|
1 |
0 |
if( nxDiv==pParent->nCell ){ |
2534
|
0 |
1 |
pParent->u.hdr.rightChild = SWAB32(pBt, pgnoNew[nNew-1]); |
2536
|
0 |
0 |
pParent->apCell[nxDiv]->h.leftChild = SWAB32(pBt, pgnoNew[nNew-1]); |
2538
|
1 |
0 |
if( pCur ){ |
2539
|
0 |
1 |
if( j<=iCur && pCur->pPage==pParent && pCur->idx>idxDiv[nOld-1] ){ |
|
0 |
0 |
if( j<=iCur && pCur->pPage==pParent && pCur->idx>idxDiv[nOld-1] ){ |
|
0 |
0 |
if( j<=iCur && pCur->pPage==pParent && pCur->idx>idxDiv[nOld-1] ){ |
2552
|
2 |
1 |
for(i=0; i
|
2566
|
0 |
1 |
if( extraUnref ){ |
2569
|
1 |
1 |
for(i=0; i
|
2570
|
0 |
1 |
if( apOld[i]!=0 && apOld[i]!=&aOld[i] ) sqlitepager_unref(apOld[i]); |
|
0 |
0 |
if( apOld[i]!=0 && apOld[i]!=&aOld[i] ) sqlitepager_unref(apOld[i]); |
2572
|
2 |
1 |
for(i=0; i
|
2575
|
1 |
0 |
if( pCur && pCur->pPage==0 ){ |
|
0 |
1 |
if( pCur && pCur->pPage==0 ){ |
2602
|
0 |
138 |
for(p=pCur->pShared; p!=pCur; p=p->pShared){ |
2605
|
0 |
0 |
if( p->wrFlag==0 ) return SQLITE_LOCKED; |
2606
|
0 |
0 |
if( sqlitepager_pagenumber(p->pPage)!=p->pgnoRoot ){ |
2631
|
0 |
121 |
if( pCur->pPage==0 ){ |
2634
|
121 |
0 |
if( !pBt->inTrans || nKey+nData==0 ){ |
|
0 |
121 |
if( !pBt->inTrans || nKey+nData==0 ){ |
2636
|
0 |
0 |
return pBt->readOnly ? SQLITE_READONLY : SQLITE_ERROR; |
2639
|
0 |
121 |
if( !pCur->wrFlag ){ |
2642
|
0 |
121 |
if( checkReadLocks(pCur) ){ |
2646
|
0 |
121 |
if( rc ) return rc; |
2650
|
0 |
121 |
if( rc ) return rc; |
2652
|
0 |
121 |
if( rc ) return rc; |
2654
|
22 |
99 |
if( loc==0 ){ |
2657
|
0 |
22 |
if( rc ) return rc; |
2659
|
99 |
0 |
}else if( loc<0 && pPage->nCell>0 ){ |
|
62 |
37 |
}else if( loc<0 && pPage->nCell>0 ){ |
2695
|
0 |
17 |
if( pCur->pPage==0 ){ |
2698
|
0 |
17 |
if( !pBt->inTrans ){ |
2700
|
0 |
0 |
return pBt->readOnly ? SQLITE_READONLY : SQLITE_ERROR; |
2703
|
0 |
17 |
if( pCur->idx >= pPage->nCell ){ |
2706
|
0 |
17 |
if( !pCur->wrFlag ){ |
2709
|
0 |
17 |
if( checkReadLocks(pCur) ){ |
2713
|
0 |
17 |
if( rc ) return rc; |
2715
|
0 |
17 |
pgnoChild = SWAB32(pBt, pCell->h.leftChild); |
2717
|
0 |
17 |
if( pgnoChild ){ |
2731
|
0 |
0 |
if( rc!=SQLITE_OK ){ |
2732
|
0 |
0 |
if( rc!=SQLITE_NOMEM ) rc = SQLITE_CORRUPT; |
2736
|
0 |
0 |
if( rc ) return rc; |
2740
|
0 |
0 |
pNext->h.leftChild = SWAB32(pBt, pgnoChild); |
2743
|
0 |
0 |
if( rc ) return rc; |
2750
|
15 |
2 |
if( pCur->idx>=pPage->nCell ){ |
2752
|
13 |
2 |
if( pCur->idx<0 ){ |
2780
|
0 |
27 |
if( !pBt->inTrans ){ |
2782
|
0 |
0 |
return pBt->readOnly ? SQLITE_READONLY : SQLITE_ERROR; |
2784
|
0 |
27 |
if( pBt->readOnly ){ |
2788
|
0 |
27 |
if( rc ) return rc; |
2807
|
0 |
11 |
if( rc ) return rc; |
2809
|
0 |
11 |
if( rc ) return rc; |
2811
|
0 |
11 |
if( rc ) return rc; |
2812
|
0 |
11 |
idx = SWAB16(pBt, pPage->u.hdr.firstCell); |
2813
|
19 |
11 |
while( idx>0 ){ |
2815
|
0 |
19 |
idx = SWAB16(pBt, pCell->h.iNext); |
2816
|
0 |
19 |
if( pCell->h.leftChild ){ |
2817
|
0 |
0 |
rc = clearDatabasePage(pBt, SWAB32(pBt, pCell->h.leftChild), 1); |
2818
|
0 |
0 |
if( rc ) return rc; |
2821
|
0 |
19 |
if( rc ) return rc; |
2823
|
0 |
11 |
if( pPage->u.hdr.rightChild ){ |
2824
|
0 |
0 |
rc = clearDatabasePage(pBt, SWAB32(pBt, pPage->u.hdr.rightChild), 1); |
2825
|
0 |
0 |
if( rc ) return rc; |
2827
|
0 |
11 |
if( freePageFlag ){ |
2842
|
0 |
11 |
if( !pBt->inTrans ){ |
2843
|
0 |
0 |
return pBt->readOnly ? SQLITE_READONLY : SQLITE_ERROR; |
2845
|
0 |
11 |
for(pCur=pBt->pCursor; pCur; pCur=pCur->pNext){ |
2846
|
0 |
0 |
if( pCur->pgnoRoot==(Pgno)iTable ){ |
2847
|
0 |
0 |
if( pCur->wrFlag==0 ) return SQLITE_LOCKED; |
2852
|
0 |
11 |
if( rc ){ |
2867
|
0 |
11 |
if( !pBt->inTrans ){ |
2868
|
0 |
0 |
return pBt->readOnly ? SQLITE_READONLY : SQLITE_ERROR; |
2870
|
0 |
11 |
for(pCur=pBt->pCursor; pCur; pCur=pCur->pNext){ |
2871
|
0 |
0 |
if( pCur->pgnoRoot==(Pgno)iTable ){ |
2876
|
0 |
11 |
if( rc ) return rc; |
2878
|
0 |
11 |
if( rc ) return rc; |
2879
|
11 |
0 |
if( iTable>2 ){ |
2996
|
0 |
254 |
if( rc ) return rc; |
2997
|
0 |
254 |
aMeta[0] = SWAB32(pBt, pP1->nFree); |
2998
|
2286 |
254 |
for(i=0; iaMeta)/sizeof(pP1->aMeta[0]); i++){ |
2999
|
0 |
2286 |
aMeta[i+1] = SWAB32(pBt, pP1->aMeta[i]); |
3011
|
0 |
53 |
if( !pBt->inTrans ){ |
3012
|
0 |
0 |
return pBt->readOnly ? SQLITE_READONLY : SQLITE_ERROR; |
3016
|
0 |
53 |
if( rc ) return rc; |
3017
|
477 |
53 |
for(i=0; iaMeta)/sizeof(pP1->aMeta[0]); i++){ |
3018
|
0 |
477 |
pP1->aMeta[i] = SWAB32(pBt, aMeta[i+1]); |
3173
|
0 |
0 |
if( pCheck->zErrMsg ){ |
3192
|
0 |
0 |
if( iPage==0 ) return 1; |
3193
|
0 |
0 |
if( iPage>pCheck->nPage || iPage<0 ){ |
|
0 |
0 |
if( iPage>pCheck->nPage || iPage<0 ){ |
3199
|
0 |
0 |
if( pCheck->anRef[iPage]==1 ){ |
3221
|
0 |
0 |
while( N-- > 0 ){ |
3223
|
0 |
0 |
if( iPage<1 ){ |
3228
|
0 |
0 |
if( checkRef(pCheck, iPage, zContext) ) break; |
3229
|
0 |
0 |
if( sqlitepager_get(pCheck->pPager, (Pgno)iPage, (void**)&pOvfl) ){ |
3234
|
0 |
0 |
if( isFreeList ){ |
3236
|
0 |
0 |
int n = SWAB32(pCheck->pBt, pInfo->nFree); |
3237
|
0 |
0 |
for(i=0; i
|
3238
|
0 |
0 |
checkRef(pCheck, SWAB32(pCheck->pBt, pInfo->aFree[i]), zContext); |
3242
|
0 |
0 |
iPage = SWAB32(pCheck->pBt, pOvfl->iNext); |
3258
|
0 |
0 |
if( c==0 ){ |
3305
|
0 |
0 |
if( iPage==0 ) return 0; |
3306
|
0 |
0 |
if( checkRef(pCheck, iPage, zParentContext) ) return 0; |
3308
|
0 |
0 |
if( (rc = sqlitepager_get(pCheck->pPager, (Pgno)iPage, (void**)&pPage))!=0 ){ |
3313
|
0 |
0 |
if( (rc = initPage(pBt, pPage, (Pgno)iPage, pParent))!=0 ){ |
3323
|
0 |
0 |
if( zLowerBound ){ |
3332
|
0 |
0 |
for(i=0; inCell; i++){ |
3338
|
0 |
0 |
nKey2 = NKEY(pBt, pCell->h); |
3339
|
0 |
0 |
sz = nKey2 + NDATA(pBt, pCell->h); |
3341
|
0 |
0 |
if( sz>MX_LOCAL_PAYLOAD ){ |
3343
|
0 |
0 |
checkList(pCheck, 0, SWAB32(pBt, pCell->ovfl), nPage, zContext); |
3351
|
0 |
0 |
if( zKey1 && keyCompare(zKey1, nKey1, zKey2, nKey2)>=0 ){ |
|
0 |
0 |
if( zKey1 && keyCompare(zKey1, nKey1, zKey2, nKey2)>=0 ){ |
3357
|
0 |
0 |
pgno = SWAB32(pBt, pCell->h.leftChild); |
3359
|
0 |
0 |
if( i>0 && d2!=depth ){ |
|
0 |
0 |
if( i>0 && d2!=depth ){ |
3367
|
0 |
0 |
pgno = SWAB32(pBt, pPage->u.hdr.rightChild); |
3376
|
0 |
0 |
for(i=SWAB16(pBt, pPage->u.hdr.firstCell); i>0 && i
|
|
0 |
0 |
for(i=SWAB16(pBt, pPage->u.hdr.firstCell); i>0 && i
|
|
0 |
0 |
for(i=SWAB16(pBt, pPage->u.hdr.firstCell); i>0 && i
|
3379
|
0 |
0 |
for(j=i+cellSize(pBt, pCell)-1; j>=i; j--) hit[j]++; |
3380
|
0 |
0 |
i = SWAB16(pBt, pCell->h.iNext); |
3382
|
0 |
0 |
for(i=SWAB16(pBt,pPage->u.hdr.firstFree); i>0 && i
|
|
0 |
0 |
for(i=SWAB16(pBt,pPage->u.hdr.firstFree); i>0 && i
|
|
0 |
0 |
for(i=SWAB16(pBt,pPage->u.hdr.firstFree); i>0 && i
|
3385
|
0 |
0 |
for(j=i+SWAB16(pBt,pFBlk->iSize)-1; j>=i; j--) hit[j]++; |
|
0 |
0 |
for(j=i+SWAB16(pBt,pFBlk->iSize)-1; j>=i; j--) hit[j]++; |
3386
|
0 |
0 |
i = SWAB16(pBt,pFBlk->iNext); |
3388
|
0 |
0 |
for(i=0; i
|
3389
|
0 |
0 |
if( hit[i]==0 ){ |
3393
|
0 |
0 |
}else if( hit[i]>1 ){ |
3430
|
0 |
0 |
if( lockBtree(pBt)!=SQLITE_OK ){ |
3436
|
0 |
0 |
if( sCheck.nPage==0 ){ |
3442
|
0 |
0 |
for(i=2; i<=sCheck.nPage; i++){ sCheck.anRef[i] = 0; } |
3447
|
0 |
0 |
checkList(&sCheck, 1, SWAB32(pBt, pBt->page1->freeList), |
|
0 |
0 |
checkList(&sCheck, 1, SWAB32(pBt, pBt->page1->freeList), |
3452
|
0 |
0 |
for(i=0; i
|
3453
|
0 |
0 |
if( aRoot[i]==0 ) continue; |
3459
|
0 |
0 |
for(i=1; i<=sCheck.nPage; i++){ |
3460
|
0 |
0 |
if( sCheck.anRef[i]==0 ){ |
3470
|
0 |
0 |
if( nRef != *sqlitepager_stats(pBt->pPager) ){ |
3504
|
0 |
0 |
if( !pBtTo->inTrans || !pBtFrom->inTrans ) return SQLITE_ERROR; |
|
0 |
0 |
if( !pBtTo->inTrans || !pBtFrom->inTrans ) return SQLITE_ERROR; |
3505
|
0 |
0 |
if( pBtTo->needSwab!=pBtFrom->needSwab ) return SQLITE_ERROR; |
3506
|
0 |
0 |
if( pBtTo->pCursor ) return SQLITE_BUSY; |
3511
|
0 |
0 |
for(i=2; rc==SQLITE_OK && i<=nPage; i++){ |
|
0 |
0 |
for(i=2; rc==SQLITE_OK && i<=nPage; i++){ |
3514
|
0 |
0 |
if( rc ) break; |
3516
|
0 |
0 |
if( rc ) break; |
3519
|
0 |
0 |
for(i=nPage+1; rc==SQLITE_OK && i<=nToPage; i++){ |
|
0 |
0 |
for(i=nPage+1; rc==SQLITE_OK && i<=nToPage; i++){ |
3522
|
0 |
0 |
if( rc ) break; |
3527
|
0 |
0 |
if( !rc && nPage
|
|
0 |
0 |
if( !rc && nPage
|
3530
|
0 |
0 |
if( rc ){ |