File: 15_bdb_stat.patch

package info (click to toggle)
db5.3 5.3.28%2Bdfsg2-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 158,500 kB
  • sloc: ansic: 448,411; java: 111,824; tcl: 80,544; sh: 44,264; cs: 33,697; cpp: 21,604; perl: 14,557; xml: 10,799; makefile: 4,077; javascript: 1,998; yacc: 1,003; awk: 965; sql: 801; erlang: 342; python: 216; php: 24; asm: 14
file content (90 lines) | stat: -rw-r--r-- 3,577 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
--- Makefile.in
+++ Makefile.in
@@ -163,8 +163,8 @@
 #
 LIBOBJS0 = alter.lo analyze.lo attach.lo auth.lo \
          backup.lo bitvec.lo btmutex.lo btree.lo build.lo \
-         callback.lo complete.lo ctime.lo date.lo db_pragma.lo delete.lo \
-         expr.lo fault.lo fkey.lo \
+         callback.lo complete.lo ctime.lo date.lo db_pragma.lo db_shell.lo \
+         delete.lo expr.lo fault.lo fkey.lo \
          fts3.lo fts3_aux.lo fts3_expr.lo fts3_hash.lo fts3_icu.lo fts3_porter.lo \
          fts3_snippet.lo fts3_tokenizer.lo fts3_tokenizer1.lo fts3_write.lo \
          func.lo global.lo hash.lo \
@@ -208,6 +208,7 @@ SRC = \
   $(TOP)/src/ctime.c \
   $(TOP)/src/date.c \
   $(TOP)/../adapter/db_pragma.c \
+  $(TOP)/../adapter/db_shell.c \
   $(TOP)/src/delete.c \
   $(TOP)/src/expr.c \
   $(TOP)/src/fault.c \
@@ -583,6 +584,10 @@ db_pragma.lo:	$(TOP)/../adapter/db_pragm
 		$(TOP)/../adapter/btreeInt.h
 	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/../adapter/db_pragma.c
 
+db_shell.lo:	$(TOP)/../adapter/db_shell.c $(HDR) \
+		$(TOP)/../adapter/btreeInt.h
+	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/../adapter/db_shell.c
+
 delete.lo:	$(TOP)/src/delete.c $(HDR)
 	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/delete.c
 
--- src/shell.c
+++ src/shell.c
@@ -1368,6 +1368,17 @@ static char zHelp[] =
   "                         LIKE pattern TABLE.\n"
   ".separator STRING      Change separator used by output mode and .import\n"
   ".show                  Show the current values for various settings\n"
+  ".stat ?ITEM?           Print statistics\n"
+  "                         If ITEM=':env:', print statistics for the\n"
+  "                         Berkeley DB environment.\n"
+  "                         If ITEM=':rep:', print a summary of replication\n"
+  "                         statistics for the Berkeley DB environment.\n"
+  "                         If ITEM is the name of a table or index, print\n"
+  "                         statistics for the table or index.\n"
+  "                         If ITEM is not specified, print statistics for\n"
+  "                         the Berkeley DB environment followed by\n"
+  "                         statistics for all tables and indexes within the\n"
+  "                         database.\n"
   ".stats ON|OFF          Turn stats on or off\n"
   ".tables ?TABLE?        List names of tables\n"
   "                         If TABLE specified, only list tables matching\n"
@@ -2128,6 +2137,27 @@ static int do_meta_command(char *zLine, 
     }
     fprintf(p->out,"\n");
   }else
+  
+  if( c=='s' && strncmp(azArg[0], "stat", n)==0 ){
+    extern int bdbSqlDbStatPrint(sqlite3 *, FILE *, char *);
+    extern int bdbSqlEnvStatPrint(sqlite3 *db, FILE *);
+    extern int bdbSqlRepSumStatPrint(sqlite3 *db, FILE *);
+
+    open_db(p);
+
+    if (nArg == 1 || nArg == 2 && strcmp(azArg[1], ":env:") == 0)
+      rc = bdbSqlEnvStatPrint(p->db, p->out);
+    else if (nArg == 2 && strcmp(azArg[1], ":rep:") == 0)
+      rc = bdbSqlRepSumStatPrint(p->db, p->out);
+    if (rc != SQLITE_OK) {
+      fprintf(stderr, "Error: environment not created yet\n");
+      rc = 1;
+    }
+    else if (nArg == 1)
+      rc = bdbSqlDbStatPrint(p->db, p->out, NULL);
+    else
+      rc = bdbSqlDbStatPrint(p->db, p->out, azArg[1]);
+  }else
 
   if( c=='s' && strncmp(azArg[0], "stats", n)==0 && nArg>1 && nArg<3 ){
     p->statsOn = booleanValue(azArg[1]);
--- tool/mksqlite3c.tcl
+++ tool/mksqlite3c.tcl
@@ -251,6 +251,7 @@ foreach file {
    btree.c
    backup.c
    db_pragma.c
+   db_shell.c
 
    vdbemem.c
    vdbeaux.c