Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Begin to add logging to btree database. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
ca59333dcdf51bfc4c32bddf9e590d24 |
User & Date: | dan 2013-10-19 20:24:31.680 |
Context
2013-10-21
| ||
20:04 | Continue adding logging to the btree module. Still does not work. check-in: ae62a34eb7 user: dan tags: trunk | |
2013-10-19
| ||
20:24 | Begin to add logging to btree database. check-in: ca59333dcd user: dan tags: trunk | |
05:50 | Add missing bt_varint.c file. check-in: e5d33eb472 user: dan tags: trunk | |
Changes
Changes to src/btInt.h.
︙ | ︙ | |||
22 23 24 25 26 27 28 29 30 31 32 33 34 35 | typedef unsigned short u16; typedef unsigned char u8; /* Number of elements in an array object. */ #define array_size(x) (sizeof(x)/sizeof(x[0])) /************************************************************************* ** Interface to bt_pager.c functionality. */ typedef struct BtPage BtPage; typedef struct BtPager BtPager; | > > > | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | typedef unsigned short u16; typedef unsigned char u8; /* Number of elements in an array object. */ #define array_size(x) (sizeof(x)/sizeof(x[0])) /* Number of read-lock slots in shared memory */ #define BT_NREADER 4 /************************************************************************* ** Interface to bt_pager.c functionality. */ typedef struct BtPage BtPage; typedef struct BtPager BtPager; |
︙ | ︙ | |||
157 158 159 160 161 162 163 164 | int sqlite4BtVarintGet64(const u8 *aData, i64 *piVal); int sqlite4BtVarintLen32(int); int sqlite4BtVarintSize(u8 c); /* ** End of bt_varint.c interface. *************************************************************************/ /************************************************************************* | | > > > | > > | > > > | > > > > > > > > > > > | > > > > > > > | | > | 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | int sqlite4BtVarintGet64(const u8 *aData, i64 *piVal); int sqlite4BtVarintLen32(int); int sqlite4BtVarintSize(u8 c); /* ** End of bt_varint.c interface. *************************************************************************/ /************************************************************************* ** Interface to bt_log.c functionality. */ typedef struct BtLog BtLog; int sqlite4BtLogOpen(BtPager*, BtLog**, int bRecover); int sqlite4BtLogClose(BtLog*, int bCleanup); int sqlite4BtLogRead(BtLog*, u32 pgno, u8 *aData); int sqlite4BtLogWrite(BtLog*, u32 pgno, u8 *aData, int bCommit); int sqlite4BtLogSnapshotOpen(BtLog*); int sqlite4BtLogSnapshotClose(BtLog*); int sqlite4BtLogSnapshotWritable(BtLog*); int sqlite4BtLogCheckpoint(BtLog*); /* ** End of bt_log.c interface. *************************************************************************/ /************************************************************************* ** Interface to bt_lock.c functionality. */ typedef struct BtLock BtLock; struct BtLock { /* These three are set by the bt_pager module and thereafter used by ** both bt_lock and bt_pager. */ sqlite4_env *pEnv; /* SQLite environment */ bt_env *pVfs; /* Bt environment */ bt_file *pFd; /* Database file descriptor */ /* These are used only by the bt_lock module. */ /* todo... */ }; /* Connect and disconnect procedures */ int sqlite4BtLockConnect(BtLock*, int (*xRecover)(BtLock*)); int sqlite4BtLockDisconnect(BtLock*, int(*xCkpt)(BtLock*), int(*xDel)(BtLock*)); /* Obtain and release the WRITER lock */ int sqlite4BtLockWriter(BtLock*); int sqlite4BtLockWriterUnlock(BtLock*); /* Obtain, release and query READER locks. */ int sqlite4BtLockReader(BtLock*, u32 *aLog, u32 *aLock); int sqlite4BtLockReaderUnlock(BtLock*); int sqlite4BtLockReaderMin(BtLock*, u32 *aLog, u32 *aLock, u32 *piMinFrame); /* Obtain and release CHECKPOINTER lock */ int sqlite4BtLockCkpt(BtLock*); int sqlite4BtLockCkptUnlock(BtLock*); /* ** End of bt_lock.c interface. *************************************************************************/ #ifdef NDEBUG # define btErrorBkpt(x) x #else int btErrorBkpt(int rc); #endif |
Changes to src/bt_lock.c.
︙ | ︙ | |||
44 45 46 47 48 49 50 51 52 | int sqlite4BtLockBegin(BtLock *p, int eLock){ return SQLITE4_OK; } int sqlite4BtLockEnd(BtLock *p, int eLock){ return SQLITE4_OK; } | > > > > > > > > > | 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | int sqlite4BtLockBegin(BtLock *p, int eLock){ return SQLITE4_OK; } int sqlite4BtLockEnd(BtLock *p, int eLock){ return SQLITE4_OK; } /* Obtain a READER lock. ** ** Argument aLog points to an array of 6 frame addresses. These are the ** first and last frames in each of log regions A, B and C. Argument ** aLock points to the array of read-lock slots in shared memory. */ int sqlite4BtLockReader(BtLock*, u32 *aLog, u32 *aLock){ } |
Added src/bt_log.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | /* ** 2013 October 19 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* */ #include "btInt.h" #include <string.h> #include <assert.h> #include <stdio.h> /* Magic values identifying WAL file header */ #define BT_WAL_MAGIC 0xBEE1CA62 #define BT_WAL_VERSION 0x00000001 typedef struct BtWalHdr BtWalHdr; typedef struct BtShmHdr BtShmHdr; /* ** WAL file header. All u32 fields are stored in big-endian order on ** disk. A single WAL file may contain two of these headers - one at ** byte offset 0 and the other at offset <sector-size> (the start of ** the second disk sector in the file, according to the xSectorSize ** VFS method). */ struct BtWalHdr { u32 iMagic; /* Magic number (BT_WAL_MAGIC) */ u32 iVersion; /* File format version */ u32 nSector; /* Sector size when header written */ u32 iSalt1; /* Initial frame cksum-0 value */ u32 iSalt2; /* Initial frame cksum-1 value */ u32 iFirstFrame; /* First frame of log (numbered from 1) */ u32 aCksum[2]; /* Checksum of all prior fields */ }; /* ** WAL Frame header. All fields are stored in big-endian order. */ struct BtFrameHdr { u32 pgno; /* Page number of this frame */ u32 aCksum[2]; /* Frame checksum */ }; /* ** Shared memory header. Shared memory begins with two copies of ** this structure. All fields are stored in machine byte-order. */ struct BtShmHdr { u32 aLog[6]; /* First/last frames for each log region */ }; /* ** A single instance of this structure follows the two BtShmHdr structures ** in shared memory. */ struct BtCkptHdr { u32 iFirstRead; /* First uncheckpointed frame */ u32 iFirstRecover; /* First recovery frame */ }; struct BtShm { BtShmHdr hdr1; BtShmHdr hdr2; BtCkptHdr ckpt; u32 aReadlock[BT_NREADER]; } |
Changes to src/bt_pager.c.
︙ | ︙ | |||
55 56 57 58 59 60 61 | /* ** Database header. */ struct BtDbhdr { u32 pgsz; /* Page size in bytes */ u32 nPg; /* Number of pages in database */ | | | 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | /* ** Database header. */ struct BtDbhdr { u32 pgsz; /* Page size in bytes */ u32 nPg; /* Number of pages in database */ u32 cookie; /* User cookie value (SQL schema cookie) */ }; /* ** Pager object. */ struct BtPager { BtLock btl; /* Variables shared with bt_lock module */ |
︙ | ︙ |