1 /* 2 ** 2001 September 15 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 header file defines the interface that the sqlite page cache 13 ** subsystem. The page cache subsystem reads and writes a file a page 14 ** at a time and provides a journal for rollback. 15 ** 16 ** @(#) $Id: pager.h,v 1.33 2004/06/09 17:37:28 drh Exp $ 17 */ 18 19 /* 20 ** The size of a page. 21 ** 22 ** You can change this value to another (reasonable) value you want. 23 ** It need not be a power of two, though the interface to the disk 24 ** will likely be faster if it is. 25 ** 26 ** Experiments show that a page size of 1024 gives the best speed 27 ** for common usages. The speed differences for different sizes 28 ** such as 512, 2048, 4096, an so forth, is minimal. Note, however, 29 ** that changing the page size results in a completely imcompatible 30 ** file format. 31 */ 32 #ifndef SQLITE_PAGE_SIZE 33 #define SQLITE_PAGE_SIZE 1024 34 #endif 35 36 /* 37 ** Number of extra bytes of data allocated at the end of each page and 38 ** stored on disk but not used by the higher level btree layer. Changing 39 ** this value results in a completely incompatible file format. 40 */ 41 #ifndef SQLITE_PAGE_RESERVE 42 #define SQLITE_PAGE_RESERVE 0 43 #endif 44 45 /* 46 ** The total number of usable bytes stored on disk for each page. 47 ** The usable bytes come at the beginning of the page and the reserve 48 ** bytes come at the end. 49 */ 50 #define SQLITE_USABLE_SIZE (SQLITE_PAGE_SIZE-SQLITE_PAGE_RESERVE) 51 52 /* 53 ** Maximum number of pages in one database. 54 */ 55 #define SQLITE_MAX_PAGE 1073741823 56 57 /* 58 ** The type used to represent a page number. The first page in a file 59 ** is called page 1. 0 is used to represent "not a page". 60 */ 61 typedef unsigned int Pgno; 62 63 /* 64 ** Each open file is managed by a separate instance of the "Pager" structure. 65 */ 66 typedef struct Pager Pager; 67 68 /* 69 ** See source code comments for a detailed description of the following 70 ** routines: 71 */ 72 int sqlite3pager_open(Pager **ppPager, const char *zFilename, 73 int nPage, int nExtra, int useJournal, 74 void *pBusyHandler); 75 void sqlite3pager_set_destructor(Pager*, void(*)(void*,int)); 76 void sqlite3pager_set_reiniter(Pager*, void(*)(void*,int)); 77 void sqlite3pager_set_cachesize(Pager*, int); 78 int sqlite3pager_close(Pager *pPager); 79 int sqlite3pager_get(Pager *pPager, Pgno pgno, void **ppPage); 80 void *sqlite3pager_lookup(Pager *pPager, Pgno pgno); 81 int sqlite3pager_ref(void*); 82 int sqlite3pager_unref(void*); 83 Pgno sqlite3pager_pagenumber(void*); 84 int sqlite3pager_write(void*); 85 int sqlite3pager_iswriteable(void*); 86 int sqlite3pager_overwrite(Pager *pPager, Pgno pgno, void*); 87 int sqlite3pager_pagecount(Pager*); 88 int sqlite3pager_truncate(Pager*,Pgno); 89 int sqlite3pager_begin(void*,int); 90 int sqlite3pager_commit(Pager*); 91 int sqlite3pager_sync(Pager*,const char *zMaster); 92 int sqlite3pager_rollback(Pager*); 93 int sqlite3pager_isreadonly(Pager*); 94 int sqlite3pager_stmt_begin(Pager*); 95 int sqlite3pager_stmt_commit(Pager*); 96 int sqlite3pager_stmt_rollback(Pager*); 97 void sqlite3pager_dont_rollback(void*); 98 void sqlite3pager_dont_write(Pager*, Pgno); 99 int *sqlite3pager_stats(Pager*); 100 void sqlite3pager_set_safety_level(Pager*,int); 101 const char *sqlite3pager_filename(Pager*); 102 int sqlite3pager_rename(Pager*, const char *zNewName); 103 void sqlite3pager_set_codec(Pager*,void(*)(void*,void*,Pgno,int),void*); 104 105 #ifdef SQLITE_DEBUG 106 int sqlite3pager_lockstate(Pager*); 107 #endif 108 109 #ifdef SQLITE_TEST 110 void sqlite3pager_refdump(Pager*); 111 int pager3_refinfo_enable; 112 #endif 113