diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-05 17:28:19 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-05 17:28:19 +0000 |
commit | 18657a960e125336f704ea058e25c27bd3900dcb (patch) | |
tree | 17b438b680ed45a996d7b59951e6aa34023783f2 /test/tkt2332.test | |
parent | Initial commit. (diff) | |
download | sqlite3-upstream.tar.xz sqlite3-upstream.zip |
Adding upstream version 3.40.1.upstream/3.40.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/tkt2332.test')
-rw-r--r-- | test/tkt2332.test | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/test/tkt2332.test b/test/tkt2332.test new file mode 100644 index 0000000..2d09dda --- /dev/null +++ b/test/tkt2332.test @@ -0,0 +1,67 @@ +# 2007 May 3 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# +# $Id: tkt2332.test,v 1.4 2007/09/12 17:01:45 danielk1977 Exp $ +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl + +ifcapable !incrblob||!tclvar { + finish_test + return +} + +do_test tkt2332.1 { + execsql { + CREATE TABLE blobs (k INTEGER PRIMARY KEY, v BLOB); + PRAGMA cache_size = 100; + } +} {} + +set ::iKey 1 +foreach Len [list 10000 100000 1000000] { + do_test tkt2332.$Len.1 { + set val "[expr rand()][expr rand()][expr rand()][expr rand()][expr rand()]" + set ::blobstr [string range \ + [string repeat $val [expr ($Len/[string length $val])+1]] 0 [expr $Len-1] + ] + + db eval { INSERT INTO blobs VALUES($::iKey, zeroblob($Len)) } + } {} + + do_test tkt2332.$Len.2 { + execsql { + SELECT length(v) FROM blobs WHERE k = $::iKey; + } + } $Len + + do_test tkt2332.$Len.3 { + set ::fd [db incrblob blobs v $::iKey] + puts -nonewline $::fd $::blobstr + close $::fd + } {} + + do_test tkt2332.$Len.4 { + execsql { SELECT length(v) FROM blobs WHERE k = $::iKey; } + } $Len + + do_test tkt2332.$Len.5 { + lindex [execsql {SELECT v FROM blobs WHERE k = $::iKey}] 0 + } $::blobstr + + incr ::iKey +} + +# Free memory: +unset ::blobstr + +finish_test |