author | sl@SLION-WIN7.fritz.box |
Fri, 15 Jun 2012 03:10:57 +0200 | |
changeset 0 | bde4ae8d615e |
permissions | -rw-r--r-- |
sl@0 | 1 |
# 2007 May 3 |
sl@0 | 2 |
# |
sl@0 | 3 |
# The author disclaims copyright to this source code. In place of |
sl@0 | 4 |
# a legal notice, here is a blessing: |
sl@0 | 5 |
# |
sl@0 | 6 |
# May you do good and not evil. |
sl@0 | 7 |
# May you find forgiveness for yourself and forgive others. |
sl@0 | 8 |
# May you share freely, never taking more than you give. |
sl@0 | 9 |
# |
sl@0 | 10 |
#*********************************************************************** |
sl@0 | 11 |
# |
sl@0 | 12 |
# $Id: tkt2332.test,v 1.4 2007/09/12 17:01:45 danielk1977 Exp $ |
sl@0 | 13 |
# |
sl@0 | 14 |
|
sl@0 | 15 |
set testdir [file dirname $argv0] |
sl@0 | 16 |
source $testdir/tester.tcl |
sl@0 | 17 |
|
sl@0 | 18 |
ifcapable !incrblob||!tclvar { |
sl@0 | 19 |
finish_test |
sl@0 | 20 |
return |
sl@0 | 21 |
} |
sl@0 | 22 |
|
sl@0 | 23 |
do_test tkt2332.1 { |
sl@0 | 24 |
execsql { |
sl@0 | 25 |
CREATE TABLE blobs (k INTEGER PRIMARY KEY, v BLOB); |
sl@0 | 26 |
PRAGMA cache_size = 100; |
sl@0 | 27 |
} |
sl@0 | 28 |
} {} |
sl@0 | 29 |
|
sl@0 | 30 |
set ::iKey 1 |
sl@0 | 31 |
foreach Len [list 10000 100000 1000000] { |
sl@0 | 32 |
do_test tkt2332.$Len.1 { |
sl@0 | 33 |
set val "[expr rand()][expr rand()][expr rand()][expr rand()][expr rand()]" |
sl@0 | 34 |
set ::blobstr [string range \ |
sl@0 | 35 |
[string repeat $val [expr ($Len/[string length $val])+1]] 0 [expr $Len-1] |
sl@0 | 36 |
] |
sl@0 | 37 |
|
sl@0 | 38 |
db eval { INSERT INTO blobs VALUES($::iKey, zeroblob($Len)) } |
sl@0 | 39 |
} {} |
sl@0 | 40 |
|
sl@0 | 41 |
do_test tkt2332.$Len.2 { |
sl@0 | 42 |
execsql { |
sl@0 | 43 |
SELECT length(v) FROM blobs WHERE k = $::iKey; |
sl@0 | 44 |
} |
sl@0 | 45 |
} $Len |
sl@0 | 46 |
|
sl@0 | 47 |
do_test tkt2332.$Len.3 { |
sl@0 | 48 |
set ::fd [db incrblob blobs v $::iKey] |
sl@0 | 49 |
puts -nonewline $::fd $::blobstr |
sl@0 | 50 |
close $::fd |
sl@0 | 51 |
} {} |
sl@0 | 52 |
|
sl@0 | 53 |
do_test tkt2332.$Len.4 { |
sl@0 | 54 |
execsql { SELECT length(v) FROM blobs WHERE k = $::iKey; } |
sl@0 | 55 |
} $Len |
sl@0 | 56 |
|
sl@0 | 57 |
do_test tkt2332.$Len.5 { |
sl@0 | 58 |
lindex [execsql {SELECT v FROM blobs WHERE k = $::iKey}] 0 |
sl@0 | 59 |
} $::blobstr |
sl@0 | 60 |
|
sl@0 | 61 |
incr ::iKey |
sl@0 | 62 |
} |
sl@0 | 63 |
|
sl@0 | 64 |
# Free memory: |
sl@0 | 65 |
unset ::blobstr |
sl@0 | 66 |
|
sl@0 | 67 |
finish_test |