Add tests to verify that strings may use embedded zero characters.

Ticket #3056. (CVS 5018)

FossilOrigin-Name: bb0f9e92e427d4ae8ea143d3d3773c9552e63565
This commit is contained in:
drh 2008-04-16 12:58:53 +00:00
parent 4c68e6d28a
commit 10dfbbb580
5 changed files with 55 additions and 19 deletions

View File

@ -1,5 +1,5 @@
C Add\sspeed-test\sscripts\sthat\salso\sshow\sEXPLAIN\soutput.\s(CVS\s5017)
D 2008-04-16T12:57:48
C Add\stests\sto\sverify\sthat\sstrings\smay\suse\sembedded\szero\scharacters.\nTicket\s#3056.\s(CVS\s5018)
D 2008-04-16T12:58:54
F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
F Makefile.in 25b3282a4ac39388632c2fb0e044ff494d490952
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@ -144,7 +144,7 @@ F src/sqliteInt.h 625375d9327f0d79bf6f0f7864cc4a0543aec440
F src/sqliteLimit.h f435e728c6b620ef7312814d660a81f9356eb5c8
F src/table.c 2c48c575dd59b3a6c5c306bc55f51a9402cf429a
F src/tclsqlite.c 2877726bf32f7d72ff057b37ed6c93485b667ea1
F src/test1.c 8d633bcf3cd3b805c3393d58b5c1011d49b9b550
F src/test1.c ab25cb2715a9e3f1d91cf99a7280ac7d8dd478e2
F src/test2.c f0808cc643528b9620e4059ca9bda8346f526121
F src/test3.c c715b5a8a6415d7b2c67f97c394eef488b6f7e63
F src/test4.c c2c0f5dc907f1346f5d4b65eb5799f11eb9e4071
@ -212,7 +212,7 @@ F test/badutf.test d5360fc31f643d37a973ab0d8b4fb85799c3169f
F test/between.test 16b1776c6323faadb097a52d673e8e3d8be7d070
F test/bigfile.test 9a6a8346e4042d9c781ed6cb6553ac871ae30618
F test/bigrow.test f0aeb7573dcb8caaafea76454be3ade29b7fc747
F test/bind.test 261fd1603613e7f877a516d29f281c9d8c2ecf52
F test/bind.test 991d5738c64e9627c09576dc18ff6cda46075563
F test/bindxfer.test 995d2cf8df61204d748cde6960443121c4ccd2e1
F test/bitvec.test 62a512c3f7041d1df12558eb25990e5a19820571
F test/blob.test 2a38d867bdf08f9ce081776acec1ac8d4bca66be
@ -322,7 +322,7 @@ F test/fts3ao.test 0aa29dd4fc1c8d46b1f7cfe5926f7ac97551bea9
F test/fts3atoken.test 25c2070e1e8755d414bf9c8200427b277a9f99fa
F test/fts3b.test b3a25180a633873d37d86e1ccd00ed690d37237a
F test/fts3near.test 2d4dadcaac5025ab65bb87e66c45f39e92966194
F test/func.test 5227e6e6e9df33f5e771ef164f634b7d4f6d6a55
F test/func.test b9f4cd2171891c258d025b10413024bb9ebcf068
F test/fuzz.test 62fc19dd36a427777fd671b569df07166548628a
F test/fuzz2.test ea38692ce2da99ad79fe0be5eb1a452c1c4d37bb
F test/fuzz_common.tcl ff4bc2dfc465f6878f8e2d819620914365382731
@ -632,7 +632,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
P d35dea059e2cb936e4277f513f036b9b0bdfc4a5
R c0b22004b0ac521d974e7b893302fd7e
P d11f5dafdaf7c18c43615d0ac018c7d221460244
R f57a0ca58b7ca1d3113ae2507d454a38
U drh
Z 1ac53e97ed99016f506aa1047f716fd9
Z d36be6b864744b356a9ad22bb2e858e2

View File

@ -1 +1 @@
d11f5dafdaf7c18c43615d0ac018c7d221460244
bb0f9e92e427d4ae8ea143d3d3773c9552e63565

View File

@ -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.298 2008/04/15 02:36:34 drh Exp $
** $Id: test1.c,v 1.299 2008/04/16 12:58:54 drh Exp $
*/
#include "sqliteInt.h"
#include "tcl.h"
@ -2695,7 +2695,7 @@ static int test_bind_text(
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]);
value = (char*)Tcl_GetByteArrayFromObj(objv[3], &bytes);
if( Tcl_GetIntFromObj(interp, objv[4], &bytes) ) return TCL_ERROR;
rc = sqlite3_bind_text(pStmt, idx, value, bytes, SQLITE_TRANSIENT);

View File

@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this script testing the sqlite_bind API.
#
# $Id: bind.test,v 1.40 2007/05/10 17:23:12 drh Exp $
# $Id: bind.test,v 1.41 2008/04/16 12:58:54 drh Exp $
#
set testdir [file dirname $argv0]
@ -252,7 +252,7 @@ do_test bind-5.3 {
do_test bind-6.1 {
sqlite3_bind_text $VM 1 hellothere 5
sqlite3_bind_text $VM 2 ".." 1
sqlite3_bind_text $VM 3 world -1
sqlite3_bind_text $VM 3 world\000 -1
sqlite_step $VM N VALUES COLNAMES
sqlite3_reset $VM
execsql {SELECT rowid, * FROM t1}
@ -266,6 +266,29 @@ do_test bind-6.3 {
}
} {}
# Make sure zeros in a string work.
#
do_test bind-6.4 {
db eval {DELETE FROM t1}
sqlite3_bind_text $VM 1 hello\000there\000 12
sqlite3_bind_text $VM 2 hello\000there\000 11
sqlite3_bind_text $VM 3 hello\000there\000 -1
sqlite_step $VM N VALUES COLNAMES
sqlite3_reset $VM
execsql {SELECT hex(a), hex(b), hex(c) FROM t1}
} {68656C6C6F00746865726500 68656C6C6F007468657265 68656C6C6F}
do_test bind-6.5 {
execsql {SELECT * FROM t1}
} {hello hello hello}
do_test bind-6.6 {
execsql {SELECT typeof(a), typeof(b), typeof(c) FROM t1}
} {text text text}
do_test bind-6.7 {
execsql {
DELETE FROM t1;
}
} {}
# UTF-16 text
ifcapable {utf16} {
do_test bind-7.1 {
@ -279,11 +302,24 @@ ifcapable {utf16} {
do_test bind-7.2 {
execsql {SELECT typeof(a), typeof(b), typeof(c) FROM t1}
} {text text text}
do_test bind-7.3 {
db eval {DELETE FROM t1}
sqlite3_bind_text16 $VM 1 [encoding convertto unicode hi\000yall\000] 16
sqlite3_bind_text16 $VM 2 [encoding convertto unicode hi\000yall\000] 14
sqlite3_bind_text16 $VM 3 [encoding convertto unicode hi\000yall\000] -1
sqlite_step $VM N VALUES COLNAMES
sqlite3_reset $VM
execsql {SELECT * FROM t1}
} {hi hi hi}
do_test bind-7.4 {
execsql {SELECT hex(a), hex(b), hex(c) FROM t1}
} {68690079616C6C00 68690079616C6C 6869}
do_test bind-7.5 {
execsql {SELECT typeof(a), typeof(b), typeof(c) FROM t1}
} {text text text}
}
do_test bind-7.3 {
execsql {
DELETE FROM t1;
}
do_test bind-7.99 {
execsql {DELETE FROM t1;}
} {}
# Test that the 'out of range' error works.

View File

@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this file is testing built-in functions.
#
# $Id: func.test,v 1.77 2008/04/15 12:14:22 drh Exp $
# $Id: func.test,v 1.78 2008/04/16 12:58:54 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -514,7 +514,7 @@ do_test func-13.7 {
set DB [sqlite3_connection_pointer db]
set sql "SELECT test_auxdata( ? , a ) FROM t4;"
set STMT [sqlite3_prepare $DB $sql -1 TAIL]
sqlite3_bind_text $STMT 1 hello -1
sqlite3_bind_text $STMT 1 hello\000 -1
set res [list]
while { "SQLITE_ROW"==[sqlite3_step $STMT] } {
lappend res [sqlite3_column_text $STMT 0]