1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-05 15:55:57 +03:00

Structural coverage tests for vdbeblob.c. Including experimental new API sqlite3_blob_reopen().

FossilOrigin-Name: 97c6b2616ddcce2337778c6ee88a973cc4fe999d
This commit is contained in:
dan
2010-10-26 18:42:52 +00:00
parent e3d82a8723
commit 61c7f59c10
6 changed files with 448 additions and 58 deletions

View File

@@ -1,5 +1,5 @@
C Add\smissing\sheader\scomments\sfor\schanges\srelated\sto\sthe\sexperimental\ssqlite3_blob_reopen()\sAPI.
D 2010-10-26T11:56:58
C Structural\scoverage\stests\sfor\svdbeblob.c.\sIncluding\sexperimental\snew\sAPI\ssqlite3_blob_reopen().
D 2010-10-26T18:42:52
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 2c8cefd962eca0147132c7cf9eaa4bb24c656f3f
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -183,7 +183,7 @@ F src/sqliteLimit.h a17dcd3fb775d63b64a43a55c54cb282f9726f44
F src/status.c 496913d4e8441195f6f2a75b1c95993a45b9b30b
F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e
F src/tclsqlite.c e91019fb6787166abca23a81b16c07fecc2ed751
F src/test1.c f6e39615c8315e03798217a360810e4c59595627
F src/test1.c a0d7c2b4d660195684d67ab8f65e4afcb301315b
F src/test2.c 80d323d11e909cf0eb1b6fbb4ac22276483bcf31
F src/test3.c 056093cfef69ff4227a6bdb9108564dc7f45e4bc
F src/test4.c 0528360b5025688002a5feb6be906ddce52eaaee
@@ -231,7 +231,7 @@ F src/vdbe.h 4de0efb4b0fdaaa900cf419b35c458933ef1c6d2
F src/vdbeInt.h 7f4cf1b2b69bef3a432b1f23dfebef57275436b4
F src/vdbeapi.c 5368714fa750270cf6430160287c21adff44582d
F src/vdbeaux.c de0b06b11a25293e820a49159eca9f1c51a64716
F src/vdbeblob.c c2ed68a4f8b764bbc88d3cdbb06c7c274833ae74
F src/vdbeblob.c e0ce3c54cc0c183af2ec67b63a289acf92251df4
F src/vdbemem.c 23723a12cd3ba7ab3099193094cbb2eb78956aa9
F src/vdbetrace.c 864cef96919323482ebd9986f2132435115e9cc2
F src/vtab.c b297e8fa656ab5e66244ab15680d68db0adbec30
@@ -462,7 +462,9 @@ F test/in3.test 3cbf58c87f4052cee3a58b37b6389777505aa0c0
F test/in4.test 64f3cc1acde1b9161ccdd8e5bde3daefdb5b2617
F test/incrblob.test 76e787ca3301d9bfa6906031c626d26f8dd707de
F test/incrblob2.test edc3a96e557bd61fb39acc8d2edd43371fbbaa19
F test/incrblob3.test 3fed76bd79df7049ec696de96632c1ede699ea27
F test/incrblob_err.test c577c91d4ed9e8336cdb188b15d6ee2a6fe9604e
F test/incrblobfault.test 917c0292224c64a56ef7215fd633a3a82f805be0
F test/incrvacuum.test 453d1e490d8f5ad2c9b3a54282a0690d6ae56462
F test/incrvacuum2.test 9e22a794899c91b7d8c8e12eaacac8df249faafe
F test/incrvacuum_ioerr.test 57d2f5777ab13fa03b87b262a4ea1bad5cfc0291
@@ -877,7 +879,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
P 7a2f2864002d4e9a487e2779ae05513880ecb4d1
R 700e55dce71c563fc39a679df209843f
P d1cc5c93f09c9092ec478c04e8d9a8b1f9c0cb04
R 1bc240279e5d7a2dcb9378295e259554
U dan
Z 667f3356e7b88f02a70759616d0ccab9
Z c7b142127578014c4915d0546d65c2ad

View File

@@ -1 +1 @@
d1cc5c93f09c9092ec478c04e8d9a8b1f9c0cb04
97c6b2616ddcce2337778c6ee88a973cc4fe999d

View File

@@ -1590,6 +1590,82 @@ static int test_table_column_metadata(
#ifndef SQLITE_OMIT_INCRBLOB
static int blobHandleFromObj(
Tcl_Interp *interp,
Tcl_Obj *pObj,
sqlite3_blob **ppBlob
){
char *z;
int n;
z = Tcl_GetStringFromObj(pObj, &n);
if( n==0 ){
*ppBlob = 0;
}else{
int notUsed;
Tcl_Channel channel;
ClientData instanceData;
channel = Tcl_GetChannel(interp, z, &notUsed);
if( !channel ) return TCL_ERROR;
Tcl_Flush(channel);
Tcl_Seek(channel, 0, SEEK_SET);
instanceData = Tcl_GetChannelInstanceData(channel);
*ppBlob = *((sqlite3_blob **)instanceData);
}
return TCL_OK;
}
/*
** sqlite3_blob_bytes CHANNEL
*/
static int test_blob_bytes(
ClientData clientData, /* Not used */
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
Tcl_Obj *CONST objv[] /* Command arguments */
){
sqlite3_blob *pBlob;
int nByte;
if( objc!=2 ){
Tcl_WrongNumArgs(interp, 1, objv, "CHANNEL");
return TCL_ERROR;
}
if( blobHandleFromObj(interp, objv[1], &pBlob) ) return TCL_ERROR;
nByte = sqlite3_blob_bytes(pBlob);
Tcl_SetObjResult(interp, Tcl_NewIntObj(nByte));
return TCL_OK;
}
/*
** sqlite3_blob_close CHANNEL
*/
static int test_blob_close(
ClientData clientData, /* Not used */
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
Tcl_Obj *CONST objv[] /* Command arguments */
){
sqlite3_blob *pBlob;
int nByte;
if( objc!=2 ){
Tcl_WrongNumArgs(interp, 1, objv, "CHANNEL");
return TCL_ERROR;
}
if( blobHandleFromObj(interp, objv[1], &pBlob) ) return TCL_ERROR;
sqlite3_blob_close(pBlob);
return TCL_OK;
}
/*
** sqlite3_blob_read CHANNEL OFFSET N
**
@@ -1611,10 +1687,7 @@ static int test_blob_read(
int objc, /* Number of arguments */
Tcl_Obj *CONST objv[] /* Command arguments */
){
Tcl_Channel channel;
ClientData instanceData;
sqlite3_blob *pBlob;
int notUsed;
int nByte;
int iOffset;
unsigned char *zBuf;
@@ -1625,18 +1698,13 @@ static int test_blob_read(
return TCL_ERROR;
}
channel = Tcl_GetChannel(interp, Tcl_GetString(objv[1]), &notUsed);
if( !channel
|| TCL_OK!=Tcl_GetIntFromObj(interp, objv[2], &iOffset)
if( blobHandleFromObj(interp, objv[1], &pBlob) ) return TCL_ERROR;
if( TCL_OK!=Tcl_GetIntFromObj(interp, objv[2], &iOffset)
|| TCL_OK!=Tcl_GetIntFromObj(interp, objv[3], &nByte)
|| nByte<0 || iOffset<0
){
return TCL_ERROR;
}
instanceData = Tcl_GetChannelInstanceData(channel);
pBlob = *((sqlite3_blob **)instanceData);
zBuf = (unsigned char *)Tcl_Alloc(nByte);
rc = sqlite3_blob_read(pBlob, zBuf, nByte, iOffset);
if( rc==SQLITE_OK ){
@@ -1669,10 +1737,7 @@ static int test_blob_write(
int objc, /* Number of arguments */
Tcl_Obj *CONST objv[] /* Command arguments */
){
Tcl_Channel channel;
ClientData instanceData;
sqlite3_blob *pBlob;
int notUsed;
int iOffset;
int rc;
@@ -1684,14 +1749,11 @@ static int test_blob_write(
return TCL_ERROR;
}
channel = Tcl_GetChannel(interp, Tcl_GetString(objv[1]), &notUsed);
if( !channel || TCL_OK!=Tcl_GetIntFromObj(interp, objv[2], &iOffset) ){
if( blobHandleFromObj(interp, objv[1], &pBlob) ) return TCL_ERROR;
if( TCL_OK!=Tcl_GetIntFromObj(interp, objv[2], &iOffset) ){
return TCL_ERROR;
}
instanceData = Tcl_GetChannelInstanceData(channel);
pBlob = *((sqlite3_blob **)instanceData);
zBuf = Tcl_GetByteArrayFromObj(objv[3], &nBuf);
if( objc==5 && Tcl_GetIntFromObj(interp, objv[4], &nBuf) ){
return TCL_ERROR;
@@ -1711,10 +1773,7 @@ static int test_blob_reopen(
Tcl_Obj *CONST objv[] /* Command arguments */
){
Tcl_WideInt iRowid;
Tcl_Channel channel;
ClientData instanceData;
sqlite3_blob *pBlob;
int notUsed;
int rc;
unsigned char *zBuf;
@@ -1725,20 +1784,8 @@ static int test_blob_reopen(
return TCL_ERROR;
}
channel = Tcl_GetChannel(interp, Tcl_GetString(objv[1]), &notUsed);
if( !channel || TCL_OK!=Tcl_GetWideIntFromObj(interp, objv[2], &iRowid) ){
return TCL_ERROR;
}
if( TCL_OK!=(rc = Tcl_Flush(channel)) ){
return rc;
}
if( TCL_OK!=(rc = Tcl_Seek(channel, 0, SEEK_SET)) ){
return rc;
}
instanceData = Tcl_GetChannelInstanceData(channel);
pBlob = *((sqlite3_blob **)instanceData);
if( blobHandleFromObj(interp, objv[1], &pBlob) ) return TCL_ERROR;
if( Tcl_GetWideIntFromObj(interp, objv[2], &iRowid) ) return TCL_ERROR;
rc = sqlite3_blob_reopen(pBlob, iRowid);
if( rc!=SQLITE_OK ){
@@ -5374,6 +5421,8 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
{ "sqlite3_blob_read", test_blob_read, 0 },
{ "sqlite3_blob_write", test_blob_write, 0 },
{ "sqlite3_blob_reopen", test_blob_reopen, 0 },
{ "sqlite3_blob_bytes", test_blob_bytes, 0 },
{ "sqlite3_blob_close", test_blob_close, 0 },
#endif
{ "pcache_stats", test_pcache_stats, 0 },
#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY

View File

@@ -150,12 +150,11 @@ int sqlite3_blob_open(
{OP_Halt, 0, 0, 0}, /* 11 */
};
Vdbe *v = 0;
int rc = SQLITE_OK;
char *zErr = 0;
Table *pTab;
Parse *pParse;
Incrblob *pBlob;
Parse *pParse = 0;
Incrblob *pBlob = 0;
flags = !!flags; /* flags = (flags ? 1 : 0); */
*ppBlob = 0;
@@ -163,15 +162,15 @@ int sqlite3_blob_open(
sqlite3_mutex_enter(db->mutex);
pBlob = (Incrblob *)sqlite3DbMallocZero(db, sizeof(Incrblob));
if( !pBlob ) goto blob_open_out;
pParse = sqlite3StackAllocRaw(db, sizeof(*pParse));
if( pParse==0 || pBlob==0 ){
assert( db->mallocFailed );
goto blob_open_out;
}
if( !pParse ) goto blob_open_out;
do {
memset(pParse, 0, sizeof(Parse));
pParse->db = db;
sqlite3DbFree(db, zErr);
zErr = 0;
sqlite3BtreeEnterAll(db);
pTab = sqlite3LocateTable(pParse, 0, zTable, zDb);
@@ -251,11 +250,15 @@ int sqlite3_blob_open(
}
}
v = sqlite3VdbeCreate(db);
if( v ){
pBlob->pStmt = (sqlite3_stmt *)sqlite3VdbeCreate(db);
assert( pBlob->pStmt || db->mallocFailed );
if( pBlob->pStmt ){
Vdbe *v = (Vdbe *)pBlob->pStmt;
int iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
sqlite3VdbeAddOpList(v, sizeof(openBlob)/sizeof(VdbeOpList), openBlob);
/* Configure the OP_Transaction */
sqlite3VdbeChangeP1(v, 0, iDb);
sqlite3VdbeChangeP2(v, 0, flags);
@@ -298,11 +301,9 @@ int sqlite3_blob_open(
}
pBlob->flags = flags;
pBlob->pStmt = (sqlite3_stmt *)v;
pBlob->iCol = iCol;
pBlob->db = db;
sqlite3BtreeLeaveAll(db);
v = 0;
if( db->mallocFailed ){
goto blob_open_out;
}
@@ -314,7 +315,6 @@ blob_open_out:
if( rc==SQLITE_OK && db->mallocFailed==0 ){
*ppBlob = (sqlite3_blob *)pBlob;
}else{
if( v ) sqlite3VdbeFinalize(v);
if( pBlob && pBlob->pStmt ) sqlite3VdbeFinalize((Vdbe *)pBlob->pStmt);
sqlite3DbFree(db, pBlob);
}

269
test/incrblob3.test Normal file
View File

@@ -0,0 +1,269 @@
# 2010 October 20
#
# 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.
#
#***********************************************************************
#
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
sqlite3 db test.db
sqlite3_db_config_lookaside db 0 0 0
do_execsql_test incrblob3-1.1 {
CREATE TABLE blobs(k INTEGER PRIMARY KEY, v BLOB);
INSERT INTO blobs VALUES(1, zeroblob(100));
INSERT INTO blobs VALUES(2, zeroblob(100));
} {}
# Test the sqlite3_blob_reopen()/read()/write() functions.
#
do_test incrblob3-1.2 {
set ::blob [db incrblob blobs v 1]
puts $::blob "hello world"
} {}
do_test incrblob3-1.3 {
sqlite3_blob_reopen $::blob 2
puts $::blob "world hello"
} {}
do_test incrblob3-1.4 {
sqlite3_blob_reopen $::blob 1
gets $::blob
} {hello world}
do_test incrblob3-1.5 {
sqlite3_blob_reopen $::blob 2
gets $::blob
} {world hello}
do_test incrblob3-1.6 { close $::blob } {}
# Test some error conditions.
#
# incrblob3-2.1: Attempting to reopen a row that does not exist.
# incrblob3-2.2: Attempting to reopen a row that does not contain a blob
# or text value.
#
do_test incrblob3-2.1.1 {
set ::blob [db incrblob blobs v 1]
list [catch {sqlite3_blob_reopen $::blob 3} msg] $msg
} {1 SQLITE_ERROR}
do_test incrblob3-2.1.2 {
list [sqlite3_errcode db] [sqlite3_errmsg db]
} {SQLITE_ERROR {no such rowid: 3}}
do_test incrblob3-2.1.3 {
list [catch {sqlite3_blob_reopen $::blob 1} msg] $msg
} {1 SQLITE_ABORT}
do_test incrblob3-2.1.4 { close $::blob } {}
do_execsql_test incrblob3-2.2.1 {
INSERT INTO blobs VALUES(3, 42);
INSERT INTO blobs VALUES(4, 54.4);
INSERT INTO blobs VALUES(5, NULL);
}
foreach {tn rowid type} {
1 3 integer
2 4 real
3 5 null
} {
do_test incrblob3-2.2.$tn.1 {
set ::blob [db incrblob blobs v 1]
list [catch {sqlite3_blob_reopen $::blob $rowid} msg] $msg
} {1 SQLITE_ERROR}
do_test incrblob3-2.2.$tn.2 {
list [sqlite3_errcode db] [sqlite3_errmsg db]
} "SQLITE_ERROR {cannot open value of type $type}"
do_test incrblob3-2.2.$tn.3 {
list [catch {sqlite3_blob_reopen $::blob 1} msg] $msg
} {1 SQLITE_ABORT}
do_test incrblob3-2.2.$tn.4 {
list [catch {sqlite3_blob_read $::blob 0 10} msg] $msg
} {1 SQLITE_ABORT}
do_test incrblob3-2.2.$tn.5 {
list [catch {sqlite3_blob_write $::blob 0 "abcd"} msg] $msg
} {1 SQLITE_ABORT}
do_test incrblob3-2.2.$tn.4 { close $::blob } {}
}
# Test that passing NULL to sqlite3_blob_XXX() APIs returns SQLITE_MISUSE.
#
# incrblob3-3.1: sqlite3_blob_reopen()
# incrblob3-3.2: sqlite3_blob_read()
# incrblob3-3.3: sqlite3_blob_write()
# incrblob3-3.4: sqlite3_blob_bytes()
#
do_test incrblob3-3.1 {
list [catch {sqlite3_blob_reopen {} 3} msg] $msg
} {1 SQLITE_MISUSE}
do_test incrblob3-3.2 {
list [catch {sqlite3_blob_read {} 0 10} msg] $msg
} {1 SQLITE_MISUSE}
do_test incrblob3-3.3 {
list [catch {sqlite3_blob_write {} 0 "abcd"} msg] $msg
} {1 SQLITE_MISUSE}
do_test incrblob3-3.4 { sqlite3_blob_bytes {} } {0}
do_test incrblob3-3.5 { sqlite3_blob_close {} } {}
# Test out-of-range reading and writing
#
do_test incrblob3-4.1 {
set ::blob [db incrblob blobs v 1]
sqlite3_blob_bytes $::blob
} {100}
do_test incrblob3-4.2 {
list [catch { sqlite3_blob_read $::blob -1 10 } msg] $msg
} {1 SQLITE_ERROR}
do_test incrblob3-4.3 {
list [catch { sqlite3_blob_read $::blob 0 -10 } msg] $msg
} {1 SQLITE_ERROR}
do_test incrblob3-4.4 {
list [catch { sqlite3_blob_read $::blob 95 10 } msg] $msg
} {1 SQLITE_ERROR}
do_test incrblob3-4.5 {
list [catch { sqlite3_blob_write $::blob -1 "abcdefghij" 10 } msg] $msg
} {1 SQLITE_ERROR}
do_test incrblob3-4.6 {
list [catch { sqlite3_blob_write $::blob 0 "abcdefghij" -10 } msg] $msg
} {1 SQLITE_ERROR}
do_test incrblob3-4.7 {
list [catch { sqlite3_blob_write $::blob 95 "abcdefghij" } msg] $msg
} {1 SQLITE_ERROR}
do_test incrblob3-4.8 { close $::blob } {}
# Test that modifying the row a blob handle points to aborts the blob.
#
do_test incrblob3-5.1 {
set ::blob [db incrblob blobs v 1]
sqlite3_blob_bytes $::blob
} {100}
do_test incrblob3-5.2 {
execsql { UPDATE blobs SET v = '123456789012345678901234567890' WHERE k = 1 }
list [catch { sqlite3_blob_read $::blob 0 10 } msg] $msg
} {1 SQLITE_ABORT}
# Test various errors that can occur in sqlite3_blob_open():
#
# 1. Trying to open a virtual table column.
# 2. Trying to open a view column.
# 3. Trying to open a column that does not exist.
# 4. Trying to open a read/write handle on an indexed column.
# 5. Trying to open a read/write handle on the child key of an FK constraint.
#
ifcapable fts3 {
do_test incrblob3-6.1 {
execsql {
CREATE VIRTUAL TABLE ft USING fts3;
INSERT INTO ft VALUES('rules to open a column to which');
}
list [catch { db incrblob ft content 1 } msg] $msg
} {1 {cannot open virtual table: ft}}
}
ifcapable view {
do_test incrblob3-6.2 {
execsql { CREATE VIEW v1 AS SELECT * FROM blobs }
list [catch { db incrblob v1 content 1 } msg] $msg
} {1 {cannot open view: v1}}
}
do_test incrblob3-6.3 {
list [catch { db incrblob blobs content 1 } msg] $msg
} {1 {no such column: "content"}}
do_test incrblob3-6.4.1 {
execsql {
CREATE TABLE t1(a, b);
CREATE INDEX i1 ON t1(b);
INSERT INTO t1 VALUES(zeroblob(100), zeroblob(100));
}
list [catch { db incrblob t1 b 1 } msg] $msg
} {1 {cannot open indexed column for writing}}
do_test incrblob3-6.4.2 {
set ::blob [db incrblob t1 a 1]
close $::blob
} {}
do_test incrblob3-6.4.3 {
set ::blob [db incrblob -readonly t1 b 1]
close $::blob
} {}
do_test incrblob3-6.5.1 {
execsql {
CREATE TABLE p1(a PRIMARY KEY);
CREATE TABLE c1(a, b REFERENCES p1);
PRAGMA foreign_keys = 1;
INSERT INTO p1 VALUES(zeroblob(100));
INSERT INTO c1 VALUES(zeroblob(100), zeroblob(100));
}
list [catch { db incrblob c1 b 1 } msg] $msg
} {1 {cannot open foreign key column for writing}}
do_test incrblob3-6.5.2 {
set ::blob [db incrblob c1 a 1]
close $::blob
} {}
do_test incrblob3-6.5.3 {
set ::blob [db incrblob -readonly c1 b 1]
close $::blob
} {}
do_test incrblob3-6.5.4 {
execsql { PRAGMA foreign_keys = 0 }
set ::blob [db incrblob c1 b 1]
close $::blob
} {}
# Test that sqlite3_blob_open() handles transient and persistent schema
# errors correctly.
#
do_test incrblob3-7.1 {
sqlite3 db2 test.db
sqlite3_db_config_lookaside db2 0 0 0
execsql { CREATE TABLE t2(x) } db2
set ::blob [db incrblob blobs v 1]
close $::blob
} {}
db2 close
testvfs tvfs -default 1
tvfs filter xAccess
tvfs script access_method
proc access_method {args} {
set schemacookie [hexio_get_int [hexio_read test.db 40 4]]
incr schemacookie
hexio_write test.db 40 [hexio_render_int32 $schemacookie]
set dbversion [hexio_get_int [hexio_read test.db 24 4]]
incr dbversion
hexio_write test.db 24 [hexio_render_int32 $dbversion]
return ""
}
do_test incrblob3-7.2 {
sqlite3 db test.db
sqlite3_db_config_lookaside db 0 0 0
list [catch {db incrblob blobs v 1} msg] $msg
} {1 {database schema has changed}}
db close
tvfs delete
finish_test

70
test/incrblobfault.test Normal file
View File

@@ -0,0 +1,70 @@
# 2010 October 26
#
# 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.
#
#***********************************************************************
#
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix incrblobfault
do_execsql_test 1.0 {
CREATE TABLE blob(x INTEGER PRIMARY KEY, v BLOB);
INSERT INTO blob VALUES(1, 'hello world');
INSERT INTO blob VALUES(2, 'world hello');
INSERT INTO blob SELECT NULL, v FROM blob;
INSERT INTO blob SELECT NULL, v FROM blob;
INSERT INTO blob SELECT NULL, v FROM blob;
INSERT INTO blob SELECT NULL, v FROM blob;
INSERT INTO blob SELECT NULL, v FROM blob;
INSERT INTO blob SELECT NULL, v FROM blob;
INSERT INTO blob SELECT NULL, v FROM blob;
INSERT INTO blob SELECT NULL, v FROM blob;
INSERT INTO blob SELECT NULL, v FROM blob;
INSERT INTO blob SELECT NULL, v FROM blob;
}
do_faultsim_test 1 -prep {
sqlite3 db test.db
set ::blob [db incrblob blob v 1]
} -body {
if {[catch {sqlite3_blob_reopen $::blob 1000}]} {
error [sqlite3_errmsg db]
}
} -test {
faultsim_test_result {0 {}}
close $::blob
}
do_faultsim_test 2 -prep {
sqlite3 db test.db
set ::blob [db incrblob blob v 1]
} -body {
if {[catch {sqlite3_blob_reopen $::blob -1}]} {
error [sqlite3_errmsg db]
}
} -test {
faultsim_test_result {1 {no such rowid: -1}}
close $::blob
}
do_faultsim_test 3 -prep {
sqlite3 db test.db
} -body {
set ::blob [db incrblob blob v 1]
gets $::blob
} -test {
faultsim_test_result {0 {hello world}}
catch { close $::blob }
}
finish_test