xref: /illumos-gate/usr/src/lib/libsqlite/src/pager.h (revision 1da57d551424de5a9d469760be7c4b4d4f10a755)
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.26 2004/02/11 02:18:07 drh Exp $
17 */
18 
19 /*
20 ** The size of one 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.  (This is a limitation of
54 ** imposed by 4GB files size limits.)
55 */
56 #define SQLITE_MAX_PAGE 1073741823
57 
58 /*
59 ** The type used to represent a page number.  The first page in a file
60 ** is called page 1.  0 is used to represent "not a page".
61 */
62 typedef unsigned int Pgno;
63 
64 /*
65 ** Each open file is managed by a separate instance of the "Pager" structure.
66 */
67 typedef struct Pager Pager;
68 
69 /*
70 ** See source code comments for a detailed description of the following
71 ** routines:
72 */
73 int sqlitepager_open(Pager **ppPager, const char *zFilename,
74                      int nPage, int nExtra, int useJournal);
75 void sqlitepager_set_destructor(Pager*, void(*)(void*));
76 void sqlitepager_set_cachesize(Pager*, int);
77 int sqlitepager_close(Pager *pPager);
78 int sqlitepager_get(Pager *pPager, Pgno pgno, void **ppPage);
79 void *sqlitepager_lookup(Pager *pPager, Pgno pgno);
80 int sqlitepager_ref(void*);
81 int sqlitepager_unref(void*);
82 Pgno sqlitepager_pagenumber(void*);
83 int sqlitepager_write(void*);
84 int sqlitepager_iswriteable(void*);
85 int sqlitepager_overwrite(Pager *pPager, Pgno pgno, void*);
86 int sqlitepager_pagecount(Pager*);
87 int sqlitepager_truncate(Pager*,Pgno);
88 int sqlitepager_begin(void*);
89 int sqlitepager_commit(Pager*);
90 int sqlitepager_rollback(Pager*);
91 int sqlitepager_isreadonly(Pager*);
92 int sqlitepager_ckpt_begin(Pager*);
93 int sqlitepager_ckpt_commit(Pager*);
94 int sqlitepager_ckpt_rollback(Pager*);
95 void sqlitepager_dont_rollback(void*);
96 void sqlitepager_dont_write(Pager*, Pgno);
97 int *sqlitepager_stats(Pager*);
98 void sqlitepager_set_safety_level(Pager*,int);
99 const char *sqlitepager_filename(Pager*);
100 int sqlitepager_rename(Pager*, const char *zNewName);
101 void sqlitepager_set_codec(Pager*,void(*)(void*,void*,Pgno,int),void*);
102 
103 #ifdef SQLITE_TEST
104 void sqlitepager_refdump(Pager*);
105 int pager_refinfo_enable;
106 int journal_format;
107 #endif
108