CoolFace
Modelpublic

AryaWu/sqlite

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
tkt2332.test68 linesDownload Raw Back to test
1# 2007 May 32#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# $Id: tkt2332.test,v 1.4 2007/09/12 17:01:45 danielk1977 Exp $13#14 15set testdir [file dirname $argv0]16source $testdir/tester.tcl17 18ifcapable !incrblob||!tclvar {19  finish_test20  return21}22 23do_test tkt2332.1 {24  execsql {25    CREATE TABLE blobs (k INTEGER PRIMARY KEY, v BLOB);26    PRAGMA cache_size = 100;27  }28} {}29 30set ::iKey 131foreach Len [list 10000 100000 1000000] {32  do_test tkt2332.$Len.1 {33    set val "[expr rand()][expr rand()][expr rand()][expr rand()][expr rand()]"34    set ::blobstr [string range \35      [string repeat $val [expr ($Len/[string length $val])+1]] 0 [expr $Len-1]36    ]37 38    db eval { INSERT INTO blobs VALUES($::iKey, zeroblob($Len)) }39  } {}40 41  do_test tkt2332.$Len.2 {42    execsql {43      SELECT length(v) FROM blobs WHERE k = $::iKey;44    }45  } $Len46 47  do_test tkt2332.$Len.3 {48    set ::fd [db incrblob blobs v $::iKey]49    puts -nonewline $::fd $::blobstr50    close $::fd51  } {}52 53  do_test tkt2332.$Len.4 {54    execsql { SELECT length(v) FROM blobs WHERE k = $::iKey; }55  } $Len56 57  do_test tkt2332.$Len.5 {58    lindex [execsql {SELECT v FROM blobs WHERE k = $::iKey}] 059  } $::blobstr60 61  incr ::iKey62}63 64# Free memory:65unset ::blobstr66 67finish_test68