danielk1977 | b4e9af9 | 2007-05-01 17:49:49 +0000 | [diff] [blame] | 1 | # 2007 May 1 |
| 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 | # |
danielk1977 | d0441796 | 2007-05-02 13:16:30 +0000 | [diff] [blame^] | 12 | # $Id: incrblob.test,v 1.2 2007/05/02 13:16:31 danielk1977 Exp $ |
danielk1977 | b4e9af9 | 2007-05-01 17:49:49 +0000 | [diff] [blame] | 13 | |
| 14 | set testdir [file dirname $argv0] |
| 15 | source $testdir/tester.tcl |
| 16 | |
| 17 | do_test incrblob-1.1 { |
| 18 | execsql { |
| 19 | CREATE TABLE blobs(k PRIMARY KEY, v BLOB); |
| 20 | INSERT INTO blobs VALUES('one', X'0102030405060708090A'); |
| 21 | INSERT INTO blobs VALUES('two', X'0A090807060504030201'); |
| 22 | } |
| 23 | } {} |
| 24 | |
| 25 | do_test incrblob-1.2.1 { |
| 26 | set ::blob [db incrblob blobs v 1] |
| 27 | } {incrblob_1} |
| 28 | do_test incrblob-1.2.2 { |
| 29 | binary scan [read $::blob] c* data |
| 30 | set data |
| 31 | } {1 2 3 4 5 6 7 8 9 10} |
| 32 | do_test incrblob-1.2.3 { |
| 33 | seek $::blob 0 |
| 34 | puts -nonewline $::blob "1234567890" |
| 35 | flush $::blob |
| 36 | } {} |
| 37 | do_test incrblob-1.2.4 { |
| 38 | seek $::blob 0 |
| 39 | binary scan [read $::blob] c* data |
| 40 | set data |
| 41 | } {49 50 51 52 53 54 55 56 57 48} |
| 42 | do_test incrblob-1.2.5 { |
| 43 | close $::blob |
| 44 | } {} |
| 45 | do_test incrblob-1.2.6 { |
| 46 | execsql { |
| 47 | SELECT v FROM blobs WHERE rowid = 1; |
| 48 | } |
| 49 | } {1234567890} |
| 50 | |
danielk1977 | d0441796 | 2007-05-02 13:16:30 +0000 | [diff] [blame^] | 51 | #-------------------------------------------------------------------- |
| 52 | # Test cases incrblob-2.X check that it is possible to read and write |
| 53 | # regions of a blob that lie on overflow pages. |
| 54 | do_test incrblob-2.1 { |
| 55 | set ::str "[string repeat . 10000]" |
| 56 | execsql { |
| 57 | INSERT INTO blobs(rowid, k, v) VALUES(3, 'three', $::str); |
| 58 | } |
| 59 | } {} |
danielk1977 | b4e9af9 | 2007-05-01 17:49:49 +0000 | [diff] [blame] | 60 | |
danielk1977 | d0441796 | 2007-05-02 13:16:30 +0000 | [diff] [blame^] | 61 | do_test incrblob-2.2 { |
| 62 | set ::blob [db incrblob blobs v 3] |
| 63 | seek $::blob 8500 |
| 64 | read $::blob 10 |
| 65 | } {..........} |
| 66 | |
| 67 | do_test incrblob-2.3 { |
| 68 | seek $::blob 8500 |
| 69 | puts -nonewline $::blob 1234567890 |
| 70 | } {} |
| 71 | |
| 72 | do_test incrblob-2.4 { |
| 73 | seek $::blob 8496 |
| 74 | read $::blob 10 |
| 75 | } {....123456} |
| 76 | |
| 77 | do_test incrblob-2.10 { |
| 78 | close $::blob |
| 79 | } {} |
| 80 | |
| 81 | finish_test |
danielk1977 | b4e9af9 | 2007-05-01 17:49:49 +0000 | [diff] [blame] | 82 | |