Small performance optimization in sqlite3VdbeRecordCompareWithSkip() for
[sqlite.git] / test / index5.test
blob4c0aa0431e626dcaac66e811cca314b2eb54acbc
1 # 2012 August 6
3 # The author disclaims copyright to this source code.  In place of
4 # a legal notice, here is a blessing:
6 #    May you do good and not evil.
7 #    May you find forgiveness for yourself and forgive others.
8 #    May you share freely, never taking more than you give.
10 #***********************************************************************
14 set testdir [file dirname $argv0]
15 source $testdir/tester.tcl
16 set ::testprefix index5
18 do_test 1.1 {
19   if {[permutation]=="memsubsys1"} {
20     execsql { PRAGMA auto_vacuum = 0; }
21   }
22   execsql {
23     PRAGMA page_size = 1024;
24     CREATE TABLE t1(x);
25     BEGIN;
26   }
27   for {set i 0} {$i < 100000} {incr i} {
28     execsql { INSERT INTO t1 VALUES(randstr(100,100)) }
29   }
30   execsql COMMIT
31   execsql { 
32     CREATE INDEX i1 ON t1(x);
33     DROP INDEX I1;
34     PRAGMA main.page_size;
35   }
36 } {1024}
38 db close
39 testvfs tvfs
40 tvfs filter xWrite
41 tvfs script write_cb
42 proc write_cb {xCall file handle iOfst args} {
43   if {[file tail $file]=="test.db"} {
44     lappend ::write_list [expr $iOfst/1024 + 1]
45   }
48 do_test 1.2 {
49   sqlite3 db test.db -vfs tvfs
50   set ::write_list [list]
51   execsql { CREATE INDEX i1 ON t1(x) }
52 } {}
54 do_test 1.3 {
55   set nForward 0
56   set nBackward 0
57   set nNoncont 0
58   set iPrev [lindex $::write_list 0]
59   for {set i 1} {$i < [llength $::write_list]} {incr i} {
60     set iNext [lindex $::write_list $i]
61     if {$iNext==($iPrev+1)} {
62       incr nForward
63     } elseif {$iNext==($iPrev-1)} { 
64       incr nBackward 
65     } else {
66       incr nNoncont
67     }
68     set iPrev $iNext
69   }
70   if {0} {
71     puts -nonewline \
72         " (forward=$nForward, back=$nBackward, noncontiguous=$nNoncont)"
73   }
75   expr {$nForward > 2*($nBackward + $nNoncont)}
76 } {1}
77 db close
78 tvfs delete
80 finish_test