]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Rename the ext/misc/analyze.c extension to ext/misc/diskused.c, to avoid
authordrh <>
Fri, 29 May 2026 14:57:38 +0000 (14:57 +0000)
committerdrh <>
Fri, 29 May 2026 14:57:38 +0000 (14:57 +0000)
confusion with the src/analyze.c file.  The function is now called
"diskused(X)" instead of "analyze(X)".  The CLI command is renamed
from ".dbstat" to ".diskused".

FossilOrigin-Name: c7839f7a1749b38f8a36c06d93a7b59095e91ce753e8dd020de273ca8f73a239

Makefile.msc
ext/misc/diskused.c [moved from ext/misc/analyze.c with 75% similarity]
main.mk
manifest
manifest.uuid
src/shell.c.in
test/fuzzcheck.c
test/shell7.test

index 23fb546649376320c1c145c1d5b726d8c4034d64..dd4f86d593f4903eb86fe795aee16e97a9fb421a 100644 (file)
@@ -1766,11 +1766,11 @@ FUZZCHECK_SRC = $(FUZZCHECK_SRC) $(TOP)\test\fuzzinvariants.c
 FUZZCHECK_SRC = $(FUZZCHECK_SRC) $(TOP)\test\vt02.c
 FUZZCHECK_SRC = $(FUZZCHECK_SRC) $(TOP)\ext\recover\dbdata.c
 FUZZCHECK_SRC = $(FUZZCHECK_SRC) $(TOP)\ext\recover\sqlite3recover.c
-FUZZCHECK_SRC = $(FUZZCHECK_SRC) $(TOP)\ext\misc\analyze.c
 FUZZCHECK_SRC = $(FUZZCHECK_SRC) $(TOP)\ext\misc\base64.c
 FUZZCHECK_SRC = $(FUZZCHECK_SRC) $(TOP)\ext\misc\base85.c
 FUZZCHECK_SRC = $(FUZZCHECK_SRC) $(TOP)\ext\misc\completion.c
 FUZZCHECK_SRC = $(FUZZCHECK_SRC) $(TOP)\ext\misc\decimal.c
+FUZZCHECK_SRC = $(FUZZCHECK_SRC) $(TOP)\ext\misc\diskused.c
 FUZZCHECK_SRC = $(FUZZCHECK_SRC) $(TOP)\ext\misc\ieee754.c
 FUZZCHECK_SRC = $(FUZZCHECK_SRC) $(TOP)\ext\misc\randomjson.c
 FUZZCHECK_SRC = $(FUZZCHECK_SRC) $(TOP)\ext\misc\regexp.c
@@ -2343,12 +2343,12 @@ SHELL_DEP = \
     $(TOP)\ext\expert\sqlite3expert.h \
     $(TOP)\ext\intck\sqlite3intck.c \
     $(TOP)\ext\intck\sqlite3intck.h \
-    $(TOP)\ext\misc\analyze.c \
     $(TOP)\ext\misc\appendvfs.c \
     $(TOP)\ext\misc\base64.c \
     $(TOP)\ext\misc\base85.c \
     $(TOP)\ext\misc\completion.c \
     $(TOP)\ext\misc\decimal.c \
+    $(TOP)\ext\misc\diskused.c \
     $(TOP)\ext\misc\fileio.c \
     $(TOP)\ext\misc\ieee754.c \
     $(TOP)\ext\misc\memtrace.c \
similarity index 75%
rename from ext/misc/analyze.c
rename to ext/misc/diskused.c
index 43bd21c09d6ae5e7aec2de8bb47a5e983a045cd0..1dec199169819d64263b5ac7f6828b0820ae56cb 100644 (file)
 **
 ******************************************************************************
 **
-** Partial reimplement of the sqlite3_analyzer utility program as
-** loadable SQL function.
+** This extension implements an SQL function:
+**
+**     diskused(X)
+**
+** Where X is the schema name (typically 'main').  The output is text
+** that describes how much filesystem space the various tables and indexes
+** of the database consume.
+**
+** This function is a replacement for the (now deprecated)
+** "sqlite3_analyzer" utility program.  This function is built
+** into the CLI and is used to implement the ".diskused" command there.
 */
 #include "sqlite3ext.h"
 SQLITE_EXTENSION_INIT1
@@ -23,8 +32,8 @@ SQLITE_EXTENSION_INIT1
 /*
 ** State information for the analysis
 */
-typedef struct Analysis Analysis;
-struct Analysis {
+typedef struct DiskUsed DiskUsed;
+struct DiskUsed {
   sqlite3 *db;               /* Database connection */
   sqlite3_context *context;  /* SQL function context */
   sqlite3_str *pOut;         /* Write output here */
@@ -33,14 +42,14 @@ struct Analysis {
 };
 
 /*
-** Free all resources that the Analysis object references and
-** reset the Analysis object.
+** Free all resources that the DiskUsed object references and
+** reset the DiskUsed object.
 **
-** Call this routine multiple times on the same Analysis object
+** Call this routine multiple times on the same DiskUsed object
 ** is a harmless no-op, as long as the memory for the object itself
 ** has not been freed.
 */
-static void analysisReset(Analysis *p){
+static void diskusedReset(DiskUsed *p){
   if( p->zSU ){
     char *zSql = sqlite3_mprintf("DROP TABLE temp.%s;", p->zSU);
     if( zSql ){
@@ -57,7 +66,7 @@ static void analysisReset(Analysis *p){
 ** Report an error using formatted text.  If zFormat==NULL then report
 ** an OOM error.
 */
-static void analysisError(Analysis *p, const char *zFormat, ...){
+static void diskusedError(DiskUsed *p, const char *zFormat, ...){
   char *zErr;
   if( zFormat ){
     va_list ap;
@@ -73,34 +82,34 @@ static void analysisError(Analysis *p, const char *zFormat, ...){
     sqlite3_result_error(p->context, zErr, -1);
     sqlite3_free(zErr);
   }
-  analysisReset(p);
+  diskusedReset(p);
 }
 
 /*
 ** Prepare and return an SQL statement.
 */
-static sqlite3_stmt *analysisVPrep(Analysis *p, const char *zFmt, va_list ap){
+static sqlite3_stmt *diskusedVPrep(DiskUsed *p, const char *zFmt, va_list ap){
   char *zSql;
   int rc;
   sqlite3_stmt *pStmt = 0;
   zSql = sqlite3_vmprintf(zFmt, ap);
-  if( zSql==0 ){ analysisError(p,0); return 0; }
+  if( zSql==0 ){ diskusedError(p,0); return 0; }
   rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
   if( rc ){
-    analysisError(p, "SQL parse error: %s\nOriginal SQL: %s",
+    diskusedError(p, "SQL parse error: %s\nOriginal SQL: %s",
                                  sqlite3_errmsg(p->db), zSql);
     sqlite3_finalize(pStmt);
-    analysisReset(p);
+    diskusedReset(p);
     pStmt = 0;
   }
   sqlite3_free(zSql);
   return pStmt;
 }
-static sqlite3_stmt *analysisPrepare(Analysis *p, const char *zFormat, ...){
+static sqlite3_stmt *diskusedPrepare(DiskUsed *p, const char *zFormat, ...){
   va_list ap;
   sqlite3_stmt *pStmt = 0;
   va_start(ap, zFormat);
-  pStmt = analysisVPrep(p,zFormat,ap);
+  pStmt = diskusedVPrep(p,zFormat,ap);
   va_end(ap);
   return pStmt;
 }
@@ -113,14 +122,14 @@ static sqlite3_stmt *analysisPrepare(Analysis *p, const char *zFormat, ...){
 **
 ** The prepared statement is closed in either case.
 */
-static int analysisStmtFinish(Analysis *p, int rc, sqlite3_stmt *pStmt){
+static int diskusedStmtFinish(DiskUsed *p, int rc, sqlite3_stmt *pStmt){
   if( rc==SQLITE_DONE ){
     rc = SQLITE_OK;
   }
   if( rc!=SQLITE_OK || (rc = sqlite3_reset(pStmt))!=SQLITE_OK ){
-    analysisError(p, "SQL run-time error: %s\nOriginal SQL: %s",
+    diskusedError(p, "SQL run-time error: %s\nOriginal SQL: %s",
                   sqlite3_errmsg(p->db), sqlite3_sql(pStmt));
-    analysisReset(p);
+    diskusedReset(p);
   }
   sqlite3_finalize(pStmt);
   return rc;
@@ -129,21 +138,21 @@ static int analysisStmtFinish(Analysis *p, int rc, sqlite3_stmt *pStmt){
 /*
 ** Run SQL.  Return the number of errors. 
 */
-static int analysisSql(Analysis *p, const char *zFormat, ...){
+static int diskusedSql(DiskUsed *p, const char *zFormat, ...){
   va_list ap;
   int rc;
   sqlite3_stmt *pStmt = 0;
   va_start(ap, zFormat);
-  pStmt = analysisVPrep(p,zFormat,ap);
+  pStmt = diskusedVPrep(p,zFormat,ap);
   va_end(ap);
   if( pStmt==0 ) return 1;
   while( (rc = sqlite3_step(pStmt))==SQLITE_ROW ){}
   if( rc==SQLITE_DONE ){
     rc = SQLITE_OK;
   }else{
-    analysisError(p, "SQL run-time error: %s\nOriginal SQL: %s",
+    diskusedError(p, "SQL run-time error: %s\nOriginal SQL: %s",
                   sqlite3_errmsg(p->db), sqlite3_sql(pStmt));
-    analysisReset(p);
+    diskusedReset(p);
   }
   sqlite3_finalize(pStmt);
   return rc;
@@ -153,8 +162,8 @@ static int analysisSql(Analysis *p, const char *zFormat, ...){
 ** Run an SQL query that returns an integer.  Write that integer
 ** into *piRes.  Return the number of errors. 
 */
-static int analysisSqlInt(
-  Analysis *p,
+static int diskusedSqlInt(
+  DiskUsed *p,
   sqlite3_int64 *piRes,
   const char *zFormat, ...
 ){
@@ -162,7 +171,7 @@ static int analysisSqlInt(
   int rc;
   sqlite3_stmt *pStmt = 0;
   va_start(ap, zFormat);
-  pStmt = analysisVPrep(p,zFormat,ap);
+  pStmt = diskusedVPrep(p,zFormat,ap);
   va_end(ap);
   if( pStmt==0 ) return 1;
   rc = sqlite3_step(pStmt);
@@ -174,10 +183,10 @@ static int analysisSqlInt(
   }else{
     if( p->db ){
       /* p->db is NULL if there was some prior error */
-      analysisError(p, "SQL run-time error: %s\nOriginal SQL: %s",
+      diskusedError(p, "SQL run-time error: %s\nOriginal SQL: %s",
                     sqlite3_errmsg(p->db), sqlite3_sql(pStmt));
     }
-    analysisReset(p);
+    diskusedReset(p);
   }
   sqlite3_finalize(pStmt);
   return rc;
@@ -190,7 +199,7 @@ static int analysisSqlInt(
 ** comment.  Otherwise begin with a new-line.  Always finish with a
 ** newline.
 */
-static void analysisTitle(Analysis *p, const char *zFormat, ...){
+static void diskusedTitle(DiskUsed *p, const char *zFormat, ...){
   char *zFirst;
   char *zTitle;
   size_t nTitle;
@@ -199,7 +208,7 @@ static void analysisTitle(Analysis *p, const char *zFormat, ...){
   zTitle = sqlite3_vmprintf(zFormat, ap);
   va_end(ap);
   if( zTitle==0 ){
-    analysisError(p, 0);
+    diskusedError(p, 0);
     return;
   }
   zFirst = sqlite3_str_length(p->pOut)==0 ? "/" : "\n*";
@@ -218,8 +227,8 @@ static void analysisTitle(Analysis *p, const char *zFormat, ...){
 ** 50 columns with "." characters, and followed by whatever text is
 ** described by zFormat.
 */
-static void analysisLine(
-  Analysis *p,             /* Analysis context */
+static void diskusedLine(
+  DiskUsed *p,             /* DiskUsed context */
   const char *zDesc,       /* Description */
   const char *zFormat,     /* Argument to the description */
   ...
@@ -231,7 +240,7 @@ static void analysisLine(
   zTxt = sqlite3_vmprintf(zFormat, ap);
   va_end(ap);
   if( zTxt==0 ){
-    analysisError(p, 0);
+    diskusedError(p, 0);
     return;
   }
   nDesc = strlen(zDesc);
@@ -248,7 +257,7 @@ static void analysisLine(
 ** two or three significant digits, with the decimal point being the fourth
 ** character.  
 */
-static void analysisPercent(Analysis *p, double r){
+static void diskusedPercent(DiskUsed *p, double r){
   char zNum[100];
   char *zDP;
   int nLeadingDigit;
@@ -277,8 +286,8 @@ static void analysisPercent(Analysis *p, double r){
 ** a boolean expression that can go in the WHERE clause to select
 ** the relevant rows of the s.zSU table.
 */
-static int analysisSubreport(
-  Analysis *p,                  /* Analysis context */
+static int diskusedSubreport(
+  DiskUsed *p,                  /* DiskUsed context */
   char *zTitle,                 /* Title for this subreport */
   char *zWhere,                 /* WHERE clause for this subreport */
   sqlite3_int64 pgsz,           /* Database page size */
@@ -306,10 +315,10 @@ static int analysisSubreport(
   int rc;
 
   if( zTitle==0 || zWhere==0 ){
-    analysisError(p, 0);
+    diskusedError(p, 0);
     return SQLITE_NOMEM;
   }
-  pStmt = analysisPrepare(p,
+  pStmt = diskusedPrepare(p,
     "SELECT\n"
     "  sum(if(is_without_rowid OR is_index,nentry,leaf_entries)),\n" /* 0 */
     "  sum(payload),\n"            /* 1 */
@@ -330,7 +339,7 @@ static int analysisSubreport(
   if( pStmt==0 ) return 1;
   rc = sqlite3_step(pStmt);
   if( rc==SQLITE_ROW ){
-    analysisTitle(p, "%s", zTitle);
+    diskusedTitle(p, "%s", zTitle);
 
     nentry = sqlite3_column_int64(pStmt, 0);
     payload = sqlite3_column_int64(pStmt, 1);
@@ -349,69 +358,69 @@ static int analysisSubreport(
     rc = SQLITE_DONE;
 
     total_pages = leaf_pages + int_pages + ovfl_pages;
-    analysisLine(p, "Percentage of total database", "%.3g%%\n",
+    diskusedLine(p, "Percentage of total database", "%.3g%%\n",
                  (total_pages*100.0)/(double)nPage);
-    analysisLine(p, "Number of entries", "%lld\n", nentry);
+    diskusedLine(p, "Number of entries", "%lld\n", nentry);
     storage = total_pages*pgsz;
-    analysisLine(p, "Bytes of storage consumed", "%lld\n", storage);
-    analysisLine(p, "Bytes of payload", "%-11lld ", payload);
-    analysisPercent(p, payload*100.0/(double)storage);
+    diskusedLine(p, "Bytes of storage consumed", "%lld\n", storage);
+    diskusedLine(p, "Bytes of payload", "%-11lld ", payload);
+    diskusedPercent(p, payload*100.0/(double)storage);
     if( ovfl_cnt>0 ){
-      analysisLine(p, "Bytes of payload in overflow","%-11lld ",ovfl_payload);
-      analysisPercent(p, ovfl_payload*100.0/(double)payload);
+      diskusedLine(p, "Bytes of payload in overflow","%-11lld ",ovfl_payload);
+      diskusedPercent(p, ovfl_payload*100.0/(double)payload);
     }
     total_unused = leaf_unused + int_unused + ovfl_unused;
     total_meta = storage - payload - total_unused;
-    analysisLine(p, "Bytes of metadata","%-11lld ", total_meta);
-    analysisPercent(p, total_meta*100.0/(double)storage);
+    diskusedLine(p, "Bytes of metadata","%-11lld ", total_meta);
+    diskusedPercent(p, total_meta*100.0/(double)storage);
     if( cnt==1 ){
-      analysisLine(p, "B-tree depth", "%lld\n", depth);
+      diskusedLine(p, "B-tree depth", "%lld\n", depth);
       if( int_cell>1 ){
-        analysisLine(p, "Average fanout", "%.1f\n",
+        diskusedLine(p, "Average fanout", "%.1f\n",
                      (double)(int_cell+int_pages)/(double)int_pages);
       }
     }
     if( nentry>0 ){
-      analysisLine(p, "Average payload per entry", "%.1f\n",
+      diskusedLine(p, "Average payload per entry", "%.1f\n",
                    (double)payload/(double)nentry);
-      analysisLine(p, "Average unused bytes per entry", "%.1f\n",
+      diskusedLine(p, "Average unused bytes per entry", "%.1f\n",
                    (double)total_unused/(double)nentry);
-      analysisLine(p, "Average metadata per entry", "%.1f\n",
+      diskusedLine(p, "Average metadata per entry", "%.1f\n",
                    (double)total_meta/(double)nentry);
     }
-    analysisLine(p, "Maximum single-entry payload", "%lld\n", mx_payload);
+    diskusedLine(p, "Maximum single-entry payload", "%lld\n", mx_payload);
     if( nentry>0 ){
-      analysisLine(p, "Entries that use overflow", "%-11lld ", ovfl_cnt);
-      analysisPercent(p, ovfl_cnt*100.0/(double)nentry);
+      diskusedLine(p, "Entries that use overflow", "%-11lld ", ovfl_cnt);
+      diskusedPercent(p, ovfl_cnt*100.0/(double)nentry);
     }
     if( int_pages>0 ){
-      analysisLine(p, "Index pages used", "%lld\n", int_pages);
+      diskusedLine(p, "Index pages used", "%lld\n", int_pages);
     }
-    analysisLine(p, "Primary pages used", "%lld\n", leaf_pages);
+    diskusedLine(p, "Primary pages used", "%lld\n", leaf_pages);
     if( ovfl_cnt ){
-      analysisLine(p, "Overflow pages used", "%lld\n", ovfl_pages);
+      diskusedLine(p, "Overflow pages used", "%lld\n", ovfl_pages);
     }
-    analysisLine(p, "Total pages used", "%lld\n", total_pages);
+    diskusedLine(p, "Total pages used", "%lld\n", total_pages);
     if( int_pages>0 ){
-      analysisLine(p, "Unused bytes on index pages", "%lld\n", int_unused);
+      diskusedLine(p, "Unused bytes on index pages", "%lld\n", int_unused);
     }
-    analysisLine(p, "Unused bytes on primary pages", "%lld\n", leaf_unused);
+    diskusedLine(p, "Unused bytes on primary pages", "%lld\n", leaf_unused);
     if( ovfl_cnt ){
-      analysisLine(p, "Unused bytes on overflow pages", "%lld\n", ovfl_unused);
+      diskusedLine(p, "Unused bytes on overflow pages", "%lld\n", ovfl_unused);
     }
-    analysisLine(p, "Unused bytes on all pages", "%-11lld ", total_unused);
-    analysisPercent(p, total_unused*100.0/(double)storage);
+    diskusedLine(p, "Unused bytes on all pages", "%-11lld ", total_unused);
+    diskusedPercent(p, total_unused*100.0/(double)storage);
   }
-  return analysisStmtFinish(p, rc, pStmt);
+  return diskusedStmtFinish(p, rc, pStmt);
 }
 
 /*
-** SQL Function:   analyze(SCHEMA)
+** SQL Function:   diskused(SCHEMA)
 **
 ** Analyze the database schema named in the argument.  Return text
-** containing the analysis.
+** containing the space utilization stats.
 */
-static void analyzeFunc(
+static void diskusedFunc(
   sqlite3_context *context,
   int argc,
   sqlite3_value **argv
@@ -426,7 +435,7 @@ static void analyzeFunc(
   sqlite3_int64 nFreeList;
   sqlite3_int64 nIndex;
   sqlite3_int64 nWORowid;
-  Analysis s;
+  DiskUsed s;
   sqlite3_uint64 r[2];
 
   (void)argc;
@@ -435,34 +444,34 @@ static void analyzeFunc(
   s.context = context;
   s.pOut = sqlite3_str_new(0);
   if( sqlite3_str_errcode(s.pOut) ){
-    analysisError(&s, 0);
+    diskusedError(&s, 0);
     return;
   }
   s.zSchema = (const char*)sqlite3_value_text(argv[0]);
   if( s.zSchema==0 ){
     s.zSchema = "main";
   }else if( sqlite3_strlike("temp",s.zSchema,0)==0 ){
-    analysisReset(&s);
+    diskusedReset(&s);
     sqlite3_result_text(context, "cannot analyze \"temp\"",-1,SQLITE_STATIC);
     return;
   }
   ii = 0;
-  rc = analysisSqlInt(&s,&ii,"SELECT 1 FROM pragma_database_list"
+  rc = diskusedSqlInt(&s,&ii,"SELECT 1 FROM pragma_database_list"
                              " WHERE name=%Q COLLATE nocase",s.zSchema);
   if( rc || ii==0 ){
-    analysisReset(&s);
+    diskusedReset(&s);
     sqlite3_result_text(context,"no such database",-1,SQLITE_STATIC);
     return;
   }
   sqlite3_randomness(sizeof(r), &r);
-  s.zSU = sqlite3_mprintf("analysis%016llx%016llx", r[0], r[1]);
-  if( s.zSU==0 ){ analysisError(&s, 0); return; }
+  s.zSU = sqlite3_mprintf("diskused%016llx%016llx", r[0], r[1]);
+  if( s.zSU==0 ){ diskusedError(&s, 0); return; }
 
   /* The s.zSU table contains the data used for the analysis.
   ** The table name contains 128-bits of randomness to avoid
   ** collisions with preexisting tables in temp.
   */
-  rc = analysisSql(&s,
+  rc = diskusedSql(&s,
     "CREATE TABLE temp.%s(\n"
     "   name text,                -- A table or index\n"
     "   tblname text,             -- Table that owns name\n"
@@ -489,7 +498,7 @@ static void analyzeFunc(
 
   /* Populate the s.zSU table
   */
-  rc = analysisSql(&s,
+  rc = diskusedSql(&s,
     "WITH\n"
     "  allidx(idxname) AS (\n"
     "    SELECT name FROM \"%w\".sqlite_schema WHERE type='index'\n"
@@ -541,38 +550,38 @@ static void analyzeFunc(
   if( rc ) return;
 
   nPage = 0;
-  rc = analysisSqlInt(&s, &nPage, "PRAGMA \"%w\".page_count", s.zSchema);
+  rc = diskusedSqlInt(&s, &nPage, "PRAGMA \"%w\".page_count", s.zSchema);
   if( rc ) return;
   if( nPage<=0 ){
     /* Very brief reply for an empty database */
-    analysisReset(&s);
+    diskusedReset(&s);
     sqlite3_result_text(context, "empty database", -1, SQLITE_STATIC);
     return;
   }
 
   /* Begin generating the report */
-  analysisTitle(&s, "Database storage utilization report");
+  diskusedTitle(&s, "Database storage utilization report");
   pgsz = 0;
-  rc = analysisSqlInt(&s, &pgsz, "PRAGMA \"%w\".page_size", s.zSchema);
+  rc = diskusedSqlInt(&s, &pgsz, "PRAGMA \"%w\".page_size", s.zSchema);
   if( rc ) return;
-  analysisLine(&s, "Page size in bytes","%lld\n",pgsz);
-  analysisLine(&s, "Pages in the database", "%lld\n", nPage);
+  diskusedLine(&s, "Page size in bytes","%lld\n",pgsz);
+  diskusedLine(&s, "Pages in the database", "%lld\n", nPage);
 
   nPageInUse = 0;
-  rc = analysisSqlInt(&s, &nPageInUse, 
+  rc = diskusedSqlInt(&s, &nPageInUse, 
        "SELECT sum(leaf_pages+int_pages+ovfl_pages) FROM temp.%s", s.zSU);
   if( rc ) return;
-  analysisLine(&s, "Pages that store data", "%-11lld ", nPageInUse);
-  analysisPercent(&s, (nPageInUse*100.0)/(double)nPage);
+  diskusedLine(&s, "Pages that store data", "%-11lld ", nPageInUse);
+  diskusedPercent(&s, (nPageInUse*100.0)/(double)nPage);
 
   nFreeList = 0;
-  rc = analysisSqlInt(&s, &nFreeList, "PRAGMA \"%w\".freelist_count",s.zSchema);
+  rc = diskusedSqlInt(&s, &nFreeList, "PRAGMA \"%w\".freelist_count",s.zSchema);
   if( rc ) return;
-  analysisLine(&s, "Pages on the freelist", "%-11lld ", nFreeList);
-  analysisPercent(&s, (nFreeList*100.0)/(double)nPage);
+  diskusedLine(&s, "Pages on the freelist", "%-11lld ", nFreeList);
+  diskusedPercent(&s, (nFreeList*100.0)/(double)nPage);
 
   ii = 0;
-  rc = analysisSqlInt(&s, &ii, "PRAGMA \"%w\".auto_vacuum", s.zSchema);
+  rc = diskusedSqlInt(&s, &ii, "PRAGMA \"%w\".auto_vacuum", s.zSchema);
   if( rc ) return;
   if( ii==0 || nPage<=1 ){
     ii = 0;
@@ -581,50 +590,50 @@ static void analyzeFunc(
     double rAvPage = (nPage-1.0)/(rPtrsPerPage+1.0);
     ii = (sqlite3_int64)ceil(rAvPage);
   }
-  analysisLine(&s, "Pages of auto-vacuum overhead", "%-11lld ", ii);
-  analysisPercent(&s, (ii*100.0)/(double)nPage);
+  diskusedLine(&s, "Pages of auto-vacuum overhead", "%-11lld ", ii);
+  diskusedPercent(&s, (ii*100.0)/(double)nPage);
 
   ii = 0;
-  rc = analysisSqlInt(&s, &ii, 
+  rc = diskusedSqlInt(&s, &ii, 
        "SELECT count(*)+1 FROM \"%w\".sqlite_schema WHERE type='table'",
        s.zSchema);
   if( rc ) return;
-  analysisLine(&s, "Number of tables", "%lld\n", ii);
+  diskusedLine(&s, "Number of tables", "%lld\n", ii);
   nWORowid = 0;
-  rc = analysisSqlInt(&s, &nWORowid,
+  rc = diskusedSqlInt(&s, &nWORowid,
        "SELECT count(*) FROM \"%w\".pragma_table_list WHERE wr",
        s.zSchema);
   if( rc ) return;
   if( nWORowid>0 ){
-    analysisLine(&s, "Number of WITHOUT ROWID tables", "%lld\n", nWORowid);
-    analysisLine(&s, "Number of rowid tables", "%lld\n", ii - nWORowid);
+    diskusedLine(&s, "Number of WITHOUT ROWID tables", "%lld\n", nWORowid);
+    diskusedLine(&s, "Number of rowid tables", "%lld\n", ii - nWORowid);
   }
   nIndex = 0;
-  rc = analysisSqlInt(&s, &nIndex, 
+  rc = diskusedSqlInt(&s, &nIndex, 
        "SELECT count(*) FROM \"%w\".sqlite_schema WHERE type='index'",
        s.zSchema);
   if( rc ) return;
-  analysisLine(&s, "Number of indexes", "%lld\n", nIndex);
+  diskusedLine(&s, "Number of indexes", "%lld\n", nIndex);
   ii = 0;
-  rc = analysisSqlInt(&s, &ii, 
+  rc = diskusedSqlInt(&s, &ii, 
        "SELECT count(*) FROM \"%w\".sqlite_schema"
        " WHERE name GLOB 'sqlite_autoindex_*' AND type='index'",
        s.zSchema);
   if( rc ) return;
-  analysisLine(&s, "Number of defined indexes", "%lld\n", nIndex - ii);
-  analysisLine(&s, "Number of implied indexes", "%lld\n", ii);
-  analysisLine(&s, "Size of the database in bytes", "%lld\n", pgsz*nPage);
+  diskusedLine(&s, "Number of defined indexes", "%lld\n", nIndex - ii);
+  diskusedLine(&s, "Number of implied indexes", "%lld\n", ii);
+  diskusedLine(&s, "Size of the database in bytes", "%lld\n", pgsz*nPage);
   ii = 0;
-  rc = analysisSqlInt(&s, &ii, 
+  rc = diskusedSqlInt(&s, &ii, 
        "SELECT sum(payload) FROM temp.%s"
        " WHERE NOT is_index AND name NOT LIKE 'sqlite_schema'",
        s.zSU);
   if( rc ) return;
-  analysisLine(&s, "Bytes of payload", "%-11lld ", ii);
-  analysisPercent(&s, ii*100.0/(double)(pgsz*nPage));
+  diskusedLine(&s, "Bytes of payload", "%-11lld ", ii);
+  diskusedPercent(&s, ii*100.0/(double)(pgsz*nPage));
 
-  analysisTitle(&s, "Page counts for all tables with their indexes");
-  pStmt = analysisPrepare(&s,
+  diskusedTitle(&s, "Page counts for all tables with their indexes");
+  pStmt = diskusedPrepare(&s,
     "SELECT upper(tblname),\n"
     "       sum(int_pages+leaf_pages+ovfl_pages)\n"
     "  FROM temp.%s\n"
@@ -634,13 +643,13 @@ static void analyzeFunc(
   if( pStmt==0 ) return;
   while( (rc = sqlite3_step(pStmt))==SQLITE_ROW ){
     sqlite3_int64 nn = sqlite3_column_int64(pStmt,1);
-    analysisLine(&s, (const char*)sqlite3_column_text(pStmt,0), "%-11lld ", nn);
-    analysisPercent(&s, (nn*100.0)/(double)nPage);
+    diskusedLine(&s, (const char*)sqlite3_column_text(pStmt,0), "%-11lld ", nn);
+    diskusedPercent(&s, (nn*100.0)/(double)nPage);
   }
-  if( analysisStmtFinish(&s, rc, pStmt) ) return;
+  if( diskusedStmtFinish(&s, rc, pStmt) ) return;
 
-  analysisTitle(&s, "Page counts for all tables and indexes separately");
-  pStmt = analysisPrepare(&s,
+  diskusedTitle(&s, "Page counts for all tables and indexes separately");
+  pStmt = diskusedPrepare(&s,
     "SELECT upper(name),\n"
     "       sum(int_pages+leaf_pages+ovfl_pages)\n"
     "  FROM temp.%s\n"
@@ -650,28 +659,28 @@ static void analyzeFunc(
   if( pStmt==0 ) return;
   while( (rc = sqlite3_step(pStmt))==SQLITE_ROW ){
     sqlite3_int64 nn = sqlite3_column_int64(pStmt,1);
-    analysisLine(&s, (const char*)sqlite3_column_text(pStmt,0), "%-11lld ", nn);
-    analysisPercent(&s, (nn*100.0)/(double)nPage);
+    diskusedLine(&s, (const char*)sqlite3_column_text(pStmt,0), "%-11lld ", nn);
+    diskusedPercent(&s, (nn*100.0)/(double)nPage);
   }
-  if( analysisStmtFinish(&s, rc, pStmt) ) return;
+  if( diskusedStmtFinish(&s, rc, pStmt) ) return;
 
-  rc = analysisSubreport(&s, "All tables and indexes", "1", pgsz, nPage);
+  rc = diskusedSubreport(&s, "All tables and indexes", "1", pgsz, nPage);
   if( rc ) return;
-  rc = analysisSubreport(&s, "All tables", "NOT is_index", pgsz, nPage);
+  rc = diskusedSubreport(&s, "All tables", "NOT is_index", pgsz, nPage);
   if( rc ) return;
   if( nWORowid>0 ){
-    rc = analysisSubreport(&s, "All WITHOUT ROWID tables", "is_without_rowid",
+    rc = diskusedSubreport(&s, "All WITHOUT ROWID tables", "is_without_rowid",
                            pgsz, nPage);
     if( rc ) return;
-    rc = analysisSubreport(&s, "All rowid tables",
+    rc = diskusedSubreport(&s, "All rowid tables",
                            "NOT is_without_rowid AND NOT is_index",
                            pgsz, nPage);
     if( rc ) return;
   }
-  rc = analysisSubreport(&s, "All indexes", "is_index", pgsz, nPage);
+  rc = diskusedSubreport(&s, "All indexes", "is_index", pgsz, nPage);
   if( rc ) return;
 
-  pStmt = analysisPrepare(&s,
+  pStmt = diskusedPrepare(&s,
     "SELECT upper(tblname), tblname, sum(is_index) FROM temp.%s"
     " GROUP BY 1 ORDER BY 1",
     s.zSU);
@@ -683,7 +692,7 @@ static void analyzeFunc(
     if( nSubIndex==0 ){
       char *zTitle = sqlite3_mprintf("Table %s", zUpper);
       char *zWhere = sqlite3_mprintf("name=%Q", zName);
-      rc = analysisSubreport(&s, zTitle, zWhere, pgsz, nPage);
+      rc = diskusedSubreport(&s, zTitle, zWhere, pgsz, nPage);
       sqlite3_free(zTitle);
       sqlite3_free(zWhere);
       if( rc ) break;
@@ -691,25 +700,25 @@ static void analyzeFunc(
       sqlite3_stmt *pS2;
       char *zTitle = sqlite3_mprintf("Table %s and all its indexes", zUpper);
       char *zWhere = sqlite3_mprintf("tblname=%Q", zName);
-      rc = analysisSubreport(&s, zTitle, zWhere, pgsz, nPage);
+      rc = diskusedSubreport(&s, zTitle, zWhere, pgsz, nPage);
       sqlite3_free(zTitle);
       sqlite3_free(zWhere);
       if( rc ) break;
       zTitle = sqlite3_mprintf("Table %s w/o any indexes", zUpper);
       zWhere = sqlite3_mprintf("name=%Q", zName);
-      rc = analysisSubreport(&s, zTitle, zWhere, pgsz, nPage);
+      rc = diskusedSubreport(&s, zTitle, zWhere, pgsz, nPage);
       sqlite3_free(zTitle);
       sqlite3_free(zWhere);
       if( rc ) break;
       if( nSubIndex>1 ){
         zTitle = sqlite3_mprintf("All indexes of table %s", zUpper);
         zWhere = sqlite3_mprintf("tblname=%Q AND is_index", zName);
-        rc = analysisSubreport(&s, zTitle, zWhere, pgsz, nPage);
+        rc = diskusedSubreport(&s, zTitle, zWhere, pgsz, nPage);
         sqlite3_free(zTitle);
         sqlite3_free(zWhere);
         if( rc ) break;
       }
-      pS2 = analysisPrepare(&s,
+      pS2 = diskusedPrepare(&s,
               "SELECT name, upper(name) FROM temp.%s"
               " WHERE is_index AND tblname=%Q",
               s.zSU, zName);
@@ -722,21 +731,21 @@ static void analyzeFunc(
         const char *zN = (const char*)sqlite3_column_text(pS2, 0);
         zTitle = sqlite3_mprintf("Index %s", zU);
         zWhere = sqlite3_mprintf("name=%Q", zN);
-        rc = analysisSubreport(&s, zTitle, zWhere, pgsz, nPage);
+        rc = diskusedSubreport(&s, zTitle, zWhere, pgsz, nPage);
         sqlite3_free(zTitle);
         sqlite3_free(zWhere);
         if( rc ) break;
       }
-      rc = analysisStmtFinish(&s, rc, pS2);
+      rc = diskusedStmtFinish(&s, rc, pS2);
       if( rc ) break;
     }
   }
-  if( analysisStmtFinish(&s, rc, pStmt) ) return;
+  if( diskusedStmtFinish(&s, rc, pStmt) ) return;
 
   /* Append SQL statements that will recreate the raw data used for
   ** the analysis.
   */
-  analysisTitle(&s, "Raw data used to generate this report");
+  diskusedTitle(&s, "Raw data used to generate this report");
   sqlite3_str_appendf(s.pOut,
     "The following SQL will create a table named \"space_used\" which\n"
     "contains most of the information used to generate the report above.\n"
@@ -766,7 +775,7 @@ static void analyzeFunc(
     ");\n"
     "INSERT INTO space_used VALUES\n"
   );
-  pStmt = analysisPrepare(&s,
+  pStmt = diskusedPrepare(&s,
      "SELECT quote(name), quote(tblname),\n"                        /* 0..1 */
      "       is_index, is_without_rowid, nentry, leaf_entries,\n"   /* 2..5 */
      "       depth, payload, ovfl_payload, ovfl_cnt, mx_payload,\n" /* 6..10 */
@@ -801,7 +810,7 @@ static void analyzeFunc(
       sqlite3_column_int64(pStmt, 17));
   }
   if( rc!=SQLITE_DONE ){
-    analysisError(&s, "SQL run-time error: %s\nSQL: %s",
+    diskusedError(&s, "SQL run-time error: %s\nSQL: %s",
                   sqlite3_errmsg(s.db), sqlite3_sql(pStmt));
     sqlite3_finalize(pStmt);
     return;
@@ -814,14 +823,14 @@ static void analyzeFunc(
                         sqlite3_free);
     s.pOut = 0;
   }
-  analysisReset(&s);
+  diskusedReset(&s);
 }
 
 
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int sqlite3_analyze_init(
+int sqlite3_diskused_init(
   sqlite3 *db, 
   char **pzErrMsg, 
   const sqlite3_api_routines *pApi
@@ -829,8 +838,8 @@ int sqlite3_analyze_init(
   int rc = SQLITE_OK;
   SQLITE_EXTENSION_INIT2(pApi);
   (void)pzErrMsg;  /* Unused parameter */
-  rc = sqlite3_create_function(db, "analyze", 1,
+  rc = sqlite3_create_function(db, "diskused", 1,
                    SQLITE_UTF8|SQLITE_INNOCUOUS,
-                   0, analyzeFunc, 0, 0);
+                   0, diskusedFunc, 0, 0);
   return rc;
 }
diff --git a/main.mk b/main.mk
index 97ff3798e9061b9df834b56f966c0df14dc2174f..337a754d9230603f97b5fe1f7bf7e4f508aad31c 100644 (file)
--- a/main.mk
+++ b/main.mk
@@ -982,11 +982,11 @@ FUZZCHECK_SRC = sqlite3.c \
    $(TOP)/ext/recover/dbdata.c \
    $(TOP)/ext/recover/sqlite3recover.c \
    $(TOP)/test/vt02.c \
-   $(TOP)/ext/misc/analyze.c \
    $(TOP)/ext/misc/base64.c \
    $(TOP)/ext/misc/base85.c \
    $(TOP)/ext/misc/completion.c \
    $(TOP)/ext/misc/decimal.c \
+   $(TOP)/ext/misc/diskused.c \
    $(TOP)/ext/misc/ieee754.c \
    $(TOP)/ext/misc/randomjson.c \
    $(TOP)/ext/misc/regexp.c \
@@ -2345,12 +2345,12 @@ SHELL_DEP = \
     $(TOP)/ext/expert/sqlite3expert.h \
     $(TOP)/ext/intck/sqlite3intck.c \
     $(TOP)/ext/intck/sqlite3intck.h \
-    $(TOP)/ext/misc/analyze.c \
     $(TOP)/ext/misc/appendvfs.c \
     $(TOP)/ext/misc/base64.c \
     $(TOP)/ext/misc/base85.c \
     $(TOP)/ext/misc/completion.c \
     $(TOP)/ext/misc/decimal.c \
+    $(TOP)/ext/misc/diskused.c \
     $(TOP)/ext/misc/fileio.c \
     $(TOP)/ext/misc/ieee754.c \
     $(TOP)/ext/misc/memtrace.c \
index f60d9602cb64cda3e337b7e628daadb794e17a2e..0f28fdfc7f82ffdd03f637ff0eb8a0d0e7eab5d4 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C The\s-csv\soption\sto\sthe\sCLI\salso\ssets\s"-limits\soff",\sfor\slegacy\ncompatibility,\sand\sbecause\sthat\sseems\sto\smake\ssense.\n[forum:/info/2026-05-28T16:23:36Z|Forum\sthread\s2026-05-28T16:23:36Z].
-D 2026-05-29T12:23:38.019
+C Rename\sthe\sext/misc/analyze.c\sextension\sto\sext/misc/diskused.c,\sto\savoid\nconfusion\swith\sthe\ssrc/analyze.c\sfile.\s\sThe\sfunction\sis\snow\scalled\n"diskused(X)"\sinstead\sof\s"analyze(X)".\s\sThe\sCLI\scommand\sis\srenamed\nfrom\s".dbstat"\sto\s".diskused".
+D 2026-05-29T14:57:38.380
 F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
@@ -7,7 +7,7 @@ F AGENTS.md 44ddfb38ef23e277888bd70ae378e6cbf5f5cab0e2a4420bd21d89b6caff7a4a
 F LICENSE.md 6bc480fc673fb4acbc4094e77edb326267dd460162d7723c7f30bee2d3d9e97d
 F Makefile.in 5fda086f33b144da08119255da1d2557f983d0764a13707f05acf0159fd89ba5
 F Makefile.linux-generic bd3e3cacd369821a6241d4ea1967395c962dfe3057e38cb0a435cee0e8b789d0
-F Makefile.msc 6f4294982758b5eeeac740c1a263186c3fcb9ba51d1b48261e321bcb37a41dbb
+F Makefile.msc 3b2129c90e15ea734682c8769b567012200ac30d7ff1e73c4717e23edbe1bb4b
 F README.md f00091ffb5c6379b783afb57ca5f443a5742e119082f37c407f64a5e16c56346
 F VERSION 99cf3be5f13d091183e4314b7fc2e0c0e69accfbe64608b45a313338bbdd7b62
 F art/icon-243x273.gif 9750b734f82fdb3dc43127753d5e6fbf3b62c9f4e136c2fbf573b2f57ea87af5
@@ -360,7 +360,6 @@ F ext/jni/src/tests/000-001-ignored.test e17e874c6ab3c437f1293d88093cf06286083b6
 F ext/jni/src/tests/900-001-fts.test bf0ce17a8d082773450e91f2388f5bbb2dfa316d0b676c313c637a91198090f0
 F ext/misc/README.md 6243cdc4d7eb791c41ef0716f3980b8b5f6aa8c61ff76a3958cbf0031c6ebfa7
 F ext/misc/amatch.c 972a250631d481f38736b46740bf7f5c9646a0f2bb53800543299a746ff1bac6
-F ext/misc/analyze.c d311ad12179ef4f945f18fbe7917a3a602765afd152e5bd71d358ee9a7c67473
 F ext/misc/anycollseq.c 5ffdfde9829eeac52219136ad6aa7cd9a4edb3b15f4f2532de52f4a22525eddb
 F ext/misc/appendvfs.c 9642c7a194a2a25dca7ad3e36af24a0a46d7702168c4ad7e59c9f9b0e16a3824
 F ext/misc/base64.c 1445761667c16356e827fc6418294c869468be934429aaa8315035e76dd58acf
@@ -375,6 +374,7 @@ F ext/misc/compress.c 8191118b9b73e7796c961790db62d35d9b0fb724b045e005a5713dc9e0
 F ext/misc/csv.c 5e9d4dd749e762c144104c0f01db5bf4458735b19081ebe481a64e589a66687a
 F ext/misc/dbdump.c 678f1b9ae2317b4473f65d03132a2482c3f4b08920799ed80feedd2941a06680
 F ext/misc/decimal.c 432e5b03a0e2a68a1846a9852a565a1b546ca9b295deda834e4653f0f5577daa
+F ext/misc/diskused.c 56433ee0d1ae21975c549e873d99d07b30b1b7fee9cd58b103797d7c7a2eeab6 w ext/misc/analyze.c
 F ext/misc/eval.c 04bc9aada78c888394204b4ed996ab834b99726fb59603b0ee3ed6e049755dc1
 F ext/misc/explain.c 9670c8ff7b255eea7845abc5123a4958e74016c16990b10497e56380f91704b9
 F ext/misc/fileio.c 936c0a7b3382a047d833ad33f62ba59a3847b79ea745bf529797cd344966fbb0
@@ -660,7 +660,7 @@ F ext/wasm/tests/opfs/sahpool/index.html be736567fd92d3ecb9754c145755037cbbd2bca
 F ext/wasm/tests/opfs/sahpool/sahpool-pausing.js f264925cfc82155de38cecb3d204c36e0f6991460fff0cb7c15079454679a4e2
 F ext/wasm/tests/opfs/sahpool/sahpool-worker.js bd25a43fc2ab2d1bafd8f2854ad3943ef673f7c3be03e95ecf1612ff6e8e2a61
 F magic.txt 5ade0bc977aa135e79e3faaea894d5671b26107cc91e70783aa7dc83f22f3ba0
-F main.mk d9cbbee974a8cd3999430130378878bd87b8c5754397a69ec322f4c9cc3e4e41
+F main.mk 0bbfd0c3d2d3ac908b2a6ab4017bd650be0e694291b7f97490877b7c28a147e4
 F make.bat a136fd0b1c93e89854a86d5f4edcf0386d211e5d5ec2434480f6eea436c7420c
 F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271
 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504
@@ -739,7 +739,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c
 F src/resolve.c 7e936a09405cb59e2b3e51a3ad23753e4803afc5269c5171a54c9bdd70f4fc50
 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97
 F src/select.c 4c05cde130f26991b7411d8c6809e0630625e18078742c963a047b4b9cc01d49
-F src/shell.c.in 6104d39c2416ce235c01134cd79c5be5fdd71323d58be4ace6910b2c3f89253c
+F src/shell.c.in a04d063955a69449e5bd876956ba14cf69a897eda1f5477862ab6f2bbf0d3852
 F src/sqlite.h.in 749454ec71c875bc130d399ff9a7e47191d143d1b9d8b4af3839b6028df9eda9
 F src/sqlite3.rc 015537e6ac1eec6c7050e17b616c2ffe6f70fca241835a84a4f0d5937383c479
 F src/sqlite3ext.h 9788c301f95370fa30e808861f1d2e6f022a816ddbe2a4f67486784c1b31db2e
@@ -1253,7 +1253,7 @@ F test/fuzz3.test 70ba57260364b83e964707b9d4b5625284239768ab907dd387c740c0370ce3
 F test/fuzz4.test c229bcdb45518a89e1d208a21343e061503460ac69fae1539320a89f572eb634
 F test/fuzz_common.tcl b7197de6ed1ee8250a4f82d67876f4561b42ee8cbbfc6160dcb66331bad3f830
 F test/fuzz_malloc.test f348276e732e814802e39f042b1f6da6362a610af73a528d8f76898fde6b22f2
-F test/fuzzcheck.c 5048a2426bd6968a1b9a00cef7f3aa37442a261df3b532c9e44a1f829bddbede
+F test/fuzzcheck.c 674d246742da18270abeef9e8510e3cd9e0e14cddca1f1e8131428928e996a6f
 F test/fuzzdata1.db 3e86d9cf5aea68ddb8e27c02d7dfdaa226347426c7eb814918e4d95475bf8517
 F test/fuzzdata2.db 128b3feeb78918d075c9b14b48610145a0dd4c8d6f1ca7c2870c7e425f5bf31f
 F test/fuzzdata3.db c6586d3e3cef0fbc18108f9bb649aa77bfc38aba
@@ -1635,7 +1635,7 @@ F test/shell3.test 91efdd545097a61a1f72cf79c9ad5b49da080f3f10282eaf4c3c272cd1012
 F test/shell4.test e25580a792b7b54560c3a76b6968bd8189261f38979fe28e6bc6312c5db280db
 F test/shell5.test a0c43d82a811a463a5d07d6418c5a045ab01a072544db8aa31ae394e93845d8d
 F test/shell6.test 596f2eb385a1097d4e9130b4d4f663a24cba294b35f13b774b8f13553dec307d
-F test/shell7.test 4468c1abb7e2708a3aa3f84c8918ca31fbf7909b1c19063853f2abb0a072dfab
+F test/shell7.test 6b006d296b569a7ec78b8168af77578b3bde8f58b79c32d9f46cff1eaf763a29
 F test/shell8.test 38c9e4d7e85d2a3ecfacaa9f6cda4f7a81bf4fffb5f3f37f9cd76827c6883192
 F test/shell9.test c0e8871061a92151450b3332279a893b516fa73a6c46d4f51a0998407cbf8c89
 F test/shellA.test 05cdaafa1f79913654487ce3aefa038d4106245d58f52e02faf506140a76d480
@@ -2208,8 +2208,8 @@ F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee
 F tool/warnings.sh a554d13f6e5cf3760f041b87939e3d616ec6961859c3245e8ef701d1eafc2ca2
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
 F tool/winmain.c 00c8fb88e365c9017db14c73d3c78af62194d9644feaf60e220ab0f411f3604c
-P 87c37dab7e53d1bd891f3fed624963b35ab15a785706d0964b5d07ab70421c10
-R 8367c73dbaaca89b3d19653c5b15b836
+P d15cd64160192119a5f12afec14dbfbb30fb38a8557cb9dc559b3f061c15687a
+R b94ebbf5e61926662e4d4c59c4ea9472
 U drh
-Z 434986435224008c0a9c313fa9bac32b
+Z c87a787fc483b6eb7052d881e8ec7a13
 # Remove this line to create a well-formed Fossil manifest.
index b55fabd9f3ab68aa203c9bd1ae7edd0b565f7d73..3888c14448715b50dc4d987658e9470aae2f8945 100644 (file)
@@ -1 +1 @@
-d15cd64160192119a5f12afec14dbfbb30fb38a8557cb9dc559b3f061c15687a
+c7839f7a1749b38f8a36c06d93a7b59095e91ce753e8dd020de273ca8f73a239
index fc50e43013985cbdb991c929cdea568fe189afdf..38888bf1a607fbdb49df05bd014b236c485c53bd 100644 (file)
@@ -301,7 +301,7 @@ INCLUDE ../ext/intck/sqlite3intck.h
 INCLUDE ../ext/intck/sqlite3intck.c
 INCLUDE ../ext/misc/stmtrand.c
 INCLUDE ../ext/misc/vfstrace.c
-INCLUDE ../ext/misc/analyze.c
+INCLUDE ../ext/misc/diskused.c
 
 #if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_ENABLE_DBPAGE_VTAB)
 #define SQLITE_SHELL_HAVE_RECOVER 1
@@ -4266,8 +4266,8 @@ static const char *(azHelp[]) = {
 #if SQLITE_SHELL_HAVE_RECOVER
   ".dbinfo ?DB?             Show status information about the database",
 #endif
-  ".dbstat ?SCHEMA?         Report database space and size stats",
   ".dbtotxt                 Hex dump of the database file",
+  ".diskused ?SCHEMA?       Report database space and size stats",
   ".dump ?OBJECTS?          Render database content as SQL",
   "   Options:",
   "     --data-only            Output only INSERT statements",
@@ -5096,7 +5096,7 @@ static void open_db(ShellState *p, int openFlags){
     sqlite3_regexp_init(p->db, 0, 0);
     sqlite3_ieee_init(p->db, 0, 0);
     sqlite3_series_init(p->db, 0, 0);
-    sqlite3_analyze_init(p->db, 0, 0);
+    sqlite3_diskused_init(p->db, 0, 0);
 #ifndef SQLITE_SHELL_FIDDLE
     sqlite3_fileio_init(p->db, 0, 0);
     sqlite3_completion_init(p->db, 0, 0);
@@ -9979,7 +9979,12 @@ static int do_meta_command(const char *zLine, ShellState *p){
   }else
 #endif /* SQLITE_SHELL_HAVE_RECOVER */
 
-  if( c=='d' && n==6 && cli_strncmp(azArg[0], "dbstat", n)==0 ){
+  if( c=='d' && n>=3 && cli_strncmp(azArg[0], "dbtotxt", n)==0 ){
+    open_db(p, 0);
+    rc = shell_dbtotxt_command(p, nArg, azArg);
+  }else
+
+  if( c=='d' && n==8 && cli_strncmp(azArg[0], "diskused", n)==0 ){
     const char *zSchema = 0;
     int ii;
     char *zSql;
@@ -9998,7 +10003,7 @@ static int do_meta_command(const char *zLine, ShellState *p){
       }
       zSchema = z;
     }
-    zSql = sqlite3_mprintf("SELECT analyze(%Q)", zSchema);
+    zSql = sqlite3_mprintf("SELECT diskused(%Q)", zSchema);
     shell_check_oom(zSql);
     modePush(p);
     modeChange(p, MODE_BATCH);
@@ -10007,11 +10012,6 @@ static int do_meta_command(const char *zLine, ShellState *p){
     sqlite3_free(zSql);
   }else
 
-  if( c=='d' && n>=3 && cli_strncmp(azArg[0], "dbtotxt", n)==0 ){
-    open_db(p, 0);
-    rc = shell_dbtotxt_command(p, nArg, azArg);
-  }else
-
   if( c=='d' && cli_strncmp(azArg[0], "dump", n)==0 ){
     char *zLike = 0;
     char *zSql;
index 082d29b5bc8b66a2915208374eb8f264bf03d318..fcee2178ed9c777770fb6e201e766078c2ed762c 100644 (file)
@@ -172,11 +172,11 @@ static struct GlobalVars {
 extern int sqlite3_vt02_init(sqlite3*,char**,void*);
 extern int sqlite3_randomjson_init(sqlite3*,char**,void*);
 extern int sqlite3_series_init(sqlite3*,char**,void*);
-extern int sqlite3_analyze_init(sqlite3*,char**,void*);
 extern int sqlite3_base64_init(sqlite3*,char**,void*);
 extern int sqlite3_base85_init(sqlite3*,char**,void*);
 extern int sqlite3_completion_init(sqlite3*,char**,void*);
 extern int sqlite3_decimal_init(sqlite3*,char**,void*);
+extern int sqlite3_diskused_init(sqlite3*,char**,void*);
 extern int sqlite3_ieee_init(sqlite3*,char**,void*);
 extern int sqlite3_regexp_init(sqlite3*,char**,void*);
 extern int sqlite3_shathree_init(sqlite3*,char**,void*);
@@ -1394,11 +1394,11 @@ int runCombinedDbSqlInput(
   /* Activate extensions */
   sqlite3_randomjson_init(cx.db, 0, 0);
   sqlite3_series_init(cx.db, 0, 0);
-  sqlite3_analyze_init(cx.db, 0, 0);
   sqlite3_base64_init(cx.db, 0, 0);
   sqlite3_base85_init(cx.db, 0, 0);
   sqlite3_completion_init(cx.db, 0, 0);
   sqlite3_decimal_init(cx.db, 0, 0);
+  sqlite3_diskused_init(cx.db, 0, 0);
   sqlite3_ieee_init(cx.db, 0, 0);
   sqlite3_regexp_init(cx.db, 0, 0);
   sqlite3_shathree_init(cx.db, 0, 0);
index 40ac91c770591557d6b07c560f351f97617e37f1..9520f3d5601d10bdc4aadd2cc17d635909d99395 100644 (file)
@@ -58,7 +58,7 @@ if {[catch {db eval { SELECT * FROM dbstat }} msg]==0} {
   }
 
   do_test 2.1 {
-    catchcmd test.db "SELECT length( analyze('main') ) > 1000"
+    catchcmd test.db "SELECT length( diskused('main') ) > 1000"
   } {0 1}
 
   do_execsql_test 2.2 {
@@ -68,7 +68,7 @@ if {[catch {db eval { SELECT * FROM dbstat }} msg]==0} {
   }
 
   do_test 2.3 {
-    catchcmd test.db "SELECT length( analyze('main') ) > 1000"
+    catchcmd test.db "SELECT length( diskused('main') ) > 1000"
   } {0 1}
 }