/ Check-in [7c6a809e]
Login

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

Overview
Comment:Add the SQLITE_FCNTL_VFS_POINTER file control which obtains a pointer to the top-level VFS in use by a database connection.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 7c6a809e25138950f50554e1fb96e0b6ebbe0bd4
User & Date: drh 2015-11-28 18:06:36
Context
2015-11-28
21:49
Improvements to temporary file creation logic in the unix VFS. check-in: d6e177fd user: drh tags: trunk
18:06
Add the SQLITE_FCNTL_VFS_POINTER file control which obtains a pointer to the top-level VFS in use by a database connection. check-in: 7c6a809e user: drh tags: trunk
17:38
Disable testing with SQLITE_USER_AUTHENTICATION as the makefiles are not set up to do that. check-in: 14bbcdc6 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/main.c.

  3416   3416       pPager = sqlite3BtreePager(pBtree);
  3417   3417       assert( pPager!=0 );
  3418   3418       fd = sqlite3PagerFile(pPager);
  3419   3419       assert( fd!=0 );
  3420   3420       if( op==SQLITE_FCNTL_FILE_POINTER ){
  3421   3421         *(sqlite3_file**)pArg = fd;
  3422   3422         rc = SQLITE_OK;
         3423  +    }else if( op==SQLITE_FCNTL_VFS_POINTER ){
         3424  +      *(sqlite3_vfs**)pArg = sqlite3PagerVfs(pPager);
         3425  +      rc = SQLITE_OK;
  3423   3426       }else if( fd->pMethods ){
  3424   3427         rc = sqlite3OsFileControl(fd, op, pArg);
  3425   3428       }else{
  3426   3429         rc = SQLITE_NOTFOUND;
  3427   3430       }
  3428   3431       sqlite3BtreeLeave(pBtree);
  3429   3432     }

Changes to src/pager.c.

  6675   6675   const char *sqlite3PagerFilename(Pager *pPager, int nullIfMemDb){
  6676   6676     return (nullIfMemDb && pPager->memDb) ? "" : pPager->zFilename;
  6677   6677   }
  6678   6678   
  6679   6679   /*
  6680   6680   ** Return the VFS structure for the pager.
  6681   6681   */
  6682         -const sqlite3_vfs *sqlite3PagerVfs(Pager *pPager){
         6682  +sqlite3_vfs *sqlite3PagerVfs(Pager *pPager){
  6683   6683     return pPager->pVfs;
  6684   6684   }
  6685   6685   
  6686   6686   /*
  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.

Changes to src/pager.h.

   178    178   u8 sqlite3PagerIsreadonly(Pager*);
   179    179   u32 sqlite3PagerDataVersion(Pager*);
   180    180   #ifdef SQLITE_DEBUG
   181    181     int sqlite3PagerRefcount(Pager*);
   182    182   #endif
   183    183   int sqlite3PagerMemUsed(Pager*);
   184    184   const char *sqlite3PagerFilename(Pager*, int);
   185         -const sqlite3_vfs *sqlite3PagerVfs(Pager*);
          185  +sqlite3_vfs *sqlite3PagerVfs(Pager*);
   186    186   sqlite3_file *sqlite3PagerFile(Pager*);
   187    187   const char *sqlite3PagerJournalname(Pager*);
   188    188   int sqlite3PagerNosync(Pager*);
   189    189   void *sqlite3PagerTempSpace(Pager*);
   190    190   int sqlite3PagerIsMemdb(Pager*);
   191    191   void sqlite3PagerCacheStat(Pager *, int, int, int *);
   192    192   void sqlite3PagerClearCache(Pager *);

Changes to src/shell.c.

  1843   1843     ".system CMD ARGS...    Run CMD ARGS... in a system shell\n"
  1844   1844     ".tables ?TABLE?        List names of tables\n"
  1845   1845     "                         If TABLE specified, only list tables matching\n"
  1846   1846     "                         LIKE pattern TABLE.\n"
  1847   1847     ".timeout MS            Try opening locked tables for MS milliseconds\n"
  1848   1848     ".timer on|off          Turn SQL timer on or off\n"
  1849   1849     ".trace FILE|off        Output each SQL statement as it is run\n"
         1850  +  ".vfsinfo ?AUX?         Information about the top-level VFS\n"
  1850   1851     ".vfsname ?AUX?         Print the name of the VFS stack\n"
  1851   1852     ".width NUM1 NUM2 ...   Set column widths for \"column\" mode\n"
  1852   1853     "                         Negative values right-justify\n"
  1853   1854   ;
  1854   1855   
  1855   1856   /* Forward reference */
  1856   1857   static int process_input(ShellState *p, FILE *in);
................................................................................
  4062   4063     }else
  4063   4064   #endif /* SQLITE_USER_AUTHENTICATION */
  4064   4065   
  4065   4066     if( c=='v' && strncmp(azArg[0], "version", n)==0 ){
  4066   4067       fprintf(p->out, "SQLite %s %s\n" /*extra-version-info*/,
  4067   4068           sqlite3_libversion(), sqlite3_sourceid());
  4068   4069     }else
         4070  +
         4071  +  if( c=='v' && strncmp(azArg[0], "vfsinfo", n)==0 ){
         4072  +    const char *zDbName = nArg==2 ? azArg[1] : "main";
         4073  +    sqlite3_vfs *pVfs;
         4074  +    if( p->db ){
         4075  +      sqlite3_file_control(p->db, zDbName, SQLITE_FCNTL_VFS_POINTER, &pVfs);
         4076  +      if( pVfs ){
         4077  +        fprintf(p->out, "vfs.zName      = \"%s\"\n", pVfs->zName);
         4078  +        fprintf(p->out, "vfs.iVersion   = %d\n", pVfs->iVersion);
         4079  +        fprintf(p->out, "vfs.szOsFile   = %d\n", pVfs->szOsFile);
         4080  +        fprintf(p->out, "vfs.mxPathname = %d\n", pVfs->mxPathname);
         4081  +      }
         4082  +    }
         4083  +  }else
  4069   4084   
  4070   4085     if( c=='v' && strncmp(azArg[0], "vfsname", n)==0 ){
  4071   4086       const char *zDbName = nArg==2 ? azArg[1] : "main";
  4072   4087       char *zVfsName = 0;
  4073   4088       if( p->db ){
  4074   4089         sqlite3_file_control(p->db, zDbName, SQLITE_FCNTL_VFSNAME, &zVfsName);
  4075   4090         if( zVfsName ){

Changes to src/sqlite.h.in.

   877    877   ** [sqlite3_malloc()] and the result is stored in the char* variable
   878    878   ** that the fourth parameter of [sqlite3_file_control()] points to.
   879    879   ** The caller is responsible for freeing the memory when done.  As with
   880    880   ** all file-control actions, there is no guarantee that this will actually
   881    881   ** do anything.  Callers should initialize the char* variable to a NULL
   882    882   ** pointer in case this file-control is not implemented.  This file-control
   883    883   ** is intended for diagnostic use only.
          884  +**
          885  +** <li>[[SQLITE_FCNTL_VFS_POINTER]]
          886  +** ^The [SQLITE_FCNTL_VFS_POINTER] opcode finds a pointer to the top-level
          887  +** [VFSes] currently in use.  ^(The argument X in
          888  +** sqlite3_file_control(db,SQLITE_FCNTL_VFS_POINTER,X) must be
          889  +** of type "[sqlite3_vfs] **".  This opcodes will set *X
          890  +** to a pointer to the top-level VFS.^)
          891  +** ^When there are multiple VFS shims in the stack, this opcode finds the
          892  +** upper-most shim only.
   884    893   **
   885    894   ** <li>[[SQLITE_FCNTL_PRAGMA]]
   886    895   ** ^Whenever a [PRAGMA] statement is parsed, an [SQLITE_FCNTL_PRAGMA] 
   887    896   ** file control is sent to the open [sqlite3_file] object corresponding
   888    897   ** to the database file to which the pragma statement refers. ^The argument
   889    898   ** to the [SQLITE_FCNTL_PRAGMA] file control is an array of
   890    899   ** pointers to strings (char**) in which the second element of the array
................................................................................
   996   1005   #define SQLITE_FCNTL_HAS_MOVED              20
   997   1006   #define SQLITE_FCNTL_SYNC                   21
   998   1007   #define SQLITE_FCNTL_COMMIT_PHASETWO        22
   999   1008   #define SQLITE_FCNTL_WIN32_SET_HANDLE       23
  1000   1009   #define SQLITE_FCNTL_WAL_BLOCK              24
  1001   1010   #define SQLITE_FCNTL_ZIPVFS                 25
  1002   1011   #define SQLITE_FCNTL_RBU                    26
         1012  +#define SQLITE_FCNTL_VFS_POINTER            27
  1003   1013   
  1004   1014   /* deprecated names */
  1005   1015   #define SQLITE_GET_LOCKPROXYFILE      SQLITE_FCNTL_GET_LOCKPROXYFILE
  1006   1016   #define SQLITE_SET_LOCKPROXYFILE      SQLITE_FCNTL_SET_LOCKPROXYFILE
  1007   1017   #define SQLITE_LAST_ERRNO             SQLITE_FCNTL_LAST_ERRNO
  1008   1018   
  1009   1019