2007-05-01 21:49:49 +04:00
|
|
|
# 2007 May 1
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
#***********************************************************************
|
|
|
|
#
|
2007-05-02 17:16:30 +04:00
|
|
|
# $Id: incrblob.test,v 1.2 2007/05/02 13:16:31 danielk1977 Exp $
|
2007-05-01 21:49:49 +04:00
|
|
|
|
|
|
|
set testdir [file dirname $argv0]
|
|
|
|
source $testdir/tester.tcl
|
|
|
|
|
|
|
|
do_test incrblob-1.1 {
|
|
|
|
execsql {
|
|
|
|
CREATE TABLE blobs(k PRIMARY KEY, v BLOB);
|
|
|
|
INSERT INTO blobs VALUES('one', X'0102030405060708090A');
|
|
|
|
INSERT INTO blobs VALUES('two', X'0A090807060504030201');
|
|
|
|
}
|
|
|
|
} {}
|
|
|
|
|
|
|
|
do_test incrblob-1.2.1 {
|
|
|
|
set ::blob [db incrblob blobs v 1]
|
|
|
|
} {incrblob_1}
|
|
|
|
do_test incrblob-1.2.2 {
|
|
|
|
binary scan [read $::blob] c* data
|
|
|
|
set data
|
|
|
|
} {1 2 3 4 5 6 7 8 9 10}
|
|
|
|
do_test incrblob-1.2.3 {
|
|
|
|
seek $::blob 0
|
|
|
|
puts -nonewline $::blob "1234567890"
|
|
|
|
flush $::blob
|
|
|
|
} {}
|
|
|
|
do_test incrblob-1.2.4 {
|
|
|
|
seek $::blob 0
|
|
|
|
binary scan [read $::blob] c* data
|
|
|
|
set data
|
|
|
|
} {49 50 51 52 53 54 55 56 57 48}
|
|
|
|
do_test incrblob-1.2.5 {
|
|
|
|
close $::blob
|
|
|
|
} {}
|
|
|
|
do_test incrblob-1.2.6 {
|
|
|
|
execsql {
|
|
|
|
SELECT v FROM blobs WHERE rowid = 1;
|
|
|
|
}
|
|
|
|
} {1234567890}
|
|
|
|
|
2007-05-02 17:16:30 +04:00
|
|
|
#--------------------------------------------------------------------
|
|
|
|
# Test cases incrblob-2.X check that it is possible to read and write
|
|
|
|
# regions of a blob that lie on overflow pages.
|
|
|
|
do_test incrblob-2.1 {
|
|
|
|
set ::str "[string repeat . 10000]"
|
|
|
|
execsql {
|
|
|
|
INSERT INTO blobs(rowid, k, v) VALUES(3, 'three', $::str);
|
|
|
|
}
|
|
|
|
} {}
|
|
|
|
|
|
|
|
do_test incrblob-2.2 {
|
|
|
|
set ::blob [db incrblob blobs v 3]
|
|
|
|
seek $::blob 8500
|
|
|
|
read $::blob 10
|
|
|
|
} {..........}
|
|
|
|
|
|
|
|
do_test incrblob-2.3 {
|
|
|
|
seek $::blob 8500
|
|
|
|
puts -nonewline $::blob 1234567890
|
|
|
|
} {}
|
|
|
|
|
|
|
|
do_test incrblob-2.4 {
|
|
|
|
seek $::blob 8496
|
|
|
|
read $::blob 10
|
|
|
|
} {....123456}
|
|
|
|
|
|
|
|
do_test incrblob-2.10 {
|
|
|
|
close $::blob
|
|
|
|
} {}
|
2007-05-01 21:49:49 +04:00
|
|
|
|
2007-05-02 17:16:30 +04:00
|
|
|
finish_test
|
2007-05-01 21:49:49 +04:00
|
|
|
|