/ Check-in [9cd27350]
Login

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

Overview
Comment:Add initial ZIPVFS support for the "main" database to the sqlite_memstat virtual table.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | memstat-vtab
Files: files | file ages | folders
SHA3-256: 9cd27350b0f62debfe3238c57c3ab51079699142e82c05a7ec8460a8429f55f2
User & Date: drh 2018-09-27 15:45:03
Context
2018-09-27
16:57
Enhancements to sqlite_memstat: (1) Add an extra "schema" column to show the schema name for ZIPVFS stats. (2) Only show ZIPVFS stats to schema that use ZIPVFS (3) Put a NULL in unused columns of the output. Closed-Leaf check-in: 9351135b user: drh tags: memstat-vtab
15:45
Add initial ZIPVFS support for the "main" database to the sqlite_memstat virtual table. check-in: 9cd27350 user: drh tags: memstat-vtab
15:21
Initial prototype of a eponymous virtual table that accesses sqlite3_status64() and sqlite3_db_status(). check-in: 0b44e1f6 user: drh tags: memstat-vtab
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/misc/memstat.c.

   122    122   
   123    123   
   124    124   /*
   125    125   ** Allowed values for aMemstatColumn[].eType
   126    126   */
   127    127   #define MSV_GSTAT   0          /* sqlite3_status64() information */
   128    128   #define MSV_DBSTAT  1          /* sqlite3_db_status() information */
          129  +#define MSV_ZIPVFS  2          /* ZIPVFS file-control with 64-bit return */
   129    130   
   130    131   /*
   131    132   ** An array of quantities that can be measured and reported by
   132    133   ** this virtual table
   133    134   */
   134    135   static const struct MemstatColumns {
   135    136     const char *zName;    /* Symbolic name */
   136    137     int eType;            /* Type of interface */
   137    138     int eOp;              /* Opcode */
   138    139   } aMemstatColumn[] = {
   139         -  { "MEMORY_USED",         MSV_GSTAT,   SQLITE_STATUS_MEMORY_USED          },
   140         -  { "MALLOC_SIZE",         MSV_GSTAT,   SQLITE_STATUS_MALLOC_SIZE          },
   141         -  { "MALLOC_COUNT",        MSV_GSTAT,   SQLITE_STATUS_MALLOC_COUNT         },
   142         -  { "PAGECACHE_USED",      MSV_GSTAT,   SQLITE_STATUS_PAGECACHE_USED       },
   143         -  { "PAGECACHE_OVERFLOW",  MSV_GSTAT,   SQLITE_STATUS_PAGECACHE_OVERFLOW   },
   144         -  { "PAGECACHE_SIZE",      MSV_GSTAT,   SQLITE_STATUS_PAGECACHE_SIZE       },
   145         -  { "PARSER_STACK",        MSV_GSTAT,   SQLITE_STATUS_PARSER_STACK         },
   146         -  { "LOOKASIDE_USED",      MSV_DBSTAT, SQLITE_DBSTATUS_LOOKASIDE_USED      },
   147         -  { "CACHE_USED",          MSV_DBSTAT, SQLITE_DBSTATUS_CACHE_USED          },
   148         -  { "SCHEMA_USED",         MSV_DBSTAT, SQLITE_DBSTATUS_SCHEMA_USED         },
   149         -  { "STMT_USED",           MSV_DBSTAT, SQLITE_DBSTATUS_STMT_USED           },
   150         -  { "LOOKASIDE_HIT",       MSV_DBSTAT, SQLITE_DBSTATUS_LOOKASIDE_HIT       },
   151         -  { "LOOKASIDE_MISS_SIZE", MSV_DBSTAT, SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE },
   152         -  { "LOOKASIDE_MISS_FULL", MSV_DBSTAT, SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL },
   153         -  { "CACHE_HIT",           MSV_DBSTAT, SQLITE_DBSTATUS_CACHE_HIT           },
   154         -  { "CACHE_MISS",          MSV_DBSTAT, SQLITE_DBSTATUS_CACHE_MISS          },
   155         -  { "CACHE_WRITE",         MSV_DBSTAT, SQLITE_DBSTATUS_CACHE_WRITE         },
   156         -  { "DEFERRED_FKS",        MSV_DBSTAT, SQLITE_DBSTATUS_DEFERRED_FKS        },
   157         -  { "CACHE_USED_SHARED",   MSV_DBSTAT, SQLITE_DBSTATUS_CACHE_USED_SHARED   },
   158         -  { "CACHE_SPILL",         MSV_DBSTAT, SQLITE_DBSTATUS_CACHE_SPILL         },
          140  +  { "MEMORY_USED",            MSV_GSTAT,   SQLITE_STATUS_MEMORY_USED          },
          141  +  { "MALLOC_SIZE",            MSV_GSTAT,   SQLITE_STATUS_MALLOC_SIZE          },
          142  +  { "MALLOC_COUNT",           MSV_GSTAT,   SQLITE_STATUS_MALLOC_COUNT         },
          143  +  { "PAGECACHE_USED",         MSV_GSTAT,   SQLITE_STATUS_PAGECACHE_USED       },
          144  +  { "PAGECACHE_OVERFLOW",     MSV_GSTAT,   SQLITE_STATUS_PAGECACHE_OVERFLOW   },
          145  +  { "PAGECACHE_SIZE",         MSV_GSTAT,   SQLITE_STATUS_PAGECACHE_SIZE       },
          146  +  { "PARSER_STACK",           MSV_GSTAT,   SQLITE_STATUS_PARSER_STACK         },
          147  +  { "DB_LOOKASIDE_USED",      MSV_DBSTAT, SQLITE_DBSTATUS_LOOKASIDE_USED      },
          148  +  { "DB_CACHE_USED",          MSV_DBSTAT, SQLITE_DBSTATUS_CACHE_USED          },
          149  +  { "DB_SCHEMA_USED",         MSV_DBSTAT, SQLITE_DBSTATUS_SCHEMA_USED         },
          150  +  { "DB_STMT_USED",           MSV_DBSTAT, SQLITE_DBSTATUS_STMT_USED           },
          151  +  { "DB_LOOKASIDE_HIT",       MSV_DBSTAT, SQLITE_DBSTATUS_LOOKASIDE_HIT       },
          152  +  { "DB_LOOKASIDE_MISS_SIZE", MSV_DBSTAT, SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE },
          153  +  { "DB_LOOKASIDE_MISS_FULL", MSV_DBSTAT, SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL },
          154  +  { "DB_CACHE_HIT",           MSV_DBSTAT, SQLITE_DBSTATUS_CACHE_HIT           },
          155  +  { "DB_CACHE_MISS",          MSV_DBSTAT, SQLITE_DBSTATUS_CACHE_MISS          },
          156  +  { "DB_CACHE_WRITE",         MSV_DBSTAT, SQLITE_DBSTATUS_CACHE_WRITE         },
          157  +  { "DB_DEFERRED_FKS",        MSV_DBSTAT, SQLITE_DBSTATUS_DEFERRED_FKS        },
          158  +  { "DB_CACHE_USED_SHARED",   MSV_DBSTAT, SQLITE_DBSTATUS_CACHE_USED_SHARED   },
          159  +  { "DB_CACHE_SPILL",         MSV_DBSTAT, SQLITE_DBSTATUS_CACHE_SPILL         },
          160  +#ifdef SQLITE_ENABLE_ZIPVFS
          161  +  { "ZIPVFS_CACHE_USED",      MSV_ZIPVFS, 231454 },
          162  +  { "ZIPVFS_CACHE_HIT",       MSV_ZIPVFS, 231455 },
          163  +  { "ZIPVFS_CACHE_MISS",      MSV_ZIPVFS, 231456 },
          164  +  { "ZIPVFS_CACHE_WRITE",     MSV_ZIPVFS, 231457 },
          165  +  { "ZIPVFS_DIRECT_READ",     MSV_ZIPVFS, 231458 },
          166  +  { "ZIPVFS_DIRECT_BYTES",    MSV_ZIPVFS, 231459 },
          167  +#endif /* SQLITE_ENABLE_ZIPVFS */
   159    168   };
   160    169   #define MSV_NROW (sizeof(aMemstatColumn)/sizeof(aMemstatColumn[0]))
   161    170   
   162    171   /*
   163    172   ** Advance a memstat_cursor to its next row of output.
   164    173   */
   165    174   static int memstatNext(sqlite3_vtab_cursor *cur){
................................................................................
   196    205       case MSV_DBSTAT: {
   197    206         int xCur, xHiwtr;
   198    207         sqlite3_db_status(pCur->db, aMemstatColumn[i].eOp, &xCur, &xHiwtr, 0);
   199    208         iCur = xCur;
   200    209         iHiwtr = xHiwtr;
   201    210         break;
   202    211       }
          212  +    case MSV_ZIPVFS: {
          213  +      sqlite3_file_control(pCur->db, 0, aMemstatColumn[i].eOp, (void*)&iCur);
          214  +      break;
          215  +    }
   203    216     }
   204    217     if( iCol==MSV_COLUMN_HIWTR ) iCur = iHiwtr;
   205    218     sqlite3_result_int64(ctx, iCur);
   206    219     return SQLITE_OK;
   207    220   }
   208    221   
   209    222   /*
................................................................................
   218    231   
   219    232   /*
   220    233   ** Return TRUE if the cursor has been moved off of the last
   221    234   ** row of output.
   222    235   */
   223    236   static int memstatEof(sqlite3_vtab_cursor *cur){
   224    237     memstat_cursor *pCur = (memstat_cursor*)cur;
   225         -  return pCur->iRowid>=MSV_NROW;
          238  +  return pCur->iRowid>MSV_NROW;
   226    239   }
   227    240   
   228    241   /*
   229    242   ** This method is called to "rewind" the memstat_cursor object back
   230    243   ** to the first row of output.  This method is always called at least
   231    244   ** once prior to any call to memstatColumn() or memstatRowid() or 
   232    245   ** memstatEof().