pager.h 4.1 KB

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