/ Check-in [df550066]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Backslash escaping is not working right in tostr.awk on the latest ubuntu. The easiest fix is to simply not use any backslashes in the spaceanal.tcl script.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: df550066657cb41bad34ac8e722b8148ab7eabfb
User & Date: drh 2011-08-31 17:46:50
Context
2011-08-31
18:04
Only create the sqlite3OSTrace global variable if compiling with SQLITE_TEST. check-in: 9e6a4c14 user: drh tags: trunk
17:46
Backslash escaping is not working right in tostr.awk on the latest ubuntu. The easiest fix is to simply not use any backslashes in the spaceanal.tcl script. check-in: df550066 user: drh tags: trunk
13:27
Add checks to make sure cells in corrupt database files do not overflow a page when doing autovacuum. Problem detected by valgrind. check-in: d0b347b4 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to tool/spaceanal.tcl.

    37     37   
    38     38   # In-memory database for collecting statistics. This script loops through
    39     39   # the tables and indices in the database being analyzed, adding a row for each
    40     40   # to an in-memory database (for which the schema is shown below). It then
    41     41   # queries the in-memory db to produce the space-analysis report.
    42     42   #
    43     43   sqlite3 mem :memory:
    44         -set tabledef\
    45         -{CREATE TABLE space_used(
           44  +set tabledef {CREATE TABLE space_used(
    46     45      name clob,        -- Name of a table or index in the database file
    47     46      tblname clob,     -- Name of associated table
    48     47      is_index boolean, -- TRUE if it is an index, false for a table
    49     48      nentry int,       -- Number of entries in the BTree
    50     49      leaf_entries int, -- Number of leaf entries
    51     50      payload int,      -- Total amount of data stored in this table or index
    52     51      ovfl_payload int, -- Total amount of data stored on overflow pages
................................................................................
   289    288     if {$int_pages>0} {
   290    289       statline {Index pages used} $int_pages
   291    290     }
   292    291     statline {Primary pages used} $leaf_pages
   293    292     statline {Overflow pages used} $ovfl_pages
   294    293     statline {Total pages used} $total_pages
   295    294     if {$int_unused>0} {
   296         -    set int_unused_percent \
   297         -         [percent $int_unused [expr {$int_pages*$pageSize}] {of index space}]
          295  +    set int_unused_percent [
          296  +         percent $int_unused [expr {$int_pages*$pageSize}] {of index space}]
   298    297       statline "Unused bytes on index pages" $int_unused $int_unused_percent
   299    298     }
   300         -  statline "Unused bytes on primary pages" $leaf_unused \
   301         -     [percent $leaf_unused [expr {$leaf_pages*$pageSize}] {of primary space}]
   302         -  statline "Unused bytes on overflow pages" $ovfl_unused \
   303         -     [percent $ovfl_unused [expr {$ovfl_pages*$pageSize}] {of overflow space}]
   304         -  statline "Unused bytes on all pages" $total_unused \
   305         -               [percent $total_unused $storage {of all space}]
          299  +  statline "Unused bytes on primary pages" $leaf_unused [
          300  +     percent $leaf_unused [expr {$leaf_pages*$pageSize}] {of primary space}]
          301  +  statline "Unused bytes on overflow pages" $ovfl_unused [
          302  +     percent $ovfl_unused [expr {$ovfl_pages*$pageSize}] {of overflow space}]
          303  +  statline "Unused bytes on all pages" $total_unused [
          304  +               percent $total_unused $storage {of all space}]
   306    305     return 1
   307    306   }
   308    307   
   309    308   # Calculate the overhead in pages caused by auto-vacuum. 
   310    309   #
   311    310   # This procedure calculates and returns the number of pages used by the 
   312    311   # auto-vacuum 'pointer-map'. If the database does not support auto-vacuum,
................................................................................
   448    447   Page size in bytes
   449    448   
   450    449       The number of bytes in a single page of the database file.  
   451    450       Usually 1024.
   452    451   
   453    452   Number of pages in the whole file
   454    453   }
   455         -puts \
   456         -"    The number of $pageSize-byte pages that go into forming the complete
          454  +puts "    The number of $pageSize-byte pages that go into forming the complete
   457    455       database"
   458         -puts \
   459         -{
          456  +puts {
   460    457   Pages that store data
   461    458   
   462    459       The number of pages that store data, either as primary B*Tree pages or
   463    460       as overflow pages.  The number at the right is the data pages divided by
   464    461       the total number of pages in the file.
   465    462   
   466    463   Pages on the freelist

Changes to tool/tostr.awk.

     1      1   #!/usr/bin/awk
     2      2   #
     3      3   # Convert input text into a C string
     4      4   #
     5      5   {
     6         -  gsub(/\\/,"\\\\");
     7      6     gsub(/\"/,"\\\"");
     8      7     print "\"" $0 "\\n\"";
     9      8   }