]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add to sqlite3_analyzer command-line options --version and --tclsh, and also
authordrh <drh@noemail.net>
Wed, 12 Oct 2016 18:26:26 +0000 (18:26 +0000)
committerdrh <drh@noemail.net>
Wed, 12 Oct 2016 18:26:26 +0000 (18:26 +0000)
the undocumented --debug option.

FossilOrigin-Name: e87d02d289a2016ea3ee074e914b07a8ac22b21f

manifest
manifest.uuid
tool/spaceanal.tcl

index e13f42949f15eedf7e5d70362b9d045163aeb3e2..241e0db8a7529ff06ed9982eea90229b76f6301b 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C New\stestcase()\smacros\sto\sensure\scoverage\sof\sthe\sORDER\sBY\sLIMIT\soptimization\ncode\sin\swhere.c.
-D 2016-10-12T15:15:30.391
+C Add\sto\ssqlite3_analyzer\scommand-line\soptions\s--version\sand\s--tclsh,\sand\salso\nthe\sundocumented\s--debug\soption.
+D 2016-10-12T18:26:26.364
 F Makefile.in 6fd48ffcf7c2deea7499062d1f3747f986c19678
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc 5151cc64c4c05f3455f4f692ad11410a810d937f
@@ -1484,7 +1484,7 @@ F tool/showlocks.c 9920bcc64f58378ff1118caead34147201f48c68
 F tool/showstat4.c bda40d6e395df7edb6e9ea630784d3d762c35b4b
 F tool/showwal.c ec79959834f7b21f1e0a2aa52bb7c056d2203977
 F tool/soak1.tcl 8d407956e1a45b485a8e072470a3e629a27037fe
-F tool/spaceanal.tcl 85d90e6674d8298e3eaf82dbcef3abc2d5317f3e
+F tool/spaceanal.tcl ab7d9bf68062907282a64b3e12ccbfad47193c5a
 F tool/speed-check.sh da6ce45957c509ba6343fe3fef167e7e2b306262
 F tool/speedtest.tcl 06c76698485ccf597b9e7dbb1ac70706eb873355
 F tool/speedtest16.c ecb6542862151c3e6509bbc00509b234562ae81e
@@ -1525,7 +1525,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 8e2b25f9b8a7ed087d3cece74239814bee19429e
-R 85b771c181ab2a587da3b9154662733d
+P 61f0526978af667781c57bcc87510e4524efd0d8
+R 939be1793993bb5a0733cfe788e02f4d
 U drh
-Z ed0e3333d86697e18712f68be162b390
+Z 3046f41ed5ee9baf8f6c825aaff1459e
index 704a1a0c21174614c0e36d74b26ae900bf8f1f0d..ceae9890fc0e30e057efd3cd0acdc9dabd96823e 100644 (file)
@@ -1 +1 @@
-61f0526978af667781c57bcc87510e4524efd0d8
\ No newline at end of file
+e87d02d289a2016ea3ee074e914b07a8ac22b21f
\ No newline at end of file
index eef1192a1deab89424b0e22bb56e6b6d6bddc545..e7ce846f865b780d57dc79502674f9e45a289ce7 100644 (file)
@@ -22,6 +22,33 @@ proc is_without_rowid {tname} {
   return 0
 }
 
+# Read and run TCL commands from standard input.  Used to implement
+# the --tclsh option.
+#
+proc tclsh {} {
+  set line {}
+  while {![eof stdin]} {
+    if {$line!=""} {
+      puts -nonewline "> "
+    } else {
+      puts -nonewline "% "
+    }
+    flush stdout
+    append line [gets stdin]
+    if {[info complete $line]} {
+      if {[catch {uplevel #0 $line} result]} {
+        puts stderr "Error: $result"
+      } elseif {$result!=""} {
+        puts $result
+      }
+      set line {}
+    } else {
+      append line \n
+    }
+  }
+}
+
+
 # Get the name of the database to analyze
 #
 proc usage {} {
@@ -34,22 +61,37 @@ information for the database and its constituent tables and indexes.
 
 Options:
 
-   --stats        Output SQL text that creates a new database containing
-                  statistics about the database that was analyzed
+   --pageinfo   Show how each page of the database-file is used
+
+   --stats      Output SQL text that creates a new database containing
+                statistics about the database that was analyzed
+
+   --tclsh      Run the built-in TCL interpreter interactively (for debugging)
 
-   --pageinfo     Show how each page of the database-file is used
+   --version    Show the version number of SQLite
 }
   exit 1
 }
 set file_to_analyze {}
 set flags(-pageinfo) 0
 set flags(-stats) 0
+set flags(-debug) 0
 append argv {}
 foreach arg $argv {
   if {[regexp {^-+pageinfo$} $arg]} {
     set flags(-pageinfo) 1
   } elseif {[regexp {^-+stats$} $arg]} {
     set flags(-stats) 1
+  } elseif {[regexp {^-+debug$} $arg]} {
+    set flags(-debug) 1
+  } elseif {[regexp {^-+tclsh$} $arg]} {
+    tclsh
+    exit 0
+  } elseif {[regexp {^-+version$} $arg]} {
+    sqlite3 mem :memory:
+    puts [mem one {SELECT sqlite_version()||' '||sqlite_source_id()}]
+    mem close
+    exit 0
   } elseif {[regexp {^-} $arg]} {
     puts stderr "Unknown option: $arg"
     usage
@@ -100,6 +142,10 @@ if {[catch {sqlite3 db $file_to_analyze -uri 1} msg]} {
   puts stderr "error trying to open $file_to_analyze: $msg"
   exit 1
 }
+if {$flags(-debug)} {
+  proc dbtrace {txt} {puts $txt; flush stdout;}
+  db trace ::dbtrace
+}
 
 db eval {SELECT count(*) FROM sqlite_master}
 set pageSize [expr {wide([db one {PRAGMA page_size}])}]
@@ -142,12 +188,17 @@ if {$flags(-stats)} {
   exit 0
 }
 
+
 # In-memory database for collecting statistics. This script loops through
 # the tables and indices in the database being analyzed, adding a row for each
 # to an in-memory database (for which the schema is shown below). It then
 # queries the in-memory db to produce the space-analysis report.
 #
 sqlite3 mem :memory:
+if {$flags(-debug)} {
+  proc dbtrace {txt} {puts $txt; flush stdout;}
+  mem trace ::dbtrace
+}
 set tabledef {CREATE TABLE space_used(
    name clob,        -- Name of a table or index in the database file
    tblname clob,     -- Name of associated table