extensions/sqlite/sqlite-source/pager.h
author Asher Baker <asherkin@gmail.com>
Thu Apr 26 16:58:18 2012 +0100 (2012-04-26)
changeset 3488 bee90c8ef6c3
parent 1952 b7aa2b626807
permissions -rw-r--r--
Fixed client serials not being unique on Windows (bug 5285, r=psychonic).
     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$
    17 */
    18 
    19 #ifndef _PAGER_H_
    20 #define _PAGER_H_
    21 
    22 /*
    23 ** The type used to represent a page number.  The first page in a file
    24 ** is called page 1.  0 is used to represent "not a page".
    25 */
    26 typedef unsigned int Pgno;
    27 
    28 /*
    29 ** Each open file is managed by a separate instance of the "Pager" structure.
    30 */
    31 typedef struct Pager Pager;
    32 
    33 /*
    34 ** Handle type for pages.
    35 */
    36 typedef struct PgHdr DbPage;
    37 
    38 /*
    39 ** Allowed values for the flags parameter to sqlite3PagerOpen().
    40 **
    41 ** NOTE: This values must match the corresponding BTREE_ values in btree.h.
    42 */
    43 #define PAGER_OMIT_JOURNAL  0x0001    /* Do not use a rollback journal */
    44 #define PAGER_NO_READLOCK   0x0002    /* Omit readlocks on readonly files */
    45 
    46 /*
    47 ** Valid values for the second argument to sqlite3PagerLockingMode().
    48 */
    49 #define PAGER_LOCKINGMODE_QUERY      -1
    50 #define PAGER_LOCKINGMODE_NORMAL      0
    51 #define PAGER_LOCKINGMODE_EXCLUSIVE   1
    52 
    53 /*
    54 ** See source code comments for a detailed description of the following
    55 ** routines:
    56 */
    57 int sqlite3PagerOpen(sqlite3_vfs *, Pager **ppPager, const char*, int,int,int);
    58 void sqlite3PagerSetBusyhandler(Pager*, BusyHandler *pBusyHandler);
    59 void sqlite3PagerSetDestructor(Pager*, void(*)(DbPage*,int));
    60 void sqlite3PagerSetReiniter(Pager*, void(*)(DbPage*,int));
    61 int sqlite3PagerSetPagesize(Pager*, u16*);
    62 int sqlite3PagerMaxPageCount(Pager*, int);
    63 int sqlite3PagerReadFileheader(Pager*, int, unsigned char*);
    64 void sqlite3PagerSetCachesize(Pager*, int);
    65 int sqlite3PagerClose(Pager *pPager);
    66 int sqlite3PagerAcquire(Pager *pPager, Pgno pgno, DbPage **ppPage, int clrFlag);
    67 #define sqlite3PagerGet(A,B,C) sqlite3PagerAcquire(A,B,C,0)
    68 DbPage *sqlite3PagerLookup(Pager *pPager, Pgno pgno);
    69 int sqlite3PagerRef(DbPage*);
    70 int sqlite3PagerUnref(DbPage*);
    71 int sqlite3PagerWrite(DbPage*);
    72 int sqlite3PagerOverwrite(Pager *pPager, Pgno pgno, void*);
    73 int sqlite3PagerPagecount(Pager*);
    74 int sqlite3PagerTruncate(Pager*,Pgno);
    75 int sqlite3PagerBegin(DbPage*, int exFlag);
    76 int sqlite3PagerCommitPhaseOne(Pager*,const char *zMaster, Pgno);
    77 int sqlite3PagerCommitPhaseTwo(Pager*);
    78 int sqlite3PagerRollback(Pager*);
    79 int sqlite3PagerIsreadonly(Pager*);
    80 int sqlite3PagerStmtBegin(Pager*);
    81 int sqlite3PagerStmtCommit(Pager*);
    82 int sqlite3PagerStmtRollback(Pager*);
    83 void sqlite3PagerDontRollback(DbPage*);
    84 void sqlite3PagerDontWrite(DbPage*);
    85 int sqlite3PagerRefcount(Pager*);
    86 void sqlite3PagerSetSafetyLevel(Pager*,int,int);
    87 const char *sqlite3PagerFilename(Pager*);
    88 const sqlite3_vfs *sqlite3PagerVfs(Pager*);
    89 sqlite3_file *sqlite3PagerFile(Pager*);
    90 const char *sqlite3PagerDirname(Pager*);
    91 const char *sqlite3PagerJournalname(Pager*);
    92 int sqlite3PagerNosync(Pager*);
    93 int sqlite3PagerMovepage(Pager*,DbPage*,Pgno);
    94 void *sqlite3PagerGetData(DbPage *); 
    95 void *sqlite3PagerGetExtra(DbPage *); 
    96 int sqlite3PagerLockingMode(Pager *, int);
    97 
    98 #if defined(SQLITE_ENABLE_MEMORY_MANAGEMENT) && !defined(SQLITE_OMIT_DISKIO)
    99   int sqlite3PagerReleaseMemory(int);
   100 #endif
   101 
   102 #ifdef SQLITE_HAS_CODEC
   103   void sqlite3PagerSetCodec(Pager*,void*(*)(void*,void*,Pgno,int),void*);
   104 #endif
   105 
   106 #if !defined(NDEBUG) || defined(SQLITE_TEST)
   107   Pgno sqlite3PagerPagenumber(DbPage*);
   108   int sqlite3PagerIswriteable(DbPage*);
   109 #endif
   110 
   111 #ifdef SQLITE_TEST
   112   int *sqlite3PagerStats(Pager*);
   113   void sqlite3PagerRefdump(Pager*);
   114   int pager3_refinfo_enable;
   115 #endif
   116 
   117 #ifdef SQLITE_TEST
   118 void disable_simulated_io_errors(void);
   119 void enable_simulated_io_errors(void);
   120 #else
   121 # define disable_simulated_io_errors()
   122 # define enable_simulated_io_errors()
   123 #endif
   124 
   125 #endif /* _PAGER_H_ */