wasCSharpSQLite – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 using System;
2 using System.Diagnostics;
3 using System.IO;
4  
5 using i16 = System.Int16;
6 using u32 = System.UInt32;
7 using Pgno = System.UInt32;
8  
9 namespace Community.CsharpSqlite
10 {
11 public partial class Sqlite3
12 {
13 /*
14 ** 2008 August 05
15 **
16 ** The author disclaims copyright to this source code. In place of
17 ** a legal notice, here is a blessing:
18 **
19 ** May you do good and not evil.
20 ** May you find forgiveness for yourself and forgive others.
21 ** May you share freely, never taking more than you give.
22 **
23 *************************************************************************
24 ** This header file defines the interface that the sqlite page cache
25 ** subsystem.
26 *************************************************************************
27 ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart
28 ** C#-SQLite is an independent reimplementation of the SQLite software library
29 **
30 ** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3
31 **
32 *************************************************************************
33 */
34  
35 #if !_PCACHE_H_
36  
37 //typedef struct PgHdr PgHdr;
38 //typedef struct PCache PCache;
39  
40 /*
41 ** Every page in the cache is controlled by an instance of the following
42 ** structure.
43 */
44 public class PgHdr
45 {
46 public byte[] pData; /* Content of this page */
47 public MemPage pExtra; /* Extra content */
48 public PgHdr pDirty; /* Transient list of dirty pages */
49 public Pgno pgno; /* The page number for this page */
50 public Pager pPager; /* The pager to which this page belongs */
51 #if SQLITE_CHECK_PAGES || (SQLITE_DEBUG)
52 public int pageHash; /* Hash of page content */
53 #endif
54 public int flags; /* PGHDR flags defined below */
55 /**********************************************************************
56 ** Elements above are public. All that follows is private to pcache.c
57 ** and should not be accessed by other modules.
58 */
59 public int nRef; /* Number of users of this page */
60 public PCache pCache; /* Cache that owns this page */
61 public bool CacheAllocated; /* True, if allocated from cache */
62  
63 public PgHdr pDirtyNext; /* Next element in list of dirty pages */
64 public PgHdr pDirtyPrev; /* Previous element in list of dirty pages */
65 public PgHdr1 pPgHdr1; /* Cache page header this this page */
66  
67 public static implicit operator bool( PgHdr b )
68 {
69 return ( b != null );
70 }
71  
72  
73 public void Clear()
74 {
75 sqlite3_free( ref this.pData );
76 this.pData = null;
77 this.pExtra = null;
78 this.pDirty = null;
79 this.pgno = 0;
80 this.pPager = null;
81 #if SQLITE_CHECK_PAGES
82 this.pageHash=0;
83 #endif
84 this.flags = 0;
85 this.nRef = 0;
86 this.CacheAllocated = false;
87 this.pCache = null;
88 this.pDirtyNext = null;
89 this.pDirtyPrev = null;
90 this.pPgHdr1 = null;
91 }
92 };
93  
94 /* Bit values for PgHdr.flags */
95 //#define PGHDR_DIRTY 0x002 /* Page has changed */
96 //#define PGHDR_NEED_SYNC 0x004 /* Fsync the rollback journal before
97 // ** writing this page to the database */
98 //#define PGHDR_NEED_READ 0x008 /* Content is unread */
99 //#define PGHDR_REUSE_UNLIKELY 0x010 /* A hint that reuse is unlikely */
100 //#define PGHDR_DONT_WRITE 0x020 /* Do not write content to disk */
101  
102 const int PGHDR_DIRTY = 0x002; /* Page has changed */
103 const int PGHDR_NEED_SYNC = 0x004;/* Fsync the rollback journal before
104 ** writing this page to the database */
105 const int PGHDR_NEED_READ = 0x008;/* Content is unread */
106 const int PGHDR_REUSE_UNLIKELY = 0x010;/* A hint that reuse is unlikely */
107 const int PGHDR_DONT_WRITE = 0x020;/* Do not write content to disk */
108  
109 /* Initialize and shutdown the page cache subsystem */
110 //int sqlite3PcacheInitialize(void);
111 //void sqlite3PcacheShutdown(void);
112  
113 /* Page cache buffer management:
114 ** These routines implement SQLITE_CONFIG_PAGECACHE.
115 */
116 //void sqlite3PCacheBufferSetup(void *, int sz, int n);
117  
118 /* Create a new pager cache.
119 ** Under memory stress, invoke xStress to try to make pages clean.
120 ** Only clean and unpinned pages can be reclaimed.
121 */
122 //void sqlite3PcacheOpen(
123 // int szPage, /* Size of every page */
124 // int szExtra, /* Extra space associated with each page */
125 // int bPurgeable, /* True if pages are on backing store */
126 // int (*xStress)(void*, PgHdr*), /* Call to try to make pages clean */
127 // void pStress, /* Argument to xStress */
128 // PCache pToInit /* Preallocated space for the PCache */
129 //);
130  
131 /* Modify the page-size after the cache has been created. */
132 //void sqlite3PcacheSetPageSize(PCache *, int);
133  
134 /* Return the size in bytes of a PCache object. Used to preallocate
135 ** storage space.
136 */
137 //int sqlite3PcacheSize(void);
138  
139 /* One release per successful fetch. Page is pinned until released.
140 ** Reference counted.
141 */
142 //int sqlite3PcacheFetch(PCache*, Pgno, int createFlag, PgHdr**);
143 //void sqlite3PcacheRelease(PgHdr*);
144  
145 //void sqlite3PcacheDrop(PgHdr*); /* Remove page from cache */
146 //void sqlite3PcacheMakeDirty(PgHdr*); /* Make sure page is marked dirty */
147 //void sqlite3PcacheMakeClean(PgHdr*); /* Mark a single page as clean */
148 //void sqlite3PcacheCleanAll(PCache*); /* Mark all dirty list pages as clean */
149  
150 /* Change a page number. Used by incr-vacuum. */
151 //void sqlite3PcacheMove(PgHdr*, Pgno);
152  
153 /* Remove all pages with pgno>x. Reset the cache if x==0 */
154 //void sqlite3PcacheTruncate(PCache*, Pgno x);
155  
156 /* Get a list of all dirty pages in the cache, sorted by page number */
157 //PgHdr *sqlite3PcacheDirtyList(PCache*);
158  
159 /* Reset and close the cache object */
160 //void sqlite3PcacheClose(PCache*);
161  
162 /* Clear flags from pages of the page cache */
163 //void sqlite3PcacheClearSyncFlags(PCache *);
164  
165 /* Discard the contents of the cache */
166 //void sqlite3PcacheClear(PCache*);
167  
168 /* Return the total number of outstanding page references */
169 //int sqlite3PcacheRefCount(PCache*);
170  
171 /* Increment the reference count of an existing page */
172 //void sqlite3PcacheRef(PgHdr*);
173  
174 //int sqlite3PcachePageRefcount(PgHdr*);
175  
176  
177 /* Return the total number of pages stored in the cache */
178 //int sqlite3PcachePagecount(PCache*);
179  
180 #if SQLITE_CHECK_PAGES
181 /* Iterate through all dirty pages currently stored in the cache. This
182 ** interface is only available if SQLITE_CHECK_PAGES is defined when the
183 ** library is built.
184 */
185  
186 //void sqlite3PcacheIterateDirty(PCache pCache, void (*xIter)(PgHdr *));
187 #endif
188  
189 /* Set and get the suggested cache-size for the specified pager-cache.
190 **
191 ** If no global maximum is configured, then the system attempts to limit
192 ** the total number of pages cached by purgeable pager-caches to the sum
193 ** of the suggested cache-sizes.
194 */
195 //void sqlite3PcacheSetCachesize(PCache *, int);
196 #if SQLITE_TEST
197 //int sqlite3PcacheGetCachesize(PCache *);
198 #endif
199  
200 #if SQLITE_ENABLE_MEMORY_MANAGEMENT
201 /* Try to return memory used by the pcache module to the main memory heap */
202 //int sqlite3PcacheReleaseMemory(int);
203 #endif
204  
205 #if SQLITE_TEST
206 //void sqlite3PcacheStats(int*,int*,int*,int*);
207 #endif
208  
209 //void sqlite3PCacheSetDefault(void);
210  
211 #endif //* _PCACHE_H_ */
212 }
213 }