Add the SQLITE_FCNTL_VFS_POINTER file control which obtains a pointer to
the top-level VFS in use by a database connection. FossilOrigin-Name: 7c6a809e25138950f50554e1fb96e0b6ebbe0bd4
This commit is contained in:
@@ -3420,6 +3420,9 @@ int sqlite3_file_control(sqlite3 *db, const char *zDbName, int op, void *pArg){
|
||||
if( op==SQLITE_FCNTL_FILE_POINTER ){
|
||||
*(sqlite3_file**)pArg = fd;
|
||||
rc = SQLITE_OK;
|
||||
}else if( op==SQLITE_FCNTL_VFS_POINTER ){
|
||||
*(sqlite3_vfs**)pArg = sqlite3PagerVfs(pPager);
|
||||
rc = SQLITE_OK;
|
||||
}else if( fd->pMethods ){
|
||||
rc = sqlite3OsFileControl(fd, op, pArg);
|
||||
}else{
|
||||
|
||||
+1
-1
@@ -6679,7 +6679,7 @@ const char *sqlite3PagerFilename(Pager *pPager, int nullIfMemDb){
|
||||
/*
|
||||
** Return the VFS structure for the pager.
|
||||
*/
|
||||
const sqlite3_vfs *sqlite3PagerVfs(Pager *pPager){
|
||||
sqlite3_vfs *sqlite3PagerVfs(Pager *pPager){
|
||||
return pPager->pVfs;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -182,7 +182,7 @@ u32 sqlite3PagerDataVersion(Pager*);
|
||||
#endif
|
||||
int sqlite3PagerMemUsed(Pager*);
|
||||
const char *sqlite3PagerFilename(Pager*, int);
|
||||
const sqlite3_vfs *sqlite3PagerVfs(Pager*);
|
||||
sqlite3_vfs *sqlite3PagerVfs(Pager*);
|
||||
sqlite3_file *sqlite3PagerFile(Pager*);
|
||||
const char *sqlite3PagerJournalname(Pager*);
|
||||
int sqlite3PagerNosync(Pager*);
|
||||
|
||||
+15
@@ -1847,6 +1847,7 @@ static char zHelp[] =
|
||||
".timeout MS Try opening locked tables for MS milliseconds\n"
|
||||
".timer on|off Turn SQL timer on or off\n"
|
||||
".trace FILE|off Output each SQL statement as it is run\n"
|
||||
".vfsinfo ?AUX? Information about the top-level VFS\n"
|
||||
".vfsname ?AUX? Print the name of the VFS stack\n"
|
||||
".width NUM1 NUM2 ... Set column widths for \"column\" mode\n"
|
||||
" Negative values right-justify\n"
|
||||
@@ -4067,6 +4068,20 @@ static int do_meta_command(char *zLine, ShellState *p){
|
||||
sqlite3_libversion(), sqlite3_sourceid());
|
||||
}else
|
||||
|
||||
if( c=='v' && strncmp(azArg[0], "vfsinfo", n)==0 ){
|
||||
const char *zDbName = nArg==2 ? azArg[1] : "main";
|
||||
sqlite3_vfs *pVfs;
|
||||
if( p->db ){
|
||||
sqlite3_file_control(p->db, zDbName, SQLITE_FCNTL_VFS_POINTER, &pVfs);
|
||||
if( pVfs ){
|
||||
fprintf(p->out, "vfs.zName = \"%s\"\n", pVfs->zName);
|
||||
fprintf(p->out, "vfs.iVersion = %d\n", pVfs->iVersion);
|
||||
fprintf(p->out, "vfs.szOsFile = %d\n", pVfs->szOsFile);
|
||||
fprintf(p->out, "vfs.mxPathname = %d\n", pVfs->mxPathname);
|
||||
}
|
||||
}
|
||||
}else
|
||||
|
||||
if( c=='v' && strncmp(azArg[0], "vfsname", n)==0 ){
|
||||
const char *zDbName = nArg==2 ? azArg[1] : "main";
|
||||
char *zVfsName = 0;
|
||||
|
||||
@@ -882,6 +882,15 @@ struct sqlite3_io_methods {
|
||||
** pointer in case this file-control is not implemented. This file-control
|
||||
** is intended for diagnostic use only.
|
||||
**
|
||||
** <li>[[SQLITE_FCNTL_VFS_POINTER]]
|
||||
** ^The [SQLITE_FCNTL_VFS_POINTER] opcode finds a pointer to the top-level
|
||||
** [VFSes] currently in use. ^(The argument X in
|
||||
** sqlite3_file_control(db,SQLITE_FCNTL_VFS_POINTER,X) must be
|
||||
** of type "[sqlite3_vfs] **". This opcodes will set *X
|
||||
** to a pointer to the top-level VFS.^)
|
||||
** ^When there are multiple VFS shims in the stack, this opcode finds the
|
||||
** upper-most shim only.
|
||||
**
|
||||
** <li>[[SQLITE_FCNTL_PRAGMA]]
|
||||
** ^Whenever a [PRAGMA] statement is parsed, an [SQLITE_FCNTL_PRAGMA]
|
||||
** file control is sent to the open [sqlite3_file] object corresponding
|
||||
@@ -1000,6 +1009,7 @@ struct sqlite3_io_methods {
|
||||
#define SQLITE_FCNTL_WAL_BLOCK 24
|
||||
#define SQLITE_FCNTL_ZIPVFS 25
|
||||
#define SQLITE_FCNTL_RBU 26
|
||||
#define SQLITE_FCNTL_VFS_POINTER 27
|
||||
|
||||
/* deprecated names */
|
||||
#define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE
|
||||
|
||||
Reference in New Issue
Block a user