| OLD | NEW |
| 1 /* | 1 /* |
| 2 ** 2010 February 1 | 2 ** 2010 February 1 |
| 3 ** | 3 ** |
| 4 ** The author disclaims copyright to this source code. In place of | 4 ** The author disclaims copyright to this source code. In place of |
| 5 ** a legal notice, here is a blessing: | 5 ** a legal notice, here is a blessing: |
| 6 ** | 6 ** |
| 7 ** May you do good and not evil. | 7 ** May you do good and not evil. |
| 8 ** May you find forgiveness for yourself and forgive others. | 8 ** May you find forgiveness for yourself and forgive others. |
| 9 ** May you share freely, never taking more than you give. | 9 ** May you share freely, never taking more than you give. |
| 10 ** | 10 ** |
| 11 ************************************************************************* | 11 ************************************************************************* |
| 12 ** This header file defines the interface to the write-ahead logging | 12 ** This header file defines the interface to the write-ahead logging |
| 13 ** system. Refer to the comments below and the header comment attached to | 13 ** system. Refer to the comments below and the header comment attached to |
| 14 ** the implementation of each function in log.c for further details. | 14 ** the implementation of each function in log.c for further details. |
| 15 */ | 15 */ |
| 16 | 16 |
| 17 #ifndef _WAL_H_ | 17 #ifndef _WAL_H_ |
| 18 #define _WAL_H_ | 18 #define _WAL_H_ |
| 19 | 19 |
| 20 #include "sqliteInt.h" | 20 #include "sqliteInt.h" |
| 21 | 21 |
| 22 /* Additional values that can be added to the sync_flags argument of |
| 23 ** sqlite3WalFrames(): |
| 24 */ |
| 25 #define WAL_SYNC_TRANSACTIONS 0x20 /* Sync at the end of each transaction */ |
| 26 #define SQLITE_SYNC_MASK 0x13 /* Mask off the SQLITE_SYNC_* values */ |
| 27 |
| 22 #ifdef SQLITE_OMIT_WAL | 28 #ifdef SQLITE_OMIT_WAL |
| 23 # define sqlite3WalOpen(x,y,z) 0 | 29 # define sqlite3WalOpen(x,y,z) 0 |
| 30 # define sqlite3WalLimit(x,y) |
| 24 # define sqlite3WalClose(w,x,y,z) 0 | 31 # define sqlite3WalClose(w,x,y,z) 0 |
| 25 # define sqlite3WalBeginReadTransaction(y,z) 0 | 32 # define sqlite3WalBeginReadTransaction(y,z) 0 |
| 26 # define sqlite3WalEndReadTransaction(z) | 33 # define sqlite3WalEndReadTransaction(z) |
| 27 # define sqlite3WalRead(v,w,x,y,z) 0 | |
| 28 # define sqlite3WalDbsize(y) 0 | 34 # define sqlite3WalDbsize(y) 0 |
| 29 # define sqlite3WalBeginWriteTransaction(y) 0 | 35 # define sqlite3WalBeginWriteTransaction(y) 0 |
| 30 # define sqlite3WalEndWriteTransaction(x) 0 | 36 # define sqlite3WalEndWriteTransaction(x) 0 |
| 31 # define sqlite3WalUndo(x,y,z) 0 | 37 # define sqlite3WalUndo(x,y,z) 0 |
| 32 # define sqlite3WalSavepoint(y,z) | 38 # define sqlite3WalSavepoint(y,z) |
| 33 # define sqlite3WalSavepointUndo(y,z) 0 | 39 # define sqlite3WalSavepointUndo(y,z) 0 |
| 34 # define sqlite3WalFrames(u,v,w,x,y,z) 0 | 40 # define sqlite3WalFrames(u,v,w,x,y,z) 0 |
| 35 # define sqlite3WalCheckpoint(r,s,t,u,v,w,x,y,z) 0 | 41 # define sqlite3WalCheckpoint(r,s,t,u,v,w,x,y,z) 0 |
| 36 # define sqlite3WalCallback(z) 0 | 42 # define sqlite3WalCallback(z) 0 |
| 37 # define sqlite3WalExclusiveMode(y,z) 0 | 43 # define sqlite3WalExclusiveMode(y,z) 0 |
| 38 # define sqlite3WalHeapMemory(z) 0 | 44 # define sqlite3WalHeapMemory(z) 0 |
| 45 # define sqlite3WalFramesize(z) 0 |
| 46 # define sqlite3WalFindFrame(x,y,z) 0 |
| 39 #else | 47 #else |
| 40 | 48 |
| 41 #define WAL_SAVEPOINT_NDATA 4 | 49 #define WAL_SAVEPOINT_NDATA 4 |
| 42 | 50 |
| 43 /* Connection to a write-ahead log (WAL) file. | 51 /* Connection to a write-ahead log (WAL) file. |
| 44 ** There is one object of this type for each pager. | 52 ** There is one object of this type for each pager. |
| 45 */ | 53 */ |
| 46 typedef struct Wal Wal; | 54 typedef struct Wal Wal; |
| 47 | 55 |
| 48 /* Open and close a connection to a write-ahead log. */ | 56 /* Open and close a connection to a write-ahead log. */ |
| 49 int sqlite3WalOpen(sqlite3_vfs*, sqlite3_file*, const char *zName, int, Wal**); | 57 int sqlite3WalOpen(sqlite3_vfs*, sqlite3_file*, const char *, int, i64, Wal**); |
| 50 int sqlite3WalClose(Wal *pWal, int sync_flags, int, u8 *); | 58 int sqlite3WalClose(Wal *pWal, int sync_flags, int, u8 *); |
| 51 | 59 |
| 60 /* Set the limiting size of a WAL file. */ |
| 61 void sqlite3WalLimit(Wal*, i64); |
| 62 |
| 52 /* Used by readers to open (lock) and close (unlock) a snapshot. A | 63 /* Used by readers to open (lock) and close (unlock) a snapshot. A |
| 53 ** snapshot is like a read-transaction. It is the state of the database | 64 ** snapshot is like a read-transaction. It is the state of the database |
| 54 ** at an instant in time. sqlite3WalOpenSnapshot gets a read lock and | 65 ** at an instant in time. sqlite3WalOpenSnapshot gets a read lock and |
| 55 ** preserves the current state even if the other threads or processes | 66 ** preserves the current state even if the other threads or processes |
| 56 ** write to or checkpoint the WAL. sqlite3WalCloseSnapshot() closes the | 67 ** write to or checkpoint the WAL. sqlite3WalCloseSnapshot() closes the |
| 57 ** transaction and releases the lock. | 68 ** transaction and releases the lock. |
| 58 */ | 69 */ |
| 59 int sqlite3WalBeginReadTransaction(Wal *pWal, int *); | 70 int sqlite3WalBeginReadTransaction(Wal *pWal, int *); |
| 60 void sqlite3WalEndReadTransaction(Wal *pWal); | 71 void sqlite3WalEndReadTransaction(Wal *pWal); |
| 61 | 72 |
| 62 /* Read a page from the write-ahead log, if it is present. */ | 73 /* Read a page from the write-ahead log, if it is present. */ |
| 63 int sqlite3WalRead(Wal *pWal, Pgno pgno, int *pInWal, int nOut, u8 *pOut); | 74 int sqlite3WalFindFrame(Wal *, Pgno, u32 *); |
| 75 int sqlite3WalReadFrame(Wal *, u32, int, u8 *); |
| 64 | 76 |
| 65 /* If the WAL is not empty, return the size of the database. */ | 77 /* If the WAL is not empty, return the size of the database. */ |
| 66 Pgno sqlite3WalDbsize(Wal *pWal); | 78 Pgno sqlite3WalDbsize(Wal *pWal); |
| 67 | 79 |
| 68 /* Obtain or release the WRITER lock. */ | 80 /* Obtain or release the WRITER lock. */ |
| 69 int sqlite3WalBeginWriteTransaction(Wal *pWal); | 81 int sqlite3WalBeginWriteTransaction(Wal *pWal); |
| 70 int sqlite3WalEndWriteTransaction(Wal *pWal); | 82 int sqlite3WalEndWriteTransaction(Wal *pWal); |
| 71 | 83 |
| 72 /* Undo any frames written (but not committed) to the log */ | 84 /* Undo any frames written (but not committed) to the log */ |
| 73 int sqlite3WalUndo(Wal *pWal, int (*xUndo)(void *, Pgno), void *pUndoCtx); | 85 int sqlite3WalUndo(Wal *pWal, int (*xUndo)(void *, Pgno), void *pUndoCtx); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 ** by the pager layer on the database file. | 119 ** by the pager layer on the database file. |
| 108 */ | 120 */ |
| 109 int sqlite3WalExclusiveMode(Wal *pWal, int op); | 121 int sqlite3WalExclusiveMode(Wal *pWal, int op); |
| 110 | 122 |
| 111 /* Return true if the argument is non-NULL and the WAL module is using | 123 /* Return true if the argument is non-NULL and the WAL module is using |
| 112 ** heap-memory for the wal-index. Otherwise, if the argument is NULL or the | 124 ** heap-memory for the wal-index. Otherwise, if the argument is NULL or the |
| 113 ** WAL module is using shared-memory, return false. | 125 ** WAL module is using shared-memory, return false. |
| 114 */ | 126 */ |
| 115 int sqlite3WalHeapMemory(Wal *pWal); | 127 int sqlite3WalHeapMemory(Wal *pWal); |
| 116 | 128 |
| 129 #ifdef SQLITE_ENABLE_ZIPVFS |
| 130 /* If the WAL file is not empty, return the number of bytes of content |
| 131 ** stored in each frame (i.e. the db page-size when the WAL was created). |
| 132 */ |
| 133 int sqlite3WalFramesize(Wal *pWal); |
| 134 #endif |
| 135 |
| 117 #endif /* ifndef SQLITE_OMIT_WAL */ | 136 #endif /* ifndef SQLITE_OMIT_WAL */ |
| 118 #endif /* _WAL_H_ */ | 137 #endif /* _WAL_H_ */ |
| OLD | NEW |