blob: 09bc7aedec0399406310fb8d3849f24a8188a145 [file] [log] [blame]
drh960e8c62001-04-03 16:53:21 +00001/*
drhb19a2bc2001-09-16 00:13:26 +00002** 2001 September 15
drh960e8c62001-04-03 16:53:21 +00003**
drhb19a2bc2001-09-16 00:13:26 +00004** The author disclaims copyright to this source code. In place of
5** a legal notice, here is a blessing:
drh960e8c62001-04-03 16:53:21 +00006**
drhb19a2bc2001-09-16 00:13:26 +00007** 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.
drh960e8c62001-04-03 16:53:21 +000010**
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**
drh9eb9e262004-02-11 02:18:05 +000016** @(#) $Id: pager.h,v 1.26 2004/02/11 02:18:07 drh Exp $
drh960e8c62001-04-03 16:53:21 +000017*/
drh960e8c62001-04-03 16:53:21 +000018
19/*
20** The size of one page
drh58a11682001-11-10 13:51:08 +000021**
drhd0ba1932004-02-10 01:54:28 +000022** 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.
drh960e8c62001-04-03 16:53:21 +000031*/
drhb20ea9d2004-02-09 01:20:36 +000032#ifndef SQLITE_PAGE_SIZE
drh960e8c62001-04-03 16:53:21 +000033#define SQLITE_PAGE_SIZE 1024
drhb20ea9d2004-02-09 01:20:36 +000034#endif
drh960e8c62001-04-03 16:53:21 +000035
36/*
drhd0ba1932004-02-10 01:54:28 +000037** 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/*
drh092d0352001-09-15 13:15:12 +000053** 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/*
drh960e8c62001-04-03 16:53:21 +000059** 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*/
62typedef unsigned int Pgno;
63
64/*
65** Each open file is managed by a separate instance of the "Pager" structure.
66*/
67typedef struct Pager Pager;
68
drh6446c4d2001-12-15 14:22:18 +000069/*
70** See source code comments for a detailed description of the following
71** routines:
72*/
drhda47d772002-12-02 04:25:19 +000073int sqlitepager_open(Pager **ppPager, const char *zFilename,
74 int nPage, int nExtra, int useJournal);
drh8c42ca92001-06-22 19:15:00 +000075void sqlitepager_set_destructor(Pager*, void(*)(void*));
drhf57b14a2001-09-14 18:54:08 +000076void sqlitepager_set_cachesize(Pager*, int);
drhd9b02572001-04-15 00:37:09 +000077int sqlitepager_close(Pager *pPager);
78int sqlitepager_get(Pager *pPager, Pgno pgno, void **ppPage);
drh7e3b0a02001-04-28 16:52:40 +000079void *sqlitepager_lookup(Pager *pPager, Pgno pgno);
drh8c42ca92001-06-22 19:15:00 +000080int sqlitepager_ref(void*);
drhd9b02572001-04-15 00:37:09 +000081int sqlitepager_unref(void*);
82Pgno sqlitepager_pagenumber(void*);
83int sqlitepager_write(void*);
drh6019e162001-07-02 17:51:45 +000084int sqlitepager_iswriteable(void*);
drh001bbcb2003-03-19 03:14:00 +000085int sqlitepager_overwrite(Pager *pPager, Pgno pgno, void*);
drhd9b02572001-04-15 00:37:09 +000086int sqlitepager_pagecount(Pager*);
drhf7c57532003-04-25 13:22:51 +000087int sqlitepager_truncate(Pager*,Pgno);
drh4b845d72002-03-05 12:41:19 +000088int sqlitepager_begin(void*);
drhd9b02572001-04-15 00:37:09 +000089int sqlitepager_commit(Pager*);
90int sqlitepager_rollback(Pager*);
drh5e00f6c2001-09-13 13:46:56 +000091int sqlitepager_isreadonly(Pager*);
drhfa86c412002-02-02 15:01:15 +000092int sqlitepager_ckpt_begin(Pager*);
93int sqlitepager_ckpt_commit(Pager*);
94int sqlitepager_ckpt_rollback(Pager*);
drh30e58752002-03-02 20:41:57 +000095void sqlitepager_dont_rollback(void*);
96void sqlitepager_dont_write(Pager*, Pgno);
drhd9b02572001-04-15 00:37:09 +000097int *sqlitepager_stats(Pager*);
drh973b6e32003-02-12 14:09:42 +000098void sqlitepager_set_safety_level(Pager*,int);
drh73509ee2003-04-06 20:44:45 +000099const char *sqlitepager_filename(Pager*);
100int sqlitepager_rename(Pager*, const char *zNewName);
drh9eb9e262004-02-11 02:18:05 +0000101void sqlitepager_set_codec(Pager*,void(*)(void*,void*,Pgno,int),void*);
drhdd793422001-06-28 01:54:48 +0000102
103#ifdef SQLITE_TEST
104void sqlitepager_refdump(Pager*);
105int pager_refinfo_enable;
drh968af522003-02-11 14:55:40 +0000106int journal_format;
drhdd793422001-06-28 01:54:48 +0000107#endif