Annotation of embedaddon/sqlite3/src/wal.h, revision 1.1

1.1     ! misho       1: /*
        !             2: ** 2010 February 1
        !             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 to the write-ahead logging 
        !            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.
        !            15: */
        !            16: 
        !            17: #ifndef _WAL_H_
        !            18: #define _WAL_H_
        !            19: 
        !            20: #include "sqliteInt.h"
        !            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: 
        !            28: #ifdef SQLITE_OMIT_WAL
        !            29: # define sqlite3WalOpen(x,y,z)                   0
        !            30: # define sqlite3WalLimit(x,y)
        !            31: # define sqlite3WalClose(w,x,y,z)                0
        !            32: # define sqlite3WalBeginReadTransaction(y,z)     0
        !            33: # define sqlite3WalEndReadTransaction(z)
        !            34: # define sqlite3WalRead(v,w,x,y,z)               0
        !            35: # define sqlite3WalDbsize(y)                     0
        !            36: # define sqlite3WalBeginWriteTransaction(y)      0
        !            37: # define sqlite3WalEndWriteTransaction(x)        0
        !            38: # define sqlite3WalUndo(x,y,z)                   0
        !            39: # define sqlite3WalSavepoint(y,z)
        !            40: # define sqlite3WalSavepointUndo(y,z)            0
        !            41: # define sqlite3WalFrames(u,v,w,x,y,z)           0
        !            42: # define sqlite3WalCheckpoint(r,s,t,u,v,w,x,y,z) 0
        !            43: # define sqlite3WalCallback(z)                   0
        !            44: # define sqlite3WalExclusiveMode(y,z)            0
        !            45: # define sqlite3WalHeapMemory(z)                 0
        !            46: #else
        !            47: 
        !            48: #define WAL_SAVEPOINT_NDATA 4
        !            49: 
        !            50: /* Connection to a write-ahead log (WAL) file. 
        !            51: ** There is one object of this type for each pager. 
        !            52: */
        !            53: typedef struct Wal Wal;
        !            54: 
        !            55: /* Open and close a connection to a write-ahead log. */
        !            56: int sqlite3WalOpen(sqlite3_vfs*, sqlite3_file*, const char *, int, i64, Wal**);
        !            57: int sqlite3WalClose(Wal *pWal, int sync_flags, int, u8 *);
        !            58: 
        !            59: /* Set the limiting size of a WAL file. */
        !            60: void sqlite3WalLimit(Wal*, i64);
        !            61: 
        !            62: /* Used by readers to open (lock) and close (unlock) a snapshot.  A 
        !            63: ** snapshot is like a read-transaction.  It is the state of the database
        !            64: ** at an instant in time.  sqlite3WalOpenSnapshot gets a read lock and
        !            65: ** preserves the current state even if the other threads or processes
        !            66: ** write to or checkpoint the WAL.  sqlite3WalCloseSnapshot() closes the
        !            67: ** transaction and releases the lock.
        !            68: */
        !            69: int sqlite3WalBeginReadTransaction(Wal *pWal, int *);
        !            70: void sqlite3WalEndReadTransaction(Wal *pWal);
        !            71: 
        !            72: /* Read a page from the write-ahead log, if it is present. */
        !            73: int sqlite3WalRead(Wal *pWal, Pgno pgno, int *pInWal, int nOut, u8 *pOut);
        !            74: 
        !            75: /* If the WAL is not empty, return the size of the database. */
        !            76: Pgno sqlite3WalDbsize(Wal *pWal);
        !            77: 
        !            78: /* Obtain or release the WRITER lock. */
        !            79: int sqlite3WalBeginWriteTransaction(Wal *pWal);
        !            80: int sqlite3WalEndWriteTransaction(Wal *pWal);
        !            81: 
        !            82: /* Undo any frames written (but not committed) to the log */
        !            83: int sqlite3WalUndo(Wal *pWal, int (*xUndo)(void *, Pgno), void *pUndoCtx);
        !            84: 
        !            85: /* Return an integer that records the current (uncommitted) write
        !            86: ** position in the WAL */
        !            87: void sqlite3WalSavepoint(Wal *pWal, u32 *aWalData);
        !            88: 
        !            89: /* Move the write position of the WAL back to iFrame.  Called in
        !            90: ** response to a ROLLBACK TO command. */
        !            91: int sqlite3WalSavepointUndo(Wal *pWal, u32 *aWalData);
        !            92: 
        !            93: /* Write a frame or frames to the log. */
        !            94: int sqlite3WalFrames(Wal *pWal, int, PgHdr *, Pgno, int, int);
        !            95: 
        !            96: /* Copy pages from the log to the database file */ 
        !            97: int sqlite3WalCheckpoint(
        !            98:   Wal *pWal,                      /* Write-ahead log connection */
        !            99:   int eMode,                      /* One of PASSIVE, FULL and RESTART */
        !           100:   int (*xBusy)(void*),            /* Function to call when busy */
        !           101:   void *pBusyArg,                 /* Context argument for xBusyHandler */
        !           102:   int sync_flags,                 /* Flags to sync db file with (or 0) */
        !           103:   int nBuf,                       /* Size of buffer nBuf */
        !           104:   u8 *zBuf,                       /* Temporary buffer to use */
        !           105:   int *pnLog,                     /* OUT: Number of frames in WAL */
        !           106:   int *pnCkpt                     /* OUT: Number of backfilled frames in WAL */
        !           107: );
        !           108: 
        !           109: /* Return the value to pass to a sqlite3_wal_hook callback, the
        !           110: ** number of frames in the WAL at the point of the last commit since
        !           111: ** sqlite3WalCallback() was called.  If no commits have occurred since
        !           112: ** the last call, then return 0.
        !           113: */
        !           114: int sqlite3WalCallback(Wal *pWal);
        !           115: 
        !           116: /* Tell the wal layer that an EXCLUSIVE lock has been obtained (or released)
        !           117: ** by the pager layer on the database file.
        !           118: */
        !           119: int sqlite3WalExclusiveMode(Wal *pWal, int op);
        !           120: 
        !           121: /* Return true if the argument is non-NULL and the WAL module is using
        !           122: ** heap-memory for the wal-index. Otherwise, if the argument is NULL or the
        !           123: ** WAL module is using shared-memory, return false. 
        !           124: */
        !           125: int sqlite3WalHeapMemory(Wal *pWal);
        !           126: 
        !           127: #endif /* ifndef SQLITE_OMIT_WAL */
        !           128: #endif /* _WAL_H_ */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>