1
0

tkt2332.test 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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.4 2007/09/12 17:01:45 danielk1977 Exp $
  13. #
  14. set testdir [file dirname $argv0]
  15. source $testdir/tester.tcl
  16. ifcapable !incrblob||!tclvar {
  17. finish_test
  18. return
  19. }
  20. do_test tkt2332.1 {
  21. execsql {
  22. CREATE TABLE blobs (k INTEGER PRIMARY KEY, v BLOB);
  23. PRAGMA cache_size = 100;
  24. }
  25. } {}
  26. set ::iKey 1
  27. foreach Len [list 10000 100000 1000000] {
  28. do_test tkt2332.$Len.1 {
  29. set val "[expr rand()][expr rand()][expr rand()][expr rand()][expr rand()]"
  30. set ::blobstr [string range \
  31. [string repeat $val [expr ($Len/[string length $val])+1]] 0 [expr $Len-1]
  32. ]
  33. db eval { INSERT INTO blobs VALUES($::iKey, zeroblob($Len)) }
  34. } {}
  35. do_test tkt2332.$Len.2 {
  36. execsql {
  37. SELECT length(v) FROM blobs WHERE k = $::iKey;
  38. }
  39. } $Len
  40. do_test tkt2332.$Len.3 {
  41. set ::fd [db incrblob blobs v $::iKey]
  42. puts -nonewline $::fd $::blobstr
  43. close $::fd
  44. } {}
  45. do_test tkt2332.$Len.4 {
  46. execsql { SELECT length(v) FROM blobs WHERE k = $::iKey; }
  47. } $Len
  48. do_test tkt2332.$Len.5 {
  49. lindex [execsql {SELECT v FROM blobs WHERE k = $::iKey}] 0
  50. } $::blobstr
  51. incr ::iKey
  52. }
  53. # Free memory:
  54. unset ::blobstr
  55. finish_test