diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 3 | ||||
-rw-r--r-- | src/pager.c | 8 | ||||
-rw-r--r-- | src/pager.h | 1 | ||||
-rw-r--r-- | src/sqlite.h.in | 10 | ||||
-rw-r--r-- | src/wal.c | 6 | ||||
-rw-r--r-- | src/wal.h | 4 |
6 files changed, 30 insertions, 2 deletions
diff --git a/src/main.c b/src/main.c index 8b75e7150..2998f54c7 100644 --- a/src/main.c +++ b/src/main.c @@ -3424,6 +3424,9 @@ int sqlite3_file_control(sqlite3 *db, const char *zDbName, int op, void *pArg){ }else if( op==SQLITE_FCNTL_VFS_POINTER ){ *(sqlite3_vfs**)pArg = sqlite3PagerVfs(pPager); rc = SQLITE_OK; + }else if( op==SQLITE_FCNTL_JOURNAL_POINTER ){ + *(sqlite3_file**)pArg = sqlite3PagerJrnlFile(pPager); + rc = SQLITE_OK; }else if( fd->pMethods ){ rc = sqlite3OsFileControl(fd, op, pArg); }else{ diff --git a/src/pager.c b/src/pager.c index 2c8dceb75..8f49e656e 100644 --- a/src/pager.c +++ b/src/pager.c @@ -6693,6 +6693,14 @@ sqlite3_file *sqlite3PagerFile(Pager *pPager){ } /* +** Return the file handle for the journal file (if it exists). +** This will be either the rollback journal or the WAL file. +*/ +sqlite3_file *sqlite3PagerJrnlFile(Pager *pPager){ + return pPager->pWal ? sqlite3WalFile(pPager->pWal) : pPager->jfd; +} + +/* ** Return the full pathname of the journal file. */ const char *sqlite3PagerJournalname(Pager *pPager){ diff --git a/src/pager.h b/src/pager.h index ba4eec438..3552a876e 100644 --- a/src/pager.h +++ b/src/pager.h @@ -188,6 +188,7 @@ int sqlite3PagerMemUsed(Pager*); const char *sqlite3PagerFilename(Pager*, int); sqlite3_vfs *sqlite3PagerVfs(Pager*); sqlite3_file *sqlite3PagerFile(Pager*); +sqlite3_file *sqlite3PagerJrnlFile(Pager*); const char *sqlite3PagerJournalname(Pager*); int sqlite3PagerNosync(Pager*); void *sqlite3PagerTempSpace(Pager*); diff --git a/src/sqlite.h.in b/src/sqlite.h.in index be58c7cd1..59b30cdd3 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -794,8 +794,13 @@ struct sqlite3_io_methods { ** <li>[[SQLITE_FCNTL_FILE_POINTER]] ** The [SQLITE_FCNTL_FILE_POINTER] opcode is used to obtain a pointer ** to the [sqlite3_file] object associated with a particular database -** connection. See the [sqlite3_file_control()] documentation for -** additional information. +** connection. See also [SQLITE_FCNTL_JOURNAL_POINTER]. +** +** <li>[[SQLITE_FCNTL_JOURNAL_POINTER]] +** The [SQLITE_FCNTL_JOURNAL_POINTER] opcode is used to obtain a pointer +** to the [sqlite3_file] object associated with the journal file (either +** the [rollback journal] or the [write-ahead log]) for a particular database +** connection. See also [SQLITE_FCNTL_FILE_POINTER]. ** ** <li>[[SQLITE_FCNTL_SYNC_OMITTED]] ** No longer in use. @@ -1010,6 +1015,7 @@ struct sqlite3_io_methods { #define SQLITE_FCNTL_ZIPVFS 25 #define SQLITE_FCNTL_RBU 26 #define SQLITE_FCNTL_VFS_POINTER 27 +#define SQLITE_FCNTL_JOURNAL_POINTER 28 /* deprecated names */ #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE @@ -3407,4 +3407,10 @@ int sqlite3WalFramesize(Wal *pWal){ } #endif +/* Return the sqlite3_file object for the WAL file +*/ +sqlite3_file *sqlite3WalFile(Wal *pWal){ + return pWal->pWalFd; +} + #endif /* #ifndef SQLITE_OMIT_WAL */ @@ -44,6 +44,7 @@ # define sqlite3WalHeapMemory(z) 0 # define sqlite3WalFramesize(z) 0 # define sqlite3WalFindFrame(x,y,z) 0 +# define sqlite3WalFile(x) 0 #else #define WAL_SAVEPOINT_NDATA 4 @@ -138,5 +139,8 @@ void sqlite3WalSnapshotOpen(Wal *pWal, sqlite3_snapshot *pSnapshot); int sqlite3WalFramesize(Wal *pWal); #endif +/* Return the sqlite3_file object for the WAL file */ +sqlite3_file *sqlite3WalFile(Wal *pWal); + #endif /* ifndef SQLITE_OMIT_WAL */ #endif /* _WAL_H_ */ |