persistentstorage/sql/SQLite364/pager.h
changeset 0 08ec8eefde2f
equal deleted inserted replaced
-1:000000000000 0:08ec8eefde2f
       
     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.85 2008/09/29 11:49:48 danielk1977 Exp $
       
    17 */
       
    18 
       
    19 #ifndef _PAGER_H_
       
    20 #define _PAGER_H_
       
    21 
       
    22 /*
       
    23 ** If defined as non-zero, auto-vacuum is enabled by default. Otherwise
       
    24 ** it must be turned on for each database using "PRAGMA auto_vacuum = 1".
       
    25 */
       
    26 #ifndef SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT
       
    27   #define SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT -1
       
    28 #endif
       
    29 
       
    30 /*
       
    31 ** The type used to represent a page number.  The first page in a file
       
    32 ** is called page 1.  0 is used to represent "not a page".
       
    33 */
       
    34 typedef u32 Pgno;
       
    35 
       
    36 /*
       
    37 ** Each open file is managed by a separate instance of the "Pager" structure.
       
    38 */
       
    39 typedef struct Pager Pager;
       
    40 
       
    41 /*
       
    42 ** Handle type for pages.
       
    43 */
       
    44 typedef struct PgHdr DbPage;
       
    45 
       
    46 /*
       
    47 ** Allowed values for the flags parameter to sqlite3PagerOpen().
       
    48 **
       
    49 ** NOTE: This values must match the corresponding BTREE_ values in btree.h.
       
    50 */
       
    51 #define PAGER_OMIT_JOURNAL  0x0001    /* Do not use a rollback journal */
       
    52 #define PAGER_NO_READLOCK   0x0002    /* Omit readlocks on readonly files */
       
    53 
       
    54 /*
       
    55 ** Valid values for the second argument to sqlite3PagerLockingMode().
       
    56 */
       
    57 #define PAGER_LOCKINGMODE_QUERY      -1
       
    58 #define PAGER_LOCKINGMODE_NORMAL      0
       
    59 #define PAGER_LOCKINGMODE_EXCLUSIVE   1
       
    60 
       
    61 /*
       
    62 ** Valid values for the second argument to sqlite3PagerJournalMode().
       
    63 */
       
    64 #define PAGER_JOURNALMODE_QUERY      -1
       
    65 #define PAGER_JOURNALMODE_DELETE      0   /* Commit by deleting journal file */
       
    66 #define PAGER_JOURNALMODE_PERSIST     1   /* Commit by zeroing journal header */
       
    67 #define PAGER_JOURNALMODE_OFF         2   /* Journal omitted.  */
       
    68 #define PAGER_JOURNALMODE_TRUNCATE    3   /* Commit by truncating journal */
       
    69 
       
    70 /*
       
    71 ** See source code comments for a detailed description of the following
       
    72 ** routines:
       
    73 */
       
    74 int sqlite3PagerOpen(sqlite3_vfs *, Pager **ppPager, const char*, int,int,int);
       
    75 void sqlite3PagerSetBusyhandler(Pager*, BusyHandler *pBusyHandler);
       
    76 void sqlite3PagerSetReiniter(Pager*, void(*)(DbPage*));
       
    77 int sqlite3PagerSetPagesize(Pager*, u16*);
       
    78 int sqlite3PagerMaxPageCount(Pager*, int);
       
    79 int sqlite3PagerReadFileheader(Pager*, int, unsigned char*);
       
    80 void sqlite3PagerSetCachesize(Pager*, int);
       
    81 int sqlite3PagerClose(Pager *pPager);
       
    82 int sqlite3PagerAcquire(Pager *pPager, Pgno pgno, DbPage **ppPage, int clrFlag);
       
    83 #define sqlite3PagerGet(A,B,C) sqlite3PagerAcquire(A,B,C,0)
       
    84 DbPage *sqlite3PagerLookup(Pager *pPager, Pgno pgno);
       
    85 int sqlite3PagerPageRefcount(DbPage*);
       
    86 int sqlite3PagerRef(DbPage*);
       
    87 int sqlite3PagerUnref(DbPage*);
       
    88 int sqlite3PagerWrite(DbPage*);
       
    89 int sqlite3PagerPagecount(Pager*, int*);
       
    90 int sqlite3PagerTruncate(Pager*,Pgno);
       
    91 int sqlite3PagerBegin(DbPage*, int exFlag);
       
    92 int sqlite3PagerCommitPhaseOne(Pager*,const char *zMaster, Pgno, int);
       
    93 int sqlite3PagerCommitPhaseTwo(Pager*);
       
    94 int sqlite3PagerRollback(Pager*);
       
    95 int sqlite3PagerIsreadonly(Pager*);
       
    96 int sqlite3PagerStmtBegin(Pager*);
       
    97 int sqlite3PagerStmtCommit(Pager*);
       
    98 int sqlite3PagerStmtRollback(Pager*);
       
    99 void sqlite3PagerDontRollback(DbPage*);
       
   100 int sqlite3PagerDontWrite(DbPage*);
       
   101 int sqlite3PagerRefcount(Pager*);
       
   102 void sqlite3PagerSetSafetyLevel(Pager*,int,int);
       
   103 const char *sqlite3PagerFilename(Pager*);
       
   104 const sqlite3_vfs *sqlite3PagerVfs(Pager*);
       
   105 sqlite3_file *sqlite3PagerFile(Pager*);
       
   106 const char *sqlite3PagerDirname(Pager*);
       
   107 const char *sqlite3PagerJournalname(Pager*);
       
   108 int sqlite3PagerNosync(Pager*);
       
   109 int sqlite3PagerMovepage(Pager*,DbPage*,Pgno,int);
       
   110 void *sqlite3PagerGetData(DbPage *); 
       
   111 void *sqlite3PagerGetExtra(DbPage *); 
       
   112 int sqlite3PagerLockingMode(Pager *, int);
       
   113 int sqlite3PagerJournalMode(Pager *, int);
       
   114 i64 sqlite3PagerJournalSizeLimit(Pager *, i64);
       
   115 void *sqlite3PagerTempSpace(Pager*);
       
   116 int sqlite3PagerSync(Pager *pPager);
       
   117 
       
   118 #ifdef SQLITE_HAS_CODEC
       
   119   void sqlite3PagerSetCodec(Pager*,void*(*)(void*,void*,Pgno,int),void*);
       
   120 #endif
       
   121 
       
   122 #if !defined(NDEBUG) || defined(SQLITE_TEST)
       
   123   Pgno sqlite3PagerPagenumber(DbPage*);
       
   124   int sqlite3PagerIswriteable(DbPage*);
       
   125 #endif
       
   126 
       
   127 #ifdef SQLITE_TEST
       
   128   int *sqlite3PagerStats(Pager*);
       
   129   void sqlite3PagerRefdump(Pager*);
       
   130   int sqlite3PagerIsMemdb(Pager*);
       
   131 #endif
       
   132 
       
   133 #ifdef SQLITE_TEST
       
   134 void disable_simulated_io_errors(void);
       
   135 void enable_simulated_io_errors(void);
       
   136 #else
       
   137 # define disable_simulated_io_errors()
       
   138 # define enable_simulated_io_errors()
       
   139 #endif
       
   140 
       
   141 #endif /* _PAGER_H_ */