mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-05 15:55:57 +03:00
Add the sqlite3_snapshot_cmp() API.
FossilOrigin-Name: c698a21af740ca1019c3a771fb83e569cd6bf23e
This commit is contained in:
17
src/wal.c
17
src/wal.c
@@ -3399,6 +3399,23 @@ int sqlite3WalSnapshotGet(Wal *pWal, sqlite3_snapshot **ppSnapshot){
|
||||
void sqlite3WalSnapshotOpen(Wal *pWal, sqlite3_snapshot *pSnapshot){
|
||||
pWal->pSnapshot = (WalIndexHdr*)pSnapshot;
|
||||
}
|
||||
|
||||
/*
|
||||
** Return a +ve value if snapshot p1 is newer than p2. A -ve value if
|
||||
** p1 is older than p2 and zero if p1 and p2 are the same snapshot.
|
||||
*/
|
||||
int sqlite3_snapshot_cmp(sqlite3_snapshot *p1, sqlite3_snapshot *p2){
|
||||
WalIndexHdr *pHdr1 = (WalIndexHdr*)p1;
|
||||
WalIndexHdr *pHdr2 = (WalIndexHdr*)p2;
|
||||
|
||||
/* aSalt[0] is a copy of the value stored in the wal file header. It
|
||||
** is incremented each time the wal file is restarted. */
|
||||
if( pHdr1->aSalt[0]<pHdr2->aSalt[0] ) return -1;
|
||||
if( pHdr1->aSalt[0]>pHdr2->aSalt[0] ) return +1;
|
||||
if( pHdr1->mxFrame<pHdr2->mxFrame ) return -1;
|
||||
if( pHdr1->mxFrame>pHdr2->mxFrame ) return +1;
|
||||
return 0;
|
||||
}
|
||||
#endif /* SQLITE_ENABLE_SNAPSHOT */
|
||||
|
||||
#ifdef SQLITE_ENABLE_ZIPVFS
|
||||
|
Reference in New Issue
Block a user