Test sqlite3_bind_blob(). (CVS 1475)
FossilOrigin-Name: 42247b2fb0c94e75a432b3e067fff9a1be328fc8
This commit is contained in:
parent
3fd0a736bf
commit
49e4643ee8
13
manifest
13
manifest
@ -1,5 +1,5 @@
|
||||
C A\scouple\sof\stest\scases\sand\sfixes\sfor\sblob\sliterals.\s(CVS\s1474)
|
||||
D 2004-05-27T13:35:20
|
||||
C Test\ssqlite3_bind_blob().\s(CVS\s1475)
|
||||
D 2004-05-27T13:55:27
|
||||
F Makefile.in ab7b0d5118e2da97bac66be8684a1034e3500f5a
|
||||
F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
|
||||
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
|
||||
@ -59,7 +59,7 @@ F src/sqlite.h.in cda883efb11c6f767eaf3fea06b3e3419d9cfe7f
|
||||
F src/sqliteInt.h 9c528cc7a41efafb0443655d29eafd10d8378952
|
||||
F src/table.c af14284fa36c8d41f6829e3f2819dce07d3e2de2
|
||||
F src/tclsqlite.c 877d0b96013a25b03ed6bd2d32917c42e84403bc
|
||||
F src/test1.c 08da53d31d5b3eb11ac988f933fc6efa508712e4
|
||||
F src/test1.c 70bf9b1702123ad5085337e302679a02382dad09
|
||||
F src/test2.c 6195a1ca2c8d0d2d93644e86da3289b403486872
|
||||
F src/test3.c 5e4a6d596f982f6f47a5f9f75ede9b4a3b739968
|
||||
F src/test4.c 34848a9fd31aa65857b20a8bfc03aff77d8c3426
|
||||
@ -84,6 +84,7 @@ F test/auth.test 5c4d95cdaf539c0c236e20ce1f71a93e7dde9185
|
||||
F test/bigfile.test ea904b853ce2d703b16c5ce90e2b54951bc1ae81
|
||||
F test/bigrow.test 8ab252dba108f12ad64e337b0f2ff31a807ac578
|
||||
F test/bind.test 4f5a19e84077b61ea797644b4942bb98b17bdd42
|
||||
F test/blob.test b6474275536614352d6e1c729f23a18ba1082ae9
|
||||
F test/btree.test 08e4093c78d2bc1d54e27266f8d17fed14751125
|
||||
F test/btree2.test aa4a6d05b1ea90b1acaf83ba89039dd302a88635
|
||||
F test/btree4.test 3797b4305694c7af6828675b0f4b1424b8ca30e4
|
||||
@ -205,7 +206,7 @@ F www/sqlite.tcl 3c83b08cf9f18aa2d69453ff441a36c40e431604
|
||||
F www/tclsqlite.tcl b9271d44dcf147a93c98f8ecf28c927307abd6da
|
||||
F www/vdbe.tcl 9b9095d4495f37697fd1935d10e14c6015e80aa1
|
||||
F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
|
||||
P b5d5f0ad717ef43a9714dd1cc40e20d1b94a3e58
|
||||
R 7c513f920546909cc1b3f1b4f4017169
|
||||
P 6d552af67cf6fa6935373ba39de5c47ebf613eb9
|
||||
R b03d381cd4bf5f980eaccd167389fb15
|
||||
U danielk1977
|
||||
Z b0c4aedb51c268e31583548cc1d9df58
|
||||
Z 09411564a306f0b03eed4cc55d237508
|
||||
|
@ -1 +1 @@
|
||||
6d552af67cf6fa6935373ba39de5c47ebf613eb9
|
||||
42247b2fb0c94e75a432b3e067fff9a1be328fc8
|
@ -13,7 +13,7 @@
|
||||
** is not included in the SQLite library. It is used for automated
|
||||
** testing of the SQLite library.
|
||||
**
|
||||
** $Id: test1.c,v 1.63 2004/05/27 10:31:10 danielk1977 Exp $
|
||||
** $Id: test1.c,v 1.64 2004/05/27 13:55:27 danielk1977 Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include "tcl.h"
|
||||
@ -1060,7 +1060,7 @@ static int test_bind_blob(
|
||||
if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;
|
||||
if( Tcl_GetIntFromObj(interp, objv[2], &idx) ) return TCL_ERROR;
|
||||
value = Tcl_GetString(objv[3]);
|
||||
if( Tcl_GetIntFromObj(interp, objv[2], &bytes) ) return TCL_ERROR;
|
||||
if( Tcl_GetIntFromObj(interp, objv[4], &bytes) ) return TCL_ERROR;
|
||||
|
||||
rc = sqlite3_bind_blob(pStmt, idx, value, bytes, 1);
|
||||
if( rc!=SQLITE_OK ){
|
||||
|
120
test/blob.test
Normal file
120
test/blob.test
Normal file
@ -0,0 +1,120 @@
|
||||
# 2001 September 15
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#***********************************************************************
|
||||
# This file implements regression tests for SQLite library.
|
||||
#
|
||||
# $Id: blob.test,v 1.1 2004/05/27 13:55:27 danielk1977 Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
proc bin_to_hex {blob} {
|
||||
set bytes {}
|
||||
binary scan $blob \c* bytes
|
||||
set bytes2 [list]
|
||||
foreach b $bytes {lappend bytes2 [format %02X [expr $b & 0xFF]]}
|
||||
join $bytes2 {}
|
||||
}
|
||||
|
||||
# Simplest possible case. Specify a blob literal
|
||||
do_test blob-1.0 {
|
||||
set blob [execsql {SELECT X'01020304'}]
|
||||
bin_to_hex [lindex $blob 0]
|
||||
} {01020304}
|
||||
do_test blob-1.1 {
|
||||
set blob [execsql {SELECT x'ABCDEF'}]
|
||||
bin_to_hex [lindex $blob 0]
|
||||
} {ABCDEF}
|
||||
do_test blob-1.2 {
|
||||
set blob [execsql {SELECT x''}]
|
||||
bin_to_hex [lindex $blob 0]
|
||||
} {}
|
||||
do_test blob-1.3 {
|
||||
set blob [execsql {SELECT x'abcdEF12'}]
|
||||
bin_to_hex [lindex $blob 0]
|
||||
} {ABCDEF12}
|
||||
|
||||
# Try some syntax errors in blob literals.
|
||||
do_test blob-1.4 {
|
||||
catchsql {SELECT X'01020k304', 100}
|
||||
} {1 {unrecognized token: "X'01020"}}
|
||||
do_test blob-1.5 {
|
||||
catchsql {SELECT X'01020, 100}
|
||||
} {1 {unrecognized token: "X'01020"}}
|
||||
do_test blob-1.6 {
|
||||
catchsql {SELECT X'01020 100'}
|
||||
} {1 {unrecognized token: "X'01020"}}
|
||||
do_test blob-1.7 {
|
||||
catchsql {SELECT X'01001'}
|
||||
} {1 {unrecognized token: "X'01001'"}}
|
||||
|
||||
# Insert a blob into a table and retrieve it.
|
||||
do_test blob-2.0 {
|
||||
execsql {
|
||||
CREATE TABLE t1(a BLOB, b BLOB);
|
||||
INSERT INTO t1 VALUES(X'123456', x'7890ab');
|
||||
INSERT INTO t1 VALUES(X'CDEF12', x'345678');
|
||||
}
|
||||
set blobs [execsql {SELECT * FROM t1}]
|
||||
set blobs2 [list]
|
||||
foreach b $blobs {lappend blobs2 [bin_to_hex $b]}
|
||||
set blobs2
|
||||
} {123456 7890AB CDEF12 345678}
|
||||
|
||||
# An index on a blob column
|
||||
do_test blob-2.1 {
|
||||
execsql {
|
||||
CREATE INDEX i1 ON t1(a);
|
||||
}
|
||||
set blobs [execsql {SELECT * FROM t1}]
|
||||
set blobs2 [list]
|
||||
foreach b $blobs {lappend blobs2 [bin_to_hex $b]}
|
||||
set blobs2
|
||||
} {123456 7890AB CDEF12 345678}
|
||||
do_test blob-2.2 {
|
||||
set blobs [execsql {SELECT * FROM t1 where a = X'123456'}]
|
||||
set blobs2 [list]
|
||||
foreach b $blobs {lappend blobs2 [bin_to_hex $b]}
|
||||
set blobs2
|
||||
} {123456 7890AB}
|
||||
do_test blob-2.3 {
|
||||
set blobs [execsql {SELECT * FROM t1 where a = X'CDEF12'}]
|
||||
set blobs2 [list]
|
||||
foreach b $blobs {lappend blobs2 [bin_to_hex $b]}
|
||||
set blobs2
|
||||
} {CDEF12 345678}
|
||||
do_test blob-2.4 {
|
||||
set blobs [execsql {SELECT * FROM t1 where a = X'CD12'}]
|
||||
set blobs2 [list]
|
||||
foreach b $blobs {lappend blobs2 [bin_to_hex $b]}
|
||||
set blobs2
|
||||
} {}
|
||||
|
||||
# Try to bind a blob value to a prepared statement.
|
||||
do_test blob-3.0 {
|
||||
set DB [sqlite db2 test.db]
|
||||
set STMT [sqlite3_prepare $DB "DELETE FROM t1 WHERE a = ?" -1 DUMMY]
|
||||
sqlite3_bind_blob $STMT 1 "\x12\x34\x56" 3
|
||||
sqlite3_step $STMT
|
||||
} {SQLITE_DONE}
|
||||
do_test blob-3.1 {
|
||||
sqlite3_finalize $STMT
|
||||
db2 close
|
||||
} {}
|
||||
do_test blob-2.3 {
|
||||
set blobs [execsql {SELECT * FROM t1}]
|
||||
set blobs2 [list]
|
||||
foreach b $blobs {lappend blobs2 [bin_to_hex $b]}
|
||||
set blobs2
|
||||
} {CDEF12 345678}
|
||||
|
||||
finish_test
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user