Instead of storing a pointer to the parent page in the MemPage structure, have each B-Tree cursor keep track of the ancestry of the current page. (CVS 5747)
FossilOrigin-Name: 40425e93421286cca1965d7a5769084526210c7a
This commit is contained in:
parent
d0507d691e
commit
71d5d2cd49
30
manifest
30
manifest
@ -1,5 +1,5 @@
|
|||||||
C fix\s#3077:\suse\sfull\sversion\sin\spkg-config\sfiles\s(CVS\s5746)
|
C Instead\sof\sstoring\sa\spointer\sto\sthe\sparent\spage\sin\sthe\sMemPage\sstructure,\shave\seach\sB-Tree\scursor\skeep\strack\sof\sthe\sancestry\sof\sthe\scurrent\spage.\s(CVS\s5747)
|
||||||
D 2008-09-29T00:11:22
|
D 2008-09-29T11:49:48
|
||||||
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
||||||
F Makefile.in e4ab842f9a64ef61d57093539a8aab76b12810db
|
F Makefile.in e4ab842f9a64ef61d57093539a8aab76b12810db
|
||||||
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
||||||
@ -99,9 +99,9 @@ F src/attach.c db3f4a60538733c1e4dcb9d0217a6e0d6ccd615b
|
|||||||
F src/auth.c c8b2ab5c8bad4bd90ed7c294694f48269162c627
|
F src/auth.c c8b2ab5c8bad4bd90ed7c294694f48269162c627
|
||||||
F src/bitvec.c 95c86bd18d8fedf0533f5af196192546e10a7e7d
|
F src/bitvec.c 95c86bd18d8fedf0533f5af196192546e10a7e7d
|
||||||
F src/btmutex.c 709cad2cdca0afd013f0f612363810e53f59ec53
|
F src/btmutex.c 709cad2cdca0afd013f0f612363810e53f59ec53
|
||||||
F src/btree.c 850d7ede7fe58f8bfad78131278ceff83817abf5
|
F src/btree.c 8fc7c0bd577e0e8850d95b0f8d927c983e53deab
|
||||||
F src/btree.h 6371c5e599fab391a150c96afbc10062b276d107
|
F src/btree.h 6371c5e599fab391a150c96afbc10062b276d107
|
||||||
F src/btreeInt.h e36f77e6621d671beb19ae581af1eba116cdfdc4
|
F src/btreeInt.h a9388a5e5998cec0b79c2024e6740d12d094ad17
|
||||||
F src/build.c 160c71acca8f643f436ed6c1ee2f684c88df4dfe
|
F src/build.c 160c71acca8f643f436ed6c1ee2f684c88df4dfe
|
||||||
F src/callback.c 7a40fd44da3eb89e7f6eff30aa6f940c45d73a97
|
F src/callback.c 7a40fd44da3eb89e7f6eff30aa6f940c45d73a97
|
||||||
F src/complete.c cb14e06dbe79dee031031f0d9e686ff306afe07c
|
F src/complete.c cb14e06dbe79dee031031f0d9e686ff306afe07c
|
||||||
@ -137,11 +137,11 @@ F src/os_common.h 24525d8b7bce66c374dfc1810a6c9043f3359b60
|
|||||||
F src/os_os2.c e391fc95adc744bbdcefd4d11e3066998185a0a0
|
F src/os_os2.c e391fc95adc744bbdcefd4d11e3066998185a0a0
|
||||||
F src/os_unix.c f33b69d8a85372b270fe37ee664a4c2140a5217d
|
F src/os_unix.c f33b69d8a85372b270fe37ee664a4c2140a5217d
|
||||||
F src/os_win.c 3209dc0ed734291764393ea8d534ba0d8696a540
|
F src/os_win.c 3209dc0ed734291764393ea8d534ba0d8696a540
|
||||||
F src/pager.c 6426902ba983ce6872fcec20ba72796a79d6cead
|
F src/pager.c 44eba010e81dcc9b772401b90d6a1c61ec24345b
|
||||||
F src/pager.h 30e71f447ecbcfef707bb72cc813ce37ab5a2bc9
|
F src/pager.h 9c1917be28fff58118e1fe0ddbc7adfb8dd4f44d
|
||||||
F src/parse.y d0f76d2cb8d6883d5600dc20beb961a6022b94b8
|
F src/parse.y d0f76d2cb8d6883d5600dc20beb961a6022b94b8
|
||||||
F src/pcache.c 52108517c38bcf023f3977085a66aacb520a5385
|
F src/pcache.c f8d7beceba164a34441ac37e88abb3a404f968a7
|
||||||
F src/pcache.h 0b6871e820159629915e8688b5c67a81a203773f
|
F src/pcache.h 28d9ce2d66909db1f01652586450b62b64793093
|
||||||
F src/pragma.c 0b1c2d2a241dd79a7361bbeb8ff575a9e9d7cd71
|
F src/pragma.c 0b1c2d2a241dd79a7361bbeb8ff575a9e9d7cd71
|
||||||
F src/prepare.c c7e00ed1b0bdcf699b1aad651247d4dc3d281b0b
|
F src/prepare.c c7e00ed1b0bdcf699b1aad651247d4dc3d281b0b
|
||||||
F src/printf.c 785f87120589c1db672e37c6eb1087c456e6f84d
|
F src/printf.c 785f87120589c1db672e37c6eb1087c456e6f84d
|
||||||
@ -157,7 +157,7 @@ F src/status.c 237b193efae0cf6ac3f0817a208de6c6c6ef6d76
|
|||||||
F src/table.c 22744786199c9195720c15a7a42cb97b2e2728d8
|
F src/table.c 22744786199c9195720c15a7a42cb97b2e2728d8
|
||||||
F src/tclsqlite.c 6a7eeff5afd8f5f10fcb7fd7806e56c725dd2b07
|
F src/tclsqlite.c 6a7eeff5afd8f5f10fcb7fd7806e56c725dd2b07
|
||||||
F src/test1.c c4de690aad182606e5914f6f3c8f43869fbdaaa8
|
F src/test1.c c4de690aad182606e5914f6f3c8f43869fbdaaa8
|
||||||
F src/test2.c eaa77124786649eedf47d3c5e94d8070c0da228f
|
F src/test2.c 897528183edf2839c2a3c991d415905db56f1240
|
||||||
F src/test3.c e85b7ce5c28c3ce7fbdbf7f98e1467b19786c62b
|
F src/test3.c e85b7ce5c28c3ce7fbdbf7f98e1467b19786c62b
|
||||||
F src/test4.c 41056378671e7b00e6305fa9ac6fa27e6f96f406
|
F src/test4.c 41056378671e7b00e6305fa9ac6fa27e6f96f406
|
||||||
F src/test5.c 162a1cea2105a2c460a3f39fa6919617b562a288
|
F src/test5.c 162a1cea2105a2c460a3f39fa6919617b562a288
|
||||||
@ -167,7 +167,7 @@ F src/test8.c 3637439424d0d21ff2dcf9b015c30fcc1e7bcb24
|
|||||||
F src/test9.c 904ebe0ed1472d6bad17a81e2ecbfc20017dc237
|
F src/test9.c 904ebe0ed1472d6bad17a81e2ecbfc20017dc237
|
||||||
F src/test_async.c 45024094ed7cf780c5d5dccda645145f95cf78ef
|
F src/test_async.c 45024094ed7cf780c5d5dccda645145f95cf78ef
|
||||||
F src/test_autoext.c f53b0cdf7bf5f08100009572a5d65cdb540bd0ad
|
F src/test_autoext.c f53b0cdf7bf5f08100009572a5d65cdb540bd0ad
|
||||||
F src/test_btree.c 8d5b835054f1dd15992e09864a8bc04386bab701
|
F src/test_btree.c d7b8716544611c323860370ee364e897c861f1b0
|
||||||
F src/test_config.c db72e95bafdd53c05ceb8735f833cc5dc1f48782
|
F src/test_config.c db72e95bafdd53c05ceb8735f833cc5dc1f48782
|
||||||
F src/test_devsym.c 802d10e65b4217208cb47059b84adf46318bcdf4
|
F src/test_devsym.c 802d10e65b4217208cb47059b84adf46318bcdf4
|
||||||
F src/test_func.c a55c4d5479ff2eb5c0a22d4d88e9528ab59c953b
|
F src/test_func.c a55c4d5479ff2eb5c0a22d4d88e9528ab59c953b
|
||||||
@ -253,7 +253,7 @@ F test/colmeta.test 087c42997754b8c648819832241daf724f813322
|
|||||||
F test/colname.test 0f05fea3e5c9260ece53117ad400657515c34280
|
F test/colname.test 0f05fea3e5c9260ece53117ad400657515c34280
|
||||||
F test/conflict.test bb29b052c60a1f7eb6382be77902061d1f305318
|
F test/conflict.test bb29b052c60a1f7eb6382be77902061d1f305318
|
||||||
F test/corrupt.test 5bcf7a986358123b8055dfa64b45fc2fb54dcaa9
|
F test/corrupt.test 5bcf7a986358123b8055dfa64b45fc2fb54dcaa9
|
||||||
F test/corrupt2.test 08fb049fdf4f72902ff39b1c609e7c1c2e985d8b
|
F test/corrupt2.test b83f690753525ddac4a9c96e6ba11886ddaf24ea
|
||||||
F test/corrupt3.test 263e8bb04e2728df832fddf6973cf54c91db0c32
|
F test/corrupt3.test 263e8bb04e2728df832fddf6973cf54c91db0c32
|
||||||
F test/corrupt4.test acdb01afaedf529004b70e55de1a6f5a05ae7fff
|
F test/corrupt4.test acdb01afaedf529004b70e55de1a6f5a05ae7fff
|
||||||
F test/corrupt5.test 7796d5bdfe155ed824cee9dff371f49da237cfe0
|
F test/corrupt5.test 7796d5bdfe155ed824cee9dff371f49da237cfe0
|
||||||
@ -637,7 +637,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
|
|||||||
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
||||||
F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1
|
F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1
|
||||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||||
P 7c561f2e9264de676c1028943f6c3d06542fd802
|
P efe095e0cb8e0f8a11fd9cc321ec83b556458bf2
|
||||||
R 02a6492d8d58a0069722b4e87a758448
|
R a0f3c37847099f2dcfb6efb98a6a77ac
|
||||||
U vapier
|
U danielk1977
|
||||||
Z f2828935781c5b8b7b8d7e5f72f7da88
|
Z 079550270237333fc6211bd885a42871
|
||||||
|
@ -1 +1 @@
|
|||||||
efe095e0cb8e0f8a11fd9cc321ec83b556458bf2
|
40425e93421286cca1965d7a5769084526210c7a
|
632
src/btree.c
632
src/btree.c
File diff suppressed because it is too large
Load Diff
@ -9,7 +9,7 @@
|
|||||||
** May you share freely, never taking more than you give.
|
** May you share freely, never taking more than you give.
|
||||||
**
|
**
|
||||||
*************************************************************************
|
*************************************************************************
|
||||||
** $Id: btreeInt.h,v 1.31 2008/09/18 17:34:44 danielk1977 Exp $
|
** $Id: btreeInt.h,v 1.32 2008/09/29 11:49:48 danielk1977 Exp $
|
||||||
**
|
**
|
||||||
** This file implements a external (disk-based) database using BTrees.
|
** This file implements a external (disk-based) database using BTrees.
|
||||||
** For a detailed discussion of BTrees, refer to
|
** For a detailed discussion of BTrees, refer to
|
||||||
@ -281,7 +281,6 @@ struct MemPage {
|
|||||||
u16 maxLocal; /* Copy of BtShared.maxLocal or BtShared.maxLeaf */
|
u16 maxLocal; /* Copy of BtShared.maxLocal or BtShared.maxLeaf */
|
||||||
u16 minLocal; /* Copy of BtShared.minLocal or BtShared.minLeaf */
|
u16 minLocal; /* Copy of BtShared.minLocal or BtShared.minLeaf */
|
||||||
u16 cellOffset; /* Index in aData of first cell pointer */
|
u16 cellOffset; /* Index in aData of first cell pointer */
|
||||||
u16 idxParent; /* Index in parent of this node */
|
|
||||||
u16 nFree; /* Number of free bytes on the page */
|
u16 nFree; /* Number of free bytes on the page */
|
||||||
u16 nCell; /* Number of cells on this page, local and ovfl */
|
u16 nCell; /* Number of cells on this page, local and ovfl */
|
||||||
u16 maskPage; /* Mask for page offset */
|
u16 maskPage; /* Mask for page offset */
|
||||||
@ -293,21 +292,8 @@ struct MemPage {
|
|||||||
u8 *aData; /* Pointer to disk image of the page data */
|
u8 *aData; /* Pointer to disk image of the page data */
|
||||||
DbPage *pDbPage; /* Pager page handle */
|
DbPage *pDbPage; /* Pager page handle */
|
||||||
Pgno pgno; /* Page number for this page */
|
Pgno pgno; /* Page number for this page */
|
||||||
MemPage *pParent; /* The parent of this page. NULL for root */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
** Possible values for the MemPage.isInit variable. When a page is first
|
|
||||||
** loaded or if the data stored in the MemPage struct is invalidated,
|
|
||||||
** MemPage.isInit is set to PAGE_ISINIT_NONE. If the MemPage structure
|
|
||||||
** is fully initialized, then MemPage.isInit is set to PAGE_ISINIT_FULL.
|
|
||||||
** MemPage.isInit is set to PAGE_ISINIT_DATA when the MemPage struct is
|
|
||||||
** populated, but the MemPage.pParent variable is not necessarily correct.
|
|
||||||
*/
|
|
||||||
#define PAGE_ISINIT_NONE 0
|
|
||||||
#define PAGE_ISINIT_DATA 1
|
|
||||||
#define PAGE_ISINIT_FULL 2
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** The in-memory image of a disk page has the auxiliary information appended
|
** The in-memory image of a disk page has the auxiliary information appended
|
||||||
** to the end. EXTRA_SIZE is the number of bytes of space needed to hold
|
** to the end. EXTRA_SIZE is the number of bytes of space needed to hold
|
||||||
@ -426,6 +412,17 @@ struct CellInfo {
|
|||||||
u16 nSize; /* Size of the cell content on the main b-tree page */
|
u16 nSize; /* Size of the cell content on the main b-tree page */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Maximum depth of an SQLite B-Tree structure. Any B-Tree deeper than
|
||||||
|
** this will be declared corrupt. This value is calculated based on a
|
||||||
|
** maximum database size of 2^31 pages a minimum fanout of 2 for a
|
||||||
|
** root-node and 3 for all other internal nodes.
|
||||||
|
**
|
||||||
|
** If a tree that appears to be taller than this is encountered, it is
|
||||||
|
** assumed that the database is corrupt.
|
||||||
|
*/
|
||||||
|
#define BTCURSOR_MAX_DEPTH 20
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** A cursor is a pointer to a particular entry within a particular
|
** A cursor is a pointer to a particular entry within a particular
|
||||||
** b-tree within a database file.
|
** b-tree within a database file.
|
||||||
@ -446,8 +443,6 @@ struct BtCursor {
|
|||||||
BtCursor *pNext, *pPrev; /* Forms a linked list of all cursors */
|
BtCursor *pNext, *pPrev; /* Forms a linked list of all cursors */
|
||||||
struct KeyInfo *pKeyInfo; /* Argument passed to comparison function */
|
struct KeyInfo *pKeyInfo; /* Argument passed to comparison function */
|
||||||
Pgno pgnoRoot; /* The root page of this tree */
|
Pgno pgnoRoot; /* The root page of this tree */
|
||||||
MemPage *pPage; /* Page that contains the entry */
|
|
||||||
int idx; /* Index of the entry in pPage->aCell[] */
|
|
||||||
CellInfo info; /* A parse of the cell we are pointing at */
|
CellInfo info; /* A parse of the cell we are pointing at */
|
||||||
u8 wrFlag; /* True if writable */
|
u8 wrFlag; /* True if writable */
|
||||||
u8 atLast; /* Cursor pointing to the last entry */
|
u8 atLast; /* Cursor pointing to the last entry */
|
||||||
@ -460,6 +455,10 @@ struct BtCursor {
|
|||||||
u8 isIncrblobHandle; /* True if this cursor is an incr. io handle */
|
u8 isIncrblobHandle; /* True if this cursor is an incr. io handle */
|
||||||
Pgno *aOverflow; /* Cache of overflow page locations */
|
Pgno *aOverflow; /* Cache of overflow page locations */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
i16 iPage; /* Index of current page in apPage */
|
||||||
|
MemPage *apPage[BTCURSOR_MAX_DEPTH]; /* Pages from root to current page */
|
||||||
|
u16 aiIdx[BTCURSOR_MAX_DEPTH]; /* Current index in apPage[i] */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -629,11 +628,10 @@ struct IntegrityCk {
|
|||||||
** Internal routines that should be accessed by the btree layer only.
|
** Internal routines that should be accessed by the btree layer only.
|
||||||
*/
|
*/
|
||||||
int sqlite3BtreeGetPage(BtShared*, Pgno, MemPage**, int);
|
int sqlite3BtreeGetPage(BtShared*, Pgno, MemPage**, int);
|
||||||
int sqlite3BtreeInitPage(MemPage *pPage, MemPage *pParent);
|
int sqlite3BtreeInitPage(MemPage *pPage);
|
||||||
void sqlite3BtreeParseCellPtr(MemPage*, u8*, CellInfo*);
|
void sqlite3BtreeParseCellPtr(MemPage*, u8*, CellInfo*);
|
||||||
void sqlite3BtreeParseCell(MemPage*, int, CellInfo*);
|
void sqlite3BtreeParseCell(MemPage*, int, CellInfo*);
|
||||||
int sqlite3BtreeRestoreCursorPosition(BtCursor *pCur);
|
int sqlite3BtreeRestoreCursorPosition(BtCursor *pCur);
|
||||||
void sqlite3BtreeGetTempCursor(BtCursor *pCur, BtCursor *pTempCur);
|
void sqlite3BtreeGetTempCursor(BtCursor *pCur, BtCursor *pTempCur);
|
||||||
void sqlite3BtreeReleaseTempCursor(BtCursor *pCur);
|
void sqlite3BtreeReleaseTempCursor(BtCursor *pCur);
|
||||||
int sqlite3BtreeIsRootPage(MemPage *pPage);
|
|
||||||
void sqlite3BtreeMoveToParent(BtCursor *pCur);
|
void sqlite3BtreeMoveToParent(BtCursor *pCur);
|
||||||
|
14
src/pager.c
14
src/pager.c
@ -18,7 +18,7 @@
|
|||||||
** file simultaneously, or one process from reading the database while
|
** file simultaneously, or one process from reading the database while
|
||||||
** another is writing.
|
** another is writing.
|
||||||
**
|
**
|
||||||
** @(#) $Id: pager.c,v 1.495 2008/09/26 21:08:08 drh Exp $
|
** @(#) $Id: pager.c,v 1.496 2008/09/29 11:49:48 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#ifndef SQLITE_OMIT_DISKIO
|
#ifndef SQLITE_OMIT_DISKIO
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
@ -1728,7 +1728,6 @@ int sqlite3PagerOpen(
|
|||||||
sqlite3_vfs *pVfs, /* The virtual file system to use */
|
sqlite3_vfs *pVfs, /* The virtual file system to use */
|
||||||
Pager **ppPager, /* Return the Pager structure here */
|
Pager **ppPager, /* Return the Pager structure here */
|
||||||
const char *zFilename, /* Name of the database file to open */
|
const char *zFilename, /* Name of the database file to open */
|
||||||
void (*xDesc)(DbPage*), /* Page destructor function */
|
|
||||||
int nExtra, /* Extra bytes append to each in-memory page */
|
int nExtra, /* Extra bytes append to each in-memory page */
|
||||||
int flags, /* flags controlling this file */
|
int flags, /* flags controlling this file */
|
||||||
int vfsFlags /* flags passed through to sqlite3_vfs.xOpen() */
|
int vfsFlags /* flags passed through to sqlite3_vfs.xOpen() */
|
||||||
@ -1870,7 +1869,7 @@ int sqlite3PagerOpen(
|
|||||||
return ((rc==SQLITE_OK)?SQLITE_NOMEM:rc);
|
return ((rc==SQLITE_OK)?SQLITE_NOMEM:rc);
|
||||||
}
|
}
|
||||||
nExtra = FORCE_ALIGNMENT(nExtra);
|
nExtra = FORCE_ALIGNMENT(nExtra);
|
||||||
sqlite3PcacheOpen(szPageDflt, nExtra, !memDb, xDesc,
|
sqlite3PcacheOpen(szPageDflt, nExtra, !memDb,
|
||||||
!memDb?pagerStress:0, (void *)pPager, pPager->pPCache);
|
!memDb?pagerStress:0, (void *)pPager, pPager->pPCache);
|
||||||
|
|
||||||
PAGERTRACE3("OPEN %d %s\n", FILEHANDLEID(pPager->fd), pPager->zFilename);
|
PAGERTRACE3("OPEN %d %s\n", FILEHANDLEID(pPager->fd), pPager->zFilename);
|
||||||
@ -3875,6 +3874,13 @@ int sqlite3PagerRefcount(Pager *pPager){
|
|||||||
return sqlite3PcacheRefCount(pPager->pPCache);
|
return sqlite3PcacheRefCount(pPager->pPCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Return the number of references to the specified page.
|
||||||
|
*/
|
||||||
|
int sqlite3PagerPageRefcount(DbPage *pPage){
|
||||||
|
return sqlite3PcachePageRefcount(pPage);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef SQLITE_TEST
|
#ifdef SQLITE_TEST
|
||||||
/*
|
/*
|
||||||
** This routine is used for testing and analysis only.
|
** This routine is used for testing and analysis only.
|
||||||
@ -4176,7 +4182,7 @@ int sqlite3PagerMovepage(Pager *pPager, DbPage *pPg, Pgno pgno, int isCommit){
|
|||||||
** Return a pointer to the data for the specified page.
|
** Return a pointer to the data for the specified page.
|
||||||
*/
|
*/
|
||||||
void *sqlite3PagerGetData(DbPage *pPg){
|
void *sqlite3PagerGetData(DbPage *pPg){
|
||||||
assert( pPg->nRef>0 );
|
assert( pPg->nRef>0 || pPg->pPager->memDb );
|
||||||
return pPg->pData;
|
return pPg->pData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
** subsystem. The page cache subsystem reads and writes a file a page
|
** subsystem. The page cache subsystem reads and writes a file a page
|
||||||
** at a time and provides a journal for rollback.
|
** at a time and provides a journal for rollback.
|
||||||
**
|
**
|
||||||
** @(#) $Id: pager.h,v 1.84 2008/09/26 21:08:08 drh Exp $
|
** @(#) $Id: pager.h,v 1.85 2008/09/29 11:49:48 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _PAGER_H_
|
#ifndef _PAGER_H_
|
||||||
@ -71,7 +71,7 @@ typedef struct PgHdr DbPage;
|
|||||||
** See source code comments for a detailed description of the following
|
** See source code comments for a detailed description of the following
|
||||||
** routines:
|
** routines:
|
||||||
*/
|
*/
|
||||||
int sqlite3PagerOpen(sqlite3_vfs *, Pager **ppPager, const char*, void(*)(DbPage*), int,int,int);
|
int sqlite3PagerOpen(sqlite3_vfs *, Pager **ppPager, const char*, int,int,int);
|
||||||
void sqlite3PagerSetBusyhandler(Pager*, BusyHandler *pBusyHandler);
|
void sqlite3PagerSetBusyhandler(Pager*, BusyHandler *pBusyHandler);
|
||||||
void sqlite3PagerSetReiniter(Pager*, void(*)(DbPage*));
|
void sqlite3PagerSetReiniter(Pager*, void(*)(DbPage*));
|
||||||
int sqlite3PagerSetPagesize(Pager*, u16*);
|
int sqlite3PagerSetPagesize(Pager*, u16*);
|
||||||
@ -82,6 +82,7 @@ int sqlite3PagerClose(Pager *pPager);
|
|||||||
int sqlite3PagerAcquire(Pager *pPager, Pgno pgno, DbPage **ppPage, int clrFlag);
|
int sqlite3PagerAcquire(Pager *pPager, Pgno pgno, DbPage **ppPage, int clrFlag);
|
||||||
#define sqlite3PagerGet(A,B,C) sqlite3PagerAcquire(A,B,C,0)
|
#define sqlite3PagerGet(A,B,C) sqlite3PagerAcquire(A,B,C,0)
|
||||||
DbPage *sqlite3PagerLookup(Pager *pPager, Pgno pgno);
|
DbPage *sqlite3PagerLookup(Pager *pPager, Pgno pgno);
|
||||||
|
int sqlite3PagerPageRefcount(DbPage*);
|
||||||
int sqlite3PagerRef(DbPage*);
|
int sqlite3PagerRef(DbPage*);
|
||||||
int sqlite3PagerUnref(DbPage*);
|
int sqlite3PagerUnref(DbPage*);
|
||||||
int sqlite3PagerWrite(DbPage*);
|
int sqlite3PagerWrite(DbPage*);
|
||||||
|
12
src/pcache.c
12
src/pcache.c
@ -11,7 +11,7 @@
|
|||||||
*************************************************************************
|
*************************************************************************
|
||||||
** This file implements that page cache.
|
** This file implements that page cache.
|
||||||
**
|
**
|
||||||
** @(#) $Id: pcache.c,v 1.32 2008/09/24 09:12:47 danielk1977 Exp $
|
** @(#) $Id: pcache.c,v 1.33 2008/09/29 11:49:48 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
|
|
||||||
@ -43,7 +43,6 @@ struct PCache {
|
|||||||
int szPage; /* Size of every page in this cache */
|
int szPage; /* Size of every page in this cache */
|
||||||
int szExtra; /* Size of extra space for each page */
|
int szExtra; /* Size of extra space for each page */
|
||||||
int bPurgeable; /* True if pages are on backing store */
|
int bPurgeable; /* True if pages are on backing store */
|
||||||
void (*xDestroy)(PgHdr*); /* Called when refcnt goes 1->0 */
|
|
||||||
int (*xStress)(void*,PgHdr*); /* Call to try make a page clean */
|
int (*xStress)(void*,PgHdr*); /* Call to try make a page clean */
|
||||||
void *pStress; /* Argument to xStress */
|
void *pStress; /* Argument to xStress */
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
@ -643,7 +642,6 @@ void sqlite3PcacheOpen(
|
|||||||
int szPage, /* Size of every page */
|
int szPage, /* Size of every page */
|
||||||
int szExtra, /* Extra space associated with each page */
|
int szExtra, /* Extra space associated with each page */
|
||||||
int bPurgeable, /* True if pages are on backing store */
|
int bPurgeable, /* True if pages are on backing store */
|
||||||
void (*xDestroy)(PgHdr*), /* Called to destroy a page */
|
|
||||||
int (*xStress)(void*,PgHdr*),/* Call to try to make pages clean */
|
int (*xStress)(void*,PgHdr*),/* Call to try to make pages clean */
|
||||||
void *pStress, /* Argument to xStress */
|
void *pStress, /* Argument to xStress */
|
||||||
PCache *p /* Preallocated space for the PCache */
|
PCache *p /* Preallocated space for the PCache */
|
||||||
@ -653,7 +651,6 @@ void sqlite3PcacheOpen(
|
|||||||
p->szPage = szPage;
|
p->szPage = szPage;
|
||||||
p->szExtra = szExtra;
|
p->szExtra = szExtra;
|
||||||
p->bPurgeable = bPurgeable;
|
p->bPurgeable = bPurgeable;
|
||||||
p->xDestroy = xDestroy;
|
|
||||||
p->xStress = xStress;
|
p->xStress = xStress;
|
||||||
p->pStress = pStress;
|
p->pStress = pStress;
|
||||||
p->nMax = 100;
|
p->nMax = 100;
|
||||||
@ -752,9 +749,6 @@ void sqlite3PcacheRelease(PgHdr *p){
|
|||||||
p->nRef--;
|
p->nRef--;
|
||||||
if( p->nRef==0 ){
|
if( p->nRef==0 ){
|
||||||
PCache *pCache = p->pCache;
|
PCache *pCache = p->pCache;
|
||||||
if( p->pCache->xDestroy ){
|
|
||||||
p->pCache->xDestroy(p);
|
|
||||||
}
|
|
||||||
pCache->nRef--;
|
pCache->nRef--;
|
||||||
if( (p->flags&PGHDR_DIRTY)==0 ){
|
if( (p->flags&PGHDR_DIRTY)==0 ){
|
||||||
pCache->nPinned--;
|
pCache->nPinned--;
|
||||||
@ -1163,6 +1157,10 @@ int sqlite3PcacheRefCount(PCache *pCache){
|
|||||||
return pCache->nRef;
|
return pCache->nRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int sqlite3PcachePageRefcount(PgHdr *p){
|
||||||
|
return p->nRef;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Return the total number of pages in the cache.
|
** Return the total number of pages in the cache.
|
||||||
*/
|
*/
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
** This header file defines the interface that the sqlite page cache
|
** This header file defines the interface that the sqlite page cache
|
||||||
** subsystem.
|
** subsystem.
|
||||||
**
|
**
|
||||||
** @(#) $Id: pcache.h,v 1.11 2008/09/18 17:34:44 danielk1977 Exp $
|
** @(#) $Id: pcache.h,v 1.12 2008/09/29 11:49:48 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _PCACHE_H_
|
#ifndef _PCACHE_H_
|
||||||
@ -79,7 +79,6 @@ void sqlite3PcacheOpen(
|
|||||||
int szPage, /* Size of every page */
|
int szPage, /* Size of every page */
|
||||||
int szExtra, /* Extra space associated with each page */
|
int szExtra, /* Extra space associated with each page */
|
||||||
int bPurgeable, /* True if pages are on backing store */
|
int bPurgeable, /* True if pages are on backing store */
|
||||||
void (*xDestroy)(PgHdr *), /* Called to destroy a page */
|
|
||||||
int (*xStress)(void*, PgHdr*), /* Call to try to make pages clean */
|
int (*xStress)(void*, PgHdr*), /* Call to try to make pages clean */
|
||||||
void *pStress, /* Argument to xStress */
|
void *pStress, /* Argument to xStress */
|
||||||
PCache *pToInit /* Preallocated space for the PCache */
|
PCache *pToInit /* Preallocated space for the PCache */
|
||||||
@ -143,6 +142,8 @@ int sqlite3PcacheRefCount(PCache*);
|
|||||||
/* Increment the reference count of an existing page */
|
/* Increment the reference count of an existing page */
|
||||||
void sqlite3PcacheRef(PgHdr*);
|
void sqlite3PcacheRef(PgHdr*);
|
||||||
|
|
||||||
|
int sqlite3PcachePageRefcount(PgHdr*);
|
||||||
|
|
||||||
/* Return the total number of pages stored in the cache */
|
/* Return the total number of pages stored in the cache */
|
||||||
int sqlite3PcachePagecount(PCache*);
|
int sqlite3PcachePagecount(PCache*);
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
** is not included in the SQLite library. It is used for automated
|
** is not included in the SQLite library. It is used for automated
|
||||||
** testing of the SQLite library.
|
** testing of the SQLite library.
|
||||||
**
|
**
|
||||||
** $Id: test2.c,v 1.61 2008/08/26 18:05:48 danielk1977 Exp $
|
** $Id: test2.c,v 1.62 2008/09/29 11:49:48 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include "tcl.h"
|
#include "tcl.h"
|
||||||
@ -78,7 +78,7 @@ static int pager_open(
|
|||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
}
|
}
|
||||||
if( Tcl_GetInt(interp, argv[2], &nPage) ) return TCL_ERROR;
|
if( Tcl_GetInt(interp, argv[2], &nPage) ) return TCL_ERROR;
|
||||||
rc = sqlite3PagerOpen(sqlite3_vfs_find(0), &pPager, argv[1], 0, 0, 0,
|
rc = sqlite3PagerOpen(sqlite3_vfs_find(0), &pPager, argv[1], 0, 0,
|
||||||
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_MAIN_DB);
|
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_MAIN_DB);
|
||||||
if( rc!=SQLITE_OK ){
|
if( rc!=SQLITE_OK ){
|
||||||
Tcl_AppendResult(interp, errorName(rc), 0);
|
Tcl_AppendResult(interp, errorName(rc), 0);
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
** is not included in the SQLite library. It is used for automated
|
** is not included in the SQLite library. It is used for automated
|
||||||
** testing of the SQLite library.
|
** testing of the SQLite library.
|
||||||
**
|
**
|
||||||
** $Id: test_btree.c,v 1.7 2008/09/02 00:52:52 drh Exp $
|
** $Id: test_btree.c,v 1.8 2008/09/29 11:49:48 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#include "btreeInt.h"
|
#include "btreeInt.h"
|
||||||
#include <tcl.h>
|
#include <tcl.h>
|
||||||
@ -52,11 +52,11 @@ void sqlite3BtreeCursorList(Btree *p){
|
|||||||
BtCursor *pCur;
|
BtCursor *pCur;
|
||||||
BtShared *pBt = p->pBt;
|
BtShared *pBt = p->pBt;
|
||||||
for(pCur=pBt->pCursor; pCur; pCur=pCur->pNext){
|
for(pCur=pBt->pCursor; pCur; pCur=pCur->pNext){
|
||||||
MemPage *pPage = pCur->pPage;
|
MemPage *pPage = pCur->apPage[pCur->iPage];
|
||||||
char *zMode = pCur->wrFlag ? "rw" : "ro";
|
char *zMode = pCur->wrFlag ? "rw" : "ro";
|
||||||
sqlite3DebugPrintf("CURSOR %p rooted at %4d(%s) currently at %d.%d%s\n",
|
sqlite3DebugPrintf("CURSOR %p rooted at %4d(%s) currently at %d.%d%s\n",
|
||||||
pCur, pCur->pgnoRoot, zMode,
|
pCur, pCur->pgnoRoot, zMode,
|
||||||
pPage ? pPage->pgno : 0, pCur->idx,
|
pPage ? pPage->pgno : 0, pCur->aiIdx[pCur->iPage],
|
||||||
(pCur->eState==CURSOR_VALID) ? "" : " eof"
|
(pCur->eState==CURSOR_VALID) ? "" : " eof"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -83,8 +83,9 @@ void sqlite3BtreeCursorList(Btree *p){
|
|||||||
** This routine is used for testing and debugging only.
|
** This routine is used for testing and debugging only.
|
||||||
*/
|
*/
|
||||||
int sqlite3BtreeCursorInfo(BtCursor *pCur, int *aResult, int upCnt){
|
int sqlite3BtreeCursorInfo(BtCursor *pCur, int *aResult, int upCnt){
|
||||||
|
#if 0
|
||||||
int cnt, idx;
|
int cnt, idx;
|
||||||
MemPage *pPage = pCur->pPage;
|
MemPage *pPage = pCur->apPage[pCur->iPage];
|
||||||
BtCursor tmpCur;
|
BtCursor tmpCur;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
@ -136,5 +137,6 @@ int sqlite3BtreeCursorInfo(BtCursor *pCur, int *aResult, int upCnt){
|
|||||||
aResult[10] = 0;
|
aResult[10] = 0;
|
||||||
}
|
}
|
||||||
sqlite3BtreeReleaseTempCursor(&tmpCur);
|
sqlite3BtreeReleaseTempCursor(&tmpCur);
|
||||||
|
#endif
|
||||||
return SQLITE_OK;
|
return SQLITE_OK;
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
# This file implements tests to make sure SQLite does not crash or
|
# This file implements tests to make sure SQLite does not crash or
|
||||||
# segfault if it sees a corrupt database file.
|
# segfault if it sees a corrupt database file.
|
||||||
#
|
#
|
||||||
# $Id: corrupt2.test,v 1.17 2008/09/10 11:28:38 danielk1977 Exp $
|
# $Id: corrupt2.test,v 1.18 2008/09/29 11:49:48 danielk1977 Exp $
|
||||||
|
|
||||||
set testdir [file dirname $argv0]
|
set testdir [file dirname $argv0]
|
||||||
source $testdir/tester.tcl
|
source $testdir/tester.tcl
|
||||||
@ -225,8 +225,6 @@ do_test corrupt2-5.1 {
|
|||||||
}
|
}
|
||||||
set result
|
set result
|
||||||
} {{*** in database main ***
|
} {{*** in database main ***
|
||||||
Page 10: sqlite3BtreeInitPage() returns error code 11
|
|
||||||
On tree page 3 cell 1: Child page depth differs
|
|
||||||
On tree page 2 cell 0: 2nd reference to page 10
|
On tree page 2 cell 0: 2nd reference to page 10
|
||||||
On tree page 2 cell 1: Child page depth differs
|
On tree page 2 cell 1: Child page depth differs
|
||||||
Page 4 is never used}}
|
Page 4 is never used}}
|
||||||
|
Loading…
Reference in New Issue
Block a user