]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix WITHOUT ROWID table handing in sqlite3_analyzer.
authordan <dan@noemail.net>
Mon, 9 Feb 2015 17:46:11 +0000 (17:46 +0000)
committerdan <dan@noemail.net>
Mon, 9 Feb 2015 17:46:11 +0000 (17:46 +0000)
FossilOrigin-Name: 937e0fe7008c0f76b6a584180df9a9457166a0b1

manifest
manifest.uuid
tool/spaceanal.tcl

index 10002ebccfc90f831493bdfcf34e9d44d1dee56e..13b7009965bf78000afa0872c6b773673efc582c 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Rename\sthe\sinternal\s"EP_Constant"\sbitmask\sto\sa\sless\smisleading\s"EP_ConstFunc".
-D 2015-02-09T14:07:07.358
+C Fix\sWITHOUT\sROWID\stable\shanding\sin\ssqlite3_analyzer.
+D 2015-02-09T17:46:11.315
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in 6b9e7677829aa94b9f30949656e27312aefb9a46
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -1222,7 +1222,7 @@ F tool/showstat4.c 9515faa8ec176599d4a8288293ba8ec61f7b728a
 F tool/showwal.c 85cb36d4fe3e93e2fbd63e786e0d1ce42d0c4fad
 F tool/soak1.tcl 8d407956e1a45b485a8e072470a3e629a27037fe
 F tool/space_used.tcl f714c41a59e326b8b9042f415b628b561bafa06b
-F tool/spaceanal.tcl 8e50b217c56a6a086a1b47eac9d09c5cd65b996f
+F tool/spaceanal.tcl d5a09620c66a6c144576cb9d2bdfa9a6fbe362a5
 F tool/speedtest.tcl 06c76698485ccf597b9e7dbb1ac70706eb873355
 F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
@@ -1239,7 +1239,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P aa093fef2d2a7e26d987b46654963e4d7e66d444
-R f51c0a3a4046c27eeedc2e4a71b172ba
-U drh
-Z 4b79838e5fc774abeed8438ce319eb67
+P 4ef7ceced2b0000d21f7f8014384c04a0e4661d3
+R 3dfd2d57b7936b7d1030a6a9083d3a68
+U dan
+Z 936b36142dcc1fcccff0b983a2ef7c1f
index c03c5df094e93d3f374399a36691b59d4ade6af1..dd3e606fa8935c13533a5edc1663180fbb954795 100644 (file)
@@ -1 +1 @@
-4ef7ceced2b0000d21f7f8014384c04a0e4661d3
\ No newline at end of file
+937e0fe7008c0f76b6a584180df9a9457166a0b1
\ No newline at end of file
index a227b8524359c00b9e75f052c092d5e65ab0575f..516d2824451b4ac73b651105390a574c08d6a10c 100644 (file)
@@ -4,6 +4,24 @@
 #
 
 if {[catch {
+
+# Argument $tname is the name of a table within the database opened by
+# database handle [db]. Return true if it is a WITHOUT ROWID table, or
+# false otherwise.
+#
+proc is_without_rowid {tname} {
+  set t [string map {' ''} $tname]
+  db eval "PRAGMA index_list = '$t'" o {
+    if {$o(origin) == "pk"} {
+      set n $o(name)
+      if {0==[db one { SELECT count(*) FROM sqlite_master WHERE name=$n }]} {
+        return 1
+      }
+    }
+  }
+  return 0
+}
+
 # Get the name of the database to analyze
 #
 proc usage {} {
@@ -167,20 +185,21 @@ set sql { SELECT name, tbl_name FROM sqlite_master WHERE rootpage>0 }
 foreach {name tblname} [concat sqlite_master sqlite_master [db eval $sql]] {
 
   set is_index [expr {$name!=$tblname}]
+  set idx_btree [expr {$is_index || [is_without_rowid $name]}]
   db eval {
     SELECT 
       sum(ncell) AS nentry,
-      sum(isleaf(pagetype, $is_index) * ncell) AS leaf_entries,
+      sum(isleaf(pagetype, $idx_btree) * ncell) AS leaf_entries,
       sum(payload) AS payload,
-      sum(isoverflow(pagetype, $is_index) * payload) AS ovfl_payload,
+      sum(isoverflow(pagetype, $idx_btree) * payload) AS ovfl_payload,
       sum(path LIKE '%+000000') AS ovfl_cnt,
       max(mx_payload) AS mx_payload,
-      sum(isinternal(pagetype, $is_index)) AS int_pages,
-      sum(isleaf(pagetype, $is_index)) AS leaf_pages,
-      sum(isoverflow(pagetype, $is_index)) AS ovfl_pages,
-      sum(isinternal(pagetype, $is_index) * unused) AS int_unused,
-      sum(isleaf(pagetype, $is_index) * unused) AS leaf_unused,
-      sum(isoverflow(pagetype, $is_index) * unused) AS ovfl_unused,
+      sum(isinternal(pagetype, $idx_btree)) AS int_pages,
+      sum(isleaf(pagetype, $idx_btree)) AS leaf_pages,
+      sum(isoverflow(pagetype, $idx_btree)) AS ovfl_pages,
+      sum(isinternal(pagetype, $idx_btree) * unused) AS int_unused,
+      sum(isleaf(pagetype, $idx_btree) * unused) AS leaf_unused,
+      sum(isoverflow(pagetype, $idx_btree) * unused) AS ovfl_unused,
       sum(pgsize) AS compressed_size
     FROM temp.dbstat WHERE name = $name
   } break