CoolFace
Modelpublic

AryaWu/sqlite

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
index5.test81 linesDownload Raw Back to test
1# 2012 August 62#3# The author disclaims copyright to this source code.  In place of4# a legal notice, here is a blessing:5#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.9#10#***********************************************************************11#12 13 14set testdir [file dirname $argv0]15source $testdir/tester.tcl16set ::testprefix index517 18do_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 COMMIT31  execsql { 32    CREATE INDEX i1 ON t1(x);33    DROP INDEX I1;34    PRAGMA main.page_size;35  }36} {1024}37 38db close39testvfs tvfs40tvfs filter xWrite41tvfs script write_cb42proc write_cb {xCall file handle iOfst args} {43  if {[file tail $file]=="test.db"} {44    lappend ::write_list [expr $iOfst/1024 + 1]45  }46}47 48do_test 1.2 {49  sqlite3 db test.db -vfs tvfs50  set ::write_list [list]51  execsql { CREATE INDEX i1 ON t1(x) }52} {}53 54do_test 1.3 {55  set nForward 056  set nBackward 057  set nNoncont 058  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 nForward63    } elseif {$iNext==($iPrev-1)} { 64      incr nBackward 65    } else {66      incr nNoncont67    }68    set iPrev $iNext69  }70  if {0} {71    puts -nonewline \72        " (forward=$nForward, back=$nBackward, noncontiguous=$nNoncont)"73  }74 75  expr {$nForward > 2*($nBackward + $nNoncont)}76} {1}77db close78tvfs delete79 80finish_test81