SQLite

Check-in [c1d877feb5]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add test file incrblob2.test to test opening two blob handles on a single database blob. (CVS 5196)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c1d877feb530b5cdaad55da3dbbb7c2596a10c49
User & Date: danielk1977 2008-06-09 15:51:27.000
Context
2008-06-09
19:27
Moved declaration of int nPage; to top of block to silence picky compilers (MSVC). (CVS 5197) (check-in: 120bffff74 user: shane tags: trunk)
15:51
Add test file incrblob2.test to test opening two blob handles on a single database blob. (CVS 5196) (check-in: c1d877feb5 user: danielk1977 tags: trunk)
2008-06-07
08:58
Change the signature of sqlite3PagerPagecount() so that it can return an error code. (CVS 5195) (check-in: e9f01c0186 user: danielk1977 tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Added test/incrblob2.test.






































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# 2008 June 9
#
# 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.
#
#***********************************************************************
#
# Test that it is possible to have two open blob handles on a single
# blob object.
#
# $Id: incrblob2.test,v 1.1 2008/06/09 15:51:27 danielk1977 Exp $
#

set testdir [file dirname $argv0]
source $testdir/tester.tcl

ifcapable {!autovacuum || !pragma || !incrblob} {
  finish_test
  return
}

do_test incrblob2-1.0 {
  execsql {
    CREATE TABLE blobs(id INTEGER PRIMARY KEY, data BLOB);
    INSERT INTO blobs VALUES(0, zeroblob(10240));
    INSERT INTO blobs VALUES(1, zeroblob(10240));
    INSERT INTO blobs VALUES(2, zeroblob(10240));
  }
} {}

foreach iOffset [list 0 256 4094] {
  do_test incrblob2-1.$iOffset.1 {
    set fd [db incrblob blobs data 1]
    puts $fd "[string repeat x $iOffset]SQLite version 3.6.0"
    close $fd
  } {}
  
  do_test incrblob2-1.$iOffset.2 {
    set fd1 [db incrblob blobs data 1]
    set fd2 [db incrblob blobs data 1]
    fconfigure $fd1 -buffering none
    fconfigure $fd2 -buffering none
    if {$iOffset != 0} {
      seek $fd2 $iOffset start
      seek $fd1 $iOffset start
    }
    read $fd1 6
  } {SQLite}
  
  do_test incrblob2-1.$iOffset.3 {
    read $fd2 6
  } {SQLite}
  
  do_test incrblob2-1.$iOffset.4 {
    seek $fd2 $iOffset start
    seek $fd1 $iOffset start
    puts -nonewline $fd2 "etiLQS"
  } {}

  
  do_test incrblob2-1.$iOffset.5 {
    seek $fd1 $iOffset start
    read $fd1 6
  } {etiLQS}
  
  do_test incrblob2-1.$iOffset.6 {
    seek $fd2 $iOffset start
    read $fd2 6
  } {etiLQS}
  
  do_test incrblob2-1.$iOffset.7 {
    seek $fd1 $iOffset start
    read $fd1 6
  } {etiLQS}
  
  do_test incrblob2-1.$iOffset.8 {
    close $fd1
    close $fd2
  } {}
}

#--------------------------------------------------------------------------

foreach iOffset [list 0 256 4094] {

  do_test incrblob2-2.$iOffset.1 {
    set fd1 [db incrblob blobs data 1]
    seek $fd1 [expr $iOffset - 10240] end
    fconfigure $fd1 -buffering none

    set fd2 [db incrblob blobs data 1]
    seek $fd2 [expr $iOffset - 10240] end
    fconfigure $fd2 -buffering none

    puts -nonewline $fd1 "123456"
  } {}
  
  do_test incrblob2-2.$iOffset.2 {
    read $fd2 6
  } {123456}

  do_test incrblob2-2.$iOffset.3 {
    close $fd1
    close $fd2
  } {}
}

do_test incrblob2-3.1 {
  set fd1 [db incrblob blobs data 1]
  fconfigure $fd1 -buffering none
} {}
do_test incrblob2-3.2 {
  execsql {
    INSERT INTO blobs VALUES(4, zeroblob(10240));
  }
} {}
do_test incrblob2-3.3 {
  set rc [catch { read $fd1 6 } msg]
  list $rc $msg
} "1 {error reading \"$fd1\": interrupted system call}"
do_test incrblob2-3.4 {
  close $fd1
} {}


finish_test