blob: 1aa70c715da14f08156b98fa7365394fcb3ee27a [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**
drhb6f41482004-05-14 01:58:11 +000016** @(#) $Id: pager.h,v 1.29 2004/05/14 01:58:13 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,
drhda47d772002-12-02 04:25:19 +000073 int nPage, int nExtra, int useJournal);
drhb6f41482004-05-14 01:58:11 +000074void sqlite3pager_set_destructor(Pager*, void(*)(void*,int));
drh3aac2dd2004-04-26 14:10:20 +000075void sqlite3pager_set_cachesize(Pager*, int);
76int sqlite3pager_close(Pager *pPager);
77int sqlite3pager_get(Pager *pPager, Pgno pgno, void **ppPage);
78void *sqlite3pager_lookup(Pager *pPager, Pgno pgno);
79int sqlite3pager_ref(void*);
80int sqlite3pager_unref(void*);
81Pgno sqlite3pager_pagenumber(void*);
82int sqlite3pager_write(void*);
83int sqlite3pager_iswriteable(void*);
84int sqlite3pager_overwrite(Pager *pPager, Pgno pgno, void*);
85int sqlite3pager_pagecount(Pager*);
86int sqlite3pager_truncate(Pager*,Pgno);
87int sqlite3pager_begin(void*);
88int sqlite3pager_commit(Pager*);
89int sqlite3pager_rollback(Pager*);
90int sqlite3pager_isreadonly(Pager*);
91int sqlite3pager_stmt_begin(Pager*);
92int sqlite3pager_stmt_commit(Pager*);
93int sqlite3pager_stmt_rollback(Pager*);
94void sqlite3pager_dont_rollback(void*);
95void sqlite3pager_dont_write(Pager*, Pgno);
96int *sqlite3pager_stats(Pager*);
97void sqlite3pager_set_safety_level(Pager*,int);
98const char *sqlite3pager_filename(Pager*);
99int sqlite3pager_rename(Pager*, const char *zNewName);
100void sqlite3pager_set_codec(Pager*,void(*)(void*,void*,Pgno,int),void*);
drhdd793422001-06-28 01:54:48 +0000101
102#ifdef SQLITE_TEST
drh3aac2dd2004-04-26 14:10:20 +0000103void sqlite3pager_refdump(Pager*);
104int pager3_refinfo_enable;
drhdd793422001-06-28 01:54:48 +0000105#endif