/ Check-in [2eacd386]
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:Comment the autovacuum.test script. No code or test-case changes. (CVS 2047)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 2eacd38620f7270467b16e9e2f350aa0b4869a10
User & Date: danielk1977 2004-11-03 09:30:55
Context
2004-11-03
11:37
Auto-vacuum bug: Deallocate pointer-map pages when shrinking a database file. (CVS 2048) check-in: bec6a65a user: danielk1977 tags: trunk
09:30
Comment the autovacuum.test script. No code or test-case changes. (CVS 2047) check-in: 2eacd386 user: danielk1977 tags: trunk
08:44
Auto-vacuum bug: Correctly manipulate page cache hash-table entries in sqlite3pager_movepage(). (CVS 2046) check-in: 719c1b79 user: danielk1977 tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to test/autovacuum.test.

     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this file is testing the SELECT statement.
    13     13   #
    14         -# $Id: autovacuum.test,v 1.3 2004/11/03 03:01:17 danielk1977 Exp $
           14  +# $Id: autovacuum.test,v 1.4 2004/11/03 09:30:55 danielk1977 Exp $
    15     15   
    16     16   set testdir [file dirname $argv0]
    17     17   source $testdir/tester.tcl
    18     18   
           19  +# Return a string $len characters long. The returned string is $char repeated
           20  +# over and over. For example, [make_str abc 8] returns "abcabcab".
    19     21   proc make_str {char len} {
    20     22     set str [string repeat $char. $len]
    21     23     return [string range $str 0 [expr $len-1]]
    22     24   }
    23     25   
           26  +# Return the number of pages in the file test.db by looking at the file system.
    24     27   proc file_pages {} {
    25     28     return [expr [file size test.db] / 1024]
    26     29   }
           30  +
           31  +# Test cases autovacuum-1.* work as follows:
           32  +#
           33  +# 1. A table with a single indexed field is created.
           34  +# 2. Approximately 20 rows are inserted into the table. Each row is long 
           35  +#    enough such that it uses at least 2 overflow pages for both the table 
           36  +#    and index entry.
           37  +# 3. The rows are deleted in a psuedo-random order. Sometimes only one row
           38  +#    is deleted per transaction, sometimes more than one.
           39  +# 4. After each transaction the table data is checked to ensure it is correct
           40  +#    and a "PRAGMA integrity_check" is executed.
           41  +# 5. Once all the rows are deleted the file is checked to make sure it 
           42  +#    consists of exactly 4 pages.
           43  +#
           44  +# Steps 2-5 are repeated for a few different psuedo-random delete patterns 
           45  +# (defined by the $delete_orders list).
           46  +set delete_orders [list]
           47  +lappend delete_orders {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20}
           48  +lappend delete_orders {20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1} 
           49  +lappend delete_orders {8 18 2 4 14 11 13 3 10 7 9 5 12 17 19 15 20 6 16 1}
           50  +lappend delete_orders {10 3 11 17 19 20 7 4 13 6 1 14 16 12 9 18 8 15 5 2}
           51  +lappend delete_orders {{1 2 3 4 5 6 7 8 9 10} {11 12 13 14 15 16 17 18 19 20}}
           52  +lappend delete_orders {{19 8 17 15} {16 11 9 14} {18 5 3 1} {13 20 7 2} {6 12}}
           53  +
           54  +# The length of each table entry. 
           55  +set ENTRY_LEN 3500
    27     56   
    28     57   do_test autovacuum-1.1 {
    29     58     execsql {
    30     59       CREATE TABLE av1(a);
    31     60       CREATE INDEX av1_idx ON av1(a);
    32     61     }
    33     62   } {}
    34     63   
    35         -set ENTRY_LEN 3000
    36         -
    37         -set delete_orders [list]
    38         -lappend delete_orders {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20}
    39         -lappend delete_orders {20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1} 
    40         -lappend delete_orders {8 18 2 4 14 11 13 3 10 7 9 5 12 17 19 15 20 6 16 1}
    41         -lappend delete_orders {10 3 11 17 19 20 7 4 13 6 1 14 16 12 9 18 8 15 5 2}
    42         -lappend delete_orders {{1 2 3 4 5 6 7 8 9 10} {11 12 13 14 15 16 17 18 19 20}}
    43         -lappend delete_orders \
    44         -        {{19 8 17 15} {16 11 9 14} {18 5 3 1} {13 20 7 2} {6 12 4 10}}
    45         -
    46     64   set tn 0
    47     65   foreach delete_order $delete_orders {
    48     66     incr tn
    49     67   
    50     68     # Set up the table.
    51     69     set ::tbl_data [list]
    52     70     foreach i [lsort -integer [eval concat $delete_order]] {
    53     71       execsql "INSERT INTO av1 (oid, a) VALUES($i, '[make_str $i $ENTRY_LEN]')"
    54     72       lappend ::tbl_data [make_str $i $ENTRY_LEN]
    55     73     }
    56     74   
           75  +  # Make sure the integrity check passes with the initial data.
    57     76     do_test autovacuum-1.$tn.1 {
    58     77       execsql {
    59     78         pragma integrity_check
    60     79       }
    61     80     } {ok}
    62     81   
    63     82     foreach delete $delete_order {
           83  +    # Delete one set of rows from the table.
    64     84       do_test autovacuum-1.$tn.($delete).1 {
    65     85         execsql "
    66     86           DELETE FROM av1 WHERE oid IN ([join $delete ,])
    67     87         "
    68     88       } {}
    69     89   
           90  +    # Do the integrity check.
    70     91       do_test autovacuum-1.$tn.($delete).2 {
    71     92         execsql {
    72     93           pragma integrity_check
    73     94         }
    74     95       } {ok}
    75     96   
           97  +    # Ensure the data remaining in the table is what was expected.
    76     98       foreach d $delete {
    77     99         set idx [lsearch $::tbl_data [make_str $d $ENTRY_LEN]]
    78    100         set ::tbl_data [lreplace $::tbl_data $idx $idx]
    79    101       }
    80    102       do_test autovacuum-1.$tn.($delete).3 {
    81    103         execsql {
    82    104           select a from av1
    83    105         }
    84    106       } $::tbl_data
    85    107     }
    86    108   
          109  +  # All rows have been deleted. Ensure the file has shrunk to 4 pages.
    87    110     do_test autovacuum-1.$tn.3 {
    88    111       file_pages
    89    112     } {4}
    90    113   }
    91    114   
    92    115   finish_test
    93    116