1 2 #pragma ident "%Z%%M% %I% %E% SMI" 3 4 /* 5 ** 2001 September 15 6 ** 7 ** The author disclaims copyright to this source code. In place of 8 ** a legal notice, here is a blessing: 9 ** 10 ** May you do good and not evil. 11 ** May you find forgiveness for yourself and forgive others. 12 ** May you share freely, never taking more than you give. 13 ** 14 ************************************************************************* 15 ** This header file defines the interface that the sqlite page cache 16 ** subsystem. The page cache subsystem reads and writes a file a page 17 ** at a time and provides a journal for rollback. 18 ** 19 ** @(#) $Id: pager.h,v 1.26 2004/02/11 02:18:07 drh Exp $ 20 */ 21 22 /* 23 ** The size of one page 24 ** 25 ** You can change this value to another (reasonable) value you want. 26 ** It need not be a power of two, though the interface to the disk 27 ** will likely be faster if it is. 28 ** 29 ** Experiments show that a page size of 1024 gives the best speed 30 ** for common usages. The speed differences for different sizes 31 ** such as 512, 2048, 4096, an so forth, is minimal. Note, however, 32 ** that changing the page size results in a completely imcompatible 33 ** file format. 34 */ 35 #ifndef SQLITE_PAGE_SIZE 36 #define SQLITE_PAGE_SIZE 1024 37 #endif 38 39 /* 40 ** Number of extra bytes of data allocated at the end of each page and 41 ** stored on disk but not used by the higher level btree layer. Changing 42 ** this value results in a completely incompatible file format. 43 */ 44 #ifndef SQLITE_PAGE_RESERVE 45 #define SQLITE_PAGE_RESERVE 0 46 #endif 47 48 /* 49 ** The total number of usable bytes stored on disk for each page. 50 ** The usable bytes come at the beginning of the page and the reserve 51 ** bytes come at the end. 52 */ 53 #define SQLITE_USABLE_SIZE (SQLITE_PAGE_SIZE-SQLITE_PAGE_RESERVE) 54 55 /* 56 ** Maximum number of pages in one database. (This is a limitation of 57 ** imposed by 4GB files size limits.) 58 */ 59 #define SQLITE_MAX_PAGE 1073741823 60 61 /* 62 ** The type used to represent a page number. The first page in a file 63 ** is called page 1. 0 is used to represent "not a page". 64 */ 65 typedef unsigned int Pgno; 66 67 /* 68 ** Each open file is managed by a separate instance of the "Pager" structure. 69 */ 70 typedef struct Pager Pager; 71 72 /* 73 ** See source code comments for a detailed description of the following 74 ** routines: 75 */ 76 int sqlitepager_open(Pager **ppPager, const char *zFilename, 77 int nPage, int nExtra, int useJournal); 78 void sqlitepager_set_destructor(Pager*, void(*)(void*)); 79 void sqlitepager_set_cachesize(Pager*, int); 80 int sqlitepager_close(Pager *pPager); 81 int sqlitepager_get(Pager *pPager, Pgno pgno, void **ppPage); 82 void *sqlitepager_lookup(Pager *pPager, Pgno pgno); 83 int sqlitepager_ref(void*); 84 int sqlitepager_unref(void*); 85 Pgno sqlitepager_pagenumber(void*); 86 int sqlitepager_write(void*); 87 int sqlitepager_iswriteable(void*); 88 int sqlitepager_overwrite(Pager *pPager, Pgno pgno, void*); 89 int sqlitepager_pagecount(Pager*); 90 int sqlitepager_truncate(Pager*,Pgno); 91 int sqlitepager_begin(void*); 92 int sqlitepager_commit(Pager*); 93 int sqlitepager_rollback(Pager*); 94 int sqlitepager_isreadonly(Pager*); 95 int sqlitepager_ckpt_begin(Pager*); 96 int sqlitepager_ckpt_commit(Pager*); 97 int sqlitepager_ckpt_rollback(Pager*); 98 void sqlitepager_dont_rollback(void*); 99 void sqlitepager_dont_write(Pager*, Pgno); 100 int *sqlitepager_stats(Pager*); 101 void sqlitepager_set_safety_level(Pager*,int); 102 const char *sqlitepager_filename(Pager*); 103 int sqlitepager_rename(Pager*, const char *zNewName); 104 void sqlitepager_set_codec(Pager*,void(*)(void*,void*,Pgno,int),void*); 105 106 #ifdef SQLITE_TEST 107 void sqlitepager_refdump(Pager*); 108 int pager_refinfo_enable; 109 int journal_format; 110 #endif 111