File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / sqlite3 / test / tkt2332.test
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue Feb 21 17:04:16 2012 UTC (12 years, 4 months ago) by misho
Branches: sqlite3, MAIN
CVS tags: v3_7_10, HEAD
sqlite3

    1: # 2007 May 3
    2: #
    3: # The author disclaims copyright to this source code.  In place of
    4: # 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.1.1.1 2012/02/21 17:04:16 misho Exp $
   13: #
   14: 
   15: set testdir [file dirname $argv0]
   16: source $testdir/tester.tcl
   17: 
   18: ifcapable !incrblob||!tclvar {
   19:   finish_test
   20:   return
   21: }
   22: 
   23: do_test tkt2332.1 {
   24:   execsql {
   25:     CREATE TABLE blobs (k INTEGER PRIMARY KEY, v BLOB);
   26:     PRAGMA cache_size = 100;
   27:   }
   28: } {}
   29: 
   30: set ::iKey 1
   31: foreach 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:   } $Len
   46: 
   47:   do_test tkt2332.$Len.3 {
   48:     set ::fd [db incrblob blobs v $::iKey]
   49:     puts -nonewline $::fd $::blobstr
   50:     close $::fd
   51:   } {}
   52: 
   53:   do_test tkt2332.$Len.4 {
   54:     execsql { SELECT length(v) FROM blobs WHERE k = $::iKey; }
   55:   } $Len
   56: 
   57:   do_test tkt2332.$Len.5 {
   58:     lindex [execsql {SELECT v FROM blobs WHERE k = $::iKey}] 0
   59:   } $::blobstr
   60: 
   61:   incr ::iKey
   62: }
   63: 
   64: # Free memory:
   65: unset ::blobstr
   66: 
   67: finish_test

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>