blob: 122129bf0c63f623e6009bcf2f88225ea61d8b14 [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**
drha6abd042004-06-09 17:37:22 +000016** @(#) $Id: pager.h,v 1.33 2004/06/09 17:37:28 drh Exp $
drh960e8c62001-04-03 16:53:21 +000017*/
drh960e8c62001-04-03 16:53:21 +000018
19/*
drhb6f41482004-05-14 01:58:11 +000020** The size of a 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/*
drh3aac2dd2004-04-26 14:10:20 +000053** Maximum number of pages in one database.
drh092d0352001-09-15 13:15:12 +000054*/
55#define SQLITE_MAX_PAGE 1073741823
56
57/*
drh960e8c62001-04-03 16:53:21 +000058** 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*/
61typedef unsigned int Pgno;
62
63/*
64** Each open file is managed by a separate instance of the "Pager" structure.
65*/
66typedef struct Pager Pager;
67
drh6446c4d2001-12-15 14:22:18 +000068/*
69** See source code comments for a detailed description of the following
70** routines:
71*/
drh3aac2dd2004-04-26 14:10:20 +000072int sqlite3pager_open(Pager **ppPager, const char *zFilename,
danielk197724162fe2004-06-04 06:22:00 +000073 int nPage, int nExtra, int useJournal,
74 void *pBusyHandler);
drhb6f41482004-05-14 01:58:11 +000075void sqlite3pager_set_destructor(Pager*, void(*)(void*,int));
drha6abd042004-06-09 17:37:22 +000076void sqlite3pager_set_reiniter(Pager*, void(*)(void*,int));
drh3aac2dd2004-04-26 14:10:20 +000077void sqlite3pager_set_cachesize(Pager*, int);
78int sqlite3pager_close(Pager *pPager);
79int sqlite3pager_get(Pager *pPager, Pgno pgno, void **ppPage);
80void *sqlite3pager_lookup(Pager *pPager, Pgno pgno);
81int sqlite3pager_ref(void*);
82int sqlite3pager_unref(void*);
83Pgno sqlite3pager_pagenumber(void*);
84int sqlite3pager_write(void*);
85int sqlite3pager_iswriteable(void*);
86int sqlite3pager_overwrite(Pager *pPager, Pgno pgno, void*);
87int sqlite3pager_pagecount(Pager*);
88int sqlite3pager_truncate(Pager*,Pgno);
danielk197713adf8a2004-06-03 16:08:41 +000089int sqlite3pager_begin(void*,int);
drh3aac2dd2004-04-26 14:10:20 +000090int sqlite3pager_commit(Pager*);
danielk197713adf8a2004-06-03 16:08:41 +000091int sqlite3pager_sync(Pager*,const char *zMaster);
drh3aac2dd2004-04-26 14:10:20 +000092int sqlite3pager_rollback(Pager*);
93int sqlite3pager_isreadonly(Pager*);
94int sqlite3pager_stmt_begin(Pager*);
95int sqlite3pager_stmt_commit(Pager*);
96int sqlite3pager_stmt_rollback(Pager*);
97void sqlite3pager_dont_rollback(void*);
98void sqlite3pager_dont_write(Pager*, Pgno);
99int *sqlite3pager_stats(Pager*);
100void sqlite3pager_set_safety_level(Pager*,int);
101const char *sqlite3pager_filename(Pager*);
102int sqlite3pager_rename(Pager*, const char *zNewName);
103void sqlite3pager_set_codec(Pager*,void(*)(void*,void*,Pgno,int),void*);
drhdd793422001-06-28 01:54:48 +0000104
drh89ac8c12004-06-09 14:17:20 +0000105#ifdef SQLITE_DEBUG
106int sqlite3pager_lockstate(Pager*);
107#endif
108
drhdd793422001-06-28 01:54:48 +0000109#ifdef SQLITE_TEST
drh3aac2dd2004-04-26 14:10:20 +0000110void sqlite3pager_refdump(Pager*);
111int pager3_refinfo_enable;
drhdd793422001-06-28 01:54:48 +0000112#endif