blob: d070babe2cb98bd3c6f8969abf8825dfd430925f [file] [log] [blame]
dan61c7f592010-10-26 18:42:52 +00001# 2010 October 26
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#
13
14set testdir [file dirname $argv0]
15source $testdir/tester.tcl
16
dana32536b2021-11-08 19:35:26 +000017ifcapable !incrblob {
18 finish_test
19 return
20}
21
dan61c7f592010-10-26 18:42:52 +000022set testprefix incrblobfault
23
24do_execsql_test 1.0 {
25 CREATE TABLE blob(x INTEGER PRIMARY KEY, v BLOB);
26 INSERT INTO blob VALUES(1, 'hello world');
27 INSERT INTO blob VALUES(2, 'world hello');
28 INSERT INTO blob SELECT NULL, v FROM blob;
29 INSERT INTO blob SELECT NULL, v FROM blob;
30 INSERT INTO blob SELECT NULL, v FROM blob;
31 INSERT INTO blob SELECT NULL, v FROM blob;
32 INSERT INTO blob SELECT NULL, v FROM blob;
33 INSERT INTO blob SELECT NULL, v FROM blob;
34 INSERT INTO blob SELECT NULL, v FROM blob;
35 INSERT INTO blob SELECT NULL, v FROM blob;
36 INSERT INTO blob SELECT NULL, v FROM blob;
37 INSERT INTO blob SELECT NULL, v FROM blob;
38}
39
40do_faultsim_test 1 -prep {
41 sqlite3 db test.db
42 set ::blob [db incrblob blob v 1]
43} -body {
44 if {[catch {sqlite3_blob_reopen $::blob 1000}]} {
45 error [sqlite3_errmsg db]
46 }
47} -test {
48 faultsim_test_result {0 {}}
49 close $::blob
50}
51
52do_faultsim_test 2 -prep {
53 sqlite3 db test.db
54 set ::blob [db incrblob blob v 1]
55} -body {
56 if {[catch {sqlite3_blob_reopen $::blob -1}]} {
57 error [sqlite3_errmsg db]
58 }
59} -test {
dan821fad52017-02-07 14:22:39 +000060 faultsim_test_result {1 {no such rowid: -1}} {1 {disk I/O error}}
dan61c7f592010-10-26 18:42:52 +000061 close $::blob
62}
63
64do_faultsim_test 3 -prep {
65 sqlite3 db test.db
66} -body {
67 set ::blob [db incrblob blob v 1]
68 gets $::blob
69} -test {
70 faultsim_test_result {0 {hello world}}
71 catch { close $::blob }
72}
73
74finish_test