/ Check-in [ad3daa54]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add the SQLITE_FCNTL_JOURNAL_POINTER file control.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: ad3daa5427672d2d236939ad3285b765f4601801
User & Date: drh 2016-01-13 18:12:44
Context
2016-01-13
18:25
Add documentation for new API functions to the comments in fts5.h. check-in: 14d296fa user: dan tags: trunk
18:21
Add the SQLITE_FCNTL_JOURNAL_POINTER file control. check-in: ea9ce228 user: drh tags: branch-3.10
18:12
Add the SQLITE_FCNTL_JOURNAL_POINTER file control. check-in: ad3daa54 user: drh tags: trunk
18:06
Add documentation for the SQLITE_FCNTL_JOURNAL_POINTER file-control. Closed-Leaf check-in: 807c5aee user: drh tags: file-control-journal
17:50
When the block sorting optimization is used in a scalar subquery, be sure to exit the loop as soon as the first valid output row is received. Fix for ticket [cb3aa0641d9a4]. check-in: cdbb0947 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Show Whitespace Changes Patch

Changes to src/main.c.

  3420   3420       assert( fd!=0 );
  3421   3421       if( op==SQLITE_FCNTL_FILE_POINTER ){
  3422   3422         *(sqlite3_file**)pArg = fd;
  3423   3423         rc = SQLITE_OK;
  3424   3424       }else if( op==SQLITE_FCNTL_VFS_POINTER ){
  3425   3425         *(sqlite3_vfs**)pArg = sqlite3PagerVfs(pPager);
  3426   3426         rc = SQLITE_OK;
         3427  +    }else if( op==SQLITE_FCNTL_JOURNAL_POINTER ){
         3428  +      *(sqlite3_file**)pArg = sqlite3PagerJrnlFile(pPager);
         3429  +      rc = SQLITE_OK;
  3427   3430       }else if( fd->pMethods ){
  3428   3431         rc = sqlite3OsFileControl(fd, op, pArg);
  3429   3432       }else{
  3430   3433         rc = SQLITE_NOTFOUND;
  3431   3434       }
  3432   3435       sqlite3BtreeLeave(pBtree);
  3433   3436     }

Changes to src/pager.c.

  6687   6687   ** Return the file handle for the database file associated
  6688   6688   ** with the pager.  This might return NULL if the file has
  6689   6689   ** not yet been opened.
  6690   6690   */
  6691   6691   sqlite3_file *sqlite3PagerFile(Pager *pPager){
  6692   6692     return pPager->fd;
  6693   6693   }
         6694  +
         6695  +/*
         6696  +** Return the file handle for the journal file (if it exists).
         6697  +** This will be either the rollback journal or the WAL file.
         6698  +*/
         6699  +sqlite3_file *sqlite3PagerJrnlFile(Pager *pPager){
         6700  +  return pPager->pWal ? sqlite3WalFile(pPager->pWal) : pPager->jfd;
         6701  +}
  6694   6702   
  6695   6703   /*
  6696   6704   ** Return the full pathname of the journal file.
  6697   6705   */
  6698   6706   const char *sqlite3PagerJournalname(Pager *pPager){
  6699   6707     return pPager->zJournal;
  6700   6708   }

Changes to src/pager.h.

   184    184   #ifdef SQLITE_DEBUG
   185    185     int sqlite3PagerRefcount(Pager*);
   186    186   #endif
   187    187   int sqlite3PagerMemUsed(Pager*);
   188    188   const char *sqlite3PagerFilename(Pager*, int);
   189    189   sqlite3_vfs *sqlite3PagerVfs(Pager*);
   190    190   sqlite3_file *sqlite3PagerFile(Pager*);
          191  +sqlite3_file *sqlite3PagerJrnlFile(Pager*);
   191    192   const char *sqlite3PagerJournalname(Pager*);
   192    193   int sqlite3PagerNosync(Pager*);
   193    194   void *sqlite3PagerTempSpace(Pager*);
   194    195   int sqlite3PagerIsMemdb(Pager*);
   195    196   void sqlite3PagerCacheStat(Pager *, int, int, int *);
   196    197   void sqlite3PagerClearCache(Pager *);
   197    198   int sqlite3SectorSize(sqlite3_file *);

Changes to src/sqlite.h.in.

   790    790   ** for the nominated database. Allocating database file space in large
   791    791   ** chunks (say 1MB at a time), may reduce file-system fragmentation and
   792    792   ** improve performance on some systems.
   793    793   **
   794    794   ** <li>[[SQLITE_FCNTL_FILE_POINTER]]
   795    795   ** The [SQLITE_FCNTL_FILE_POINTER] opcode is used to obtain a pointer
   796    796   ** to the [sqlite3_file] object associated with a particular database
   797         -** connection.  See the [sqlite3_file_control()] documentation for
   798         -** additional information.
          797  +** connection.  See also [SQLITE_FCNTL_JOURNAL_POINTER].
          798  +**
          799  +** <li>[[SQLITE_FCNTL_JOURNAL_POINTER]]
          800  +** The [SQLITE_FCNTL_JOURNAL_POINTER] opcode is used to obtain a pointer
          801  +** to the [sqlite3_file] object associated with the journal file (either
          802  +** the [rollback journal] or the [write-ahead log]) for a particular database
          803  +** connection.  See also [SQLITE_FCNTL_FILE_POINTER].
   799    804   **
   800    805   ** <li>[[SQLITE_FCNTL_SYNC_OMITTED]]
   801    806   ** No longer in use.
   802    807   **
   803    808   ** <li>[[SQLITE_FCNTL_SYNC]]
   804    809   ** The [SQLITE_FCNTL_SYNC] opcode is generated internally by SQLite and
   805    810   ** sent to the VFS immediately before the xSync method is invoked on a
................................................................................
  1006   1011   #define SQLITE_FCNTL_SYNC                   21
  1007   1012   #define SQLITE_FCNTL_COMMIT_PHASETWO        22
  1008   1013   #define SQLITE_FCNTL_WIN32_SET_HANDLE       23
  1009   1014   #define SQLITE_FCNTL_WAL_BLOCK              24
  1010   1015   #define SQLITE_FCNTL_ZIPVFS                 25
  1011   1016   #define SQLITE_FCNTL_RBU                    26
  1012   1017   #define SQLITE_FCNTL_VFS_POINTER            27
         1018  +#define SQLITE_FCNTL_JOURNAL_POINTER        28
  1013   1019   
  1014   1020   /* deprecated names */
  1015   1021   #define SQLITE_GET_LOCKPROXYFILE      SQLITE_FCNTL_GET_LOCKPROXYFILE
  1016   1022   #define SQLITE_SET_LOCKPROXYFILE      SQLITE_FCNTL_SET_LOCKPROXYFILE
  1017   1023   #define SQLITE_LAST_ERRNO             SQLITE_FCNTL_LAST_ERRNO
  1018   1024   
  1019   1025   

Changes to src/wal.c.

  3402   3402   ** or zero if it is not (or if pWal is NULL).
  3403   3403   */
  3404   3404   int sqlite3WalFramesize(Wal *pWal){
  3405   3405     assert( pWal==0 || pWal->readLock>=0 );
  3406   3406     return (pWal ? pWal->szPage : 0);
  3407   3407   }
  3408   3408   #endif
         3409  +
         3410  +/* Return the sqlite3_file object for the WAL file
         3411  +*/
         3412  +sqlite3_file *sqlite3WalFile(Wal *pWal){
         3413  +  return pWal->pWalFd;
         3414  +}
  3409   3415   
  3410   3416   #endif /* #ifndef SQLITE_OMIT_WAL */

Changes to src/wal.h.

    40     40   # define sqlite3WalFrames(u,v,w,x,y,z)           0
    41     41   # define sqlite3WalCheckpoint(r,s,t,u,v,w,x,y,z) 0
    42     42   # define sqlite3WalCallback(z)                   0
    43     43   # define sqlite3WalExclusiveMode(y,z)            0
    44     44   # define sqlite3WalHeapMemory(z)                 0
    45     45   # define sqlite3WalFramesize(z)                  0
    46     46   # define sqlite3WalFindFrame(x,y,z)              0
           47  +# define sqlite3WalFile(x)                       0
    47     48   #else
    48     49   
    49     50   #define WAL_SAVEPOINT_NDATA 4
    50     51   
    51     52   /* Connection to a write-ahead log (WAL) file. 
    52     53   ** There is one object of this type for each pager. 
    53     54   */
................................................................................
   133    134   
   134    135   #ifdef SQLITE_ENABLE_ZIPVFS
   135    136   /* If the WAL file is not empty, return the number of bytes of content
   136    137   ** stored in each frame (i.e. the db page-size when the WAL was created).
   137    138   */
   138    139   int sqlite3WalFramesize(Wal *pWal);
   139    140   #endif
          141  +
          142  +/* Return the sqlite3_file object for the WAL file */
          143  +sqlite3_file *sqlite3WalFile(Wal *pWal);
   140    144   
   141    145   #endif /* ifndef SQLITE_OMIT_WAL */
   142    146   #endif /* _WAL_H_ */