Fix a problem with casting blobs to numeric types. (CVS 4021)
FossilOrigin-Name: f2ce727c4d798c666e95876a2b67e8a305d82e3a
This commit is contained in:
parent
63c64f3b8c
commit
5b159dc312
16
manifest
16
manifest
@ -1,5 +1,5 @@
|
||||
C Add\sspeed3.test\sfile.\sFor\stesting\sperformance\sissues\srelated\sto\soverflow\spages.\s(CVS\s4020)
|
||||
D 2007-05-17T14:45:13
|
||||
C Fix\sa\sproblem\swith\scasting\sblobs\sto\snumeric\stypes.\s(CVS\s4021)
|
||||
D 2007-05-17T16:34:44
|
||||
F Makefile.in 87b200ad9970907f76df734d29dff3d294c10935
|
||||
F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
|
||||
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
|
||||
@ -107,7 +107,7 @@ F src/sqlite3ext.h 7d0d363ea7327e817ef0dfe1b7eee1f171b72890
|
||||
F src/sqliteInt.h 58edde37943f4f8155986f0c33735ba31fc66e9f
|
||||
F src/table.c a8de75bcedf84d4060d804264b067ab3b1a3561d
|
||||
F src/tclsqlite.c f425c7583665ef78dd8397b2de0b8e0028e80ce2
|
||||
F src/test1.c 84c841e1088f743200b87581506e93f70344bd32
|
||||
F src/test1.c 0ec120a4652ee95268a5a45e1e1adee13be9ae28
|
||||
F src/test2.c 24458b17ab2f3c90cbc1c8446bd7ffe69be62f88
|
||||
F src/test3.c a280931fb40222b7c90da45eea926459beee8904
|
||||
F src/test4.c 8b784cd82de158a2317cb4ac4bc86f91ad315e25
|
||||
@ -139,7 +139,7 @@ F src/vdbeapi.c f89d6bc5264e66f44589e454fbeeee96854d0dd3
|
||||
F src/vdbeaux.c 47f483c35c27dc0806715182ef6b281320c4b9b5
|
||||
F src/vdbeblob.c 96f3572fdc45eda5be06e6372b612bc30742d9f0
|
||||
F src/vdbefifo.c 3ca8049c561d5d67cbcb94dc909ae9bb68c0bf8f
|
||||
F src/vdbemem.c 89ffe903b4de158b29fe8459f6f816d1f860d4ee
|
||||
F src/vdbemem.c 332875a5fc9ac482e00701db5487ceb7f6fc1adc
|
||||
F src/vtab.c c5ebebf615b2f29499fbe97a584c4bb342632aa0
|
||||
F src/where.c f3920748cc650fc25ac916215500bdb90dee568e
|
||||
F tclinstaller.tcl 4356d9d94d2b5ed5e68f9f0c80c4df3048dd7617
|
||||
@ -185,7 +185,7 @@ F test/capi2.test 7ecc9b342cc9ec27b53bbf95724cf2e5874fd496
|
||||
F test/capi3.test 1675323145d128e5942a9faffcfd5cf4e219a33f
|
||||
F test/capi3b.test 5f0bc94b104e11086b1103b20277e1910f59c7f4
|
||||
F test/capi3c.test 96e35164739c6fe3357fa36f0fe74bc23abc8ef7
|
||||
F test/cast.test 6f5073af07723d15d51568508739e99855fd0fa3
|
||||
F test/cast.test 0302bbc8d1be2f94da1e16ad2eb01ea356e26d18
|
||||
F test/check.test e5ea0c1a06c10e81e3434ca029e2c4a562f2b673
|
||||
F test/collate1.test e3eaa48c21e150814be1a7b852d2a8af24458d04
|
||||
F test/collate2.test 701d9651c5707024fd86a20649af9ea55e2c0eb8
|
||||
@ -493,7 +493,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
|
||||
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
|
||||
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
|
||||
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
|
||||
P 2ee959be4afa2cf05d183ff92a31dd1b5a84becf
|
||||
R da5d5d48e56670e943a5c8c37e2f8834
|
||||
P 684f765df3e8a4836f254717d175a4a7b5e7d15f
|
||||
R f94684259a9006337971361185f52b0b
|
||||
U danielk1977
|
||||
Z 35759e4b823e1a75e52d456c8ba860fe
|
||||
Z 9940d343779fd35f92c8bf0b213dac54
|
||||
|
@ -1 +1 @@
|
||||
684f765df3e8a4836f254717d175a4a7b5e7d15f
|
||||
f2ce727c4d798c666e95876a2b67e8a305d82e3a
|
14
src/test1.c
14
src/test1.c
@ -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.253 2007/05/15 03:56:50 drh Exp $
|
||||
** $Id: test1.c,v 1.254 2007/05/17 16:34:44 danielk1977 Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include "tcl.h"
|
||||
@ -2803,7 +2803,7 @@ static int test_bind_text16(
|
||||
}
|
||||
|
||||
/*
|
||||
** Usage: sqlite3_bind_blob STMT N DATA BYTES
|
||||
** Usage: sqlite3_bind_blob ?-static? STMT N DATA BYTES
|
||||
**
|
||||
** Test the sqlite3_bind_blob interface. STMT is a prepared statement.
|
||||
** N is the index of a wildcard in the prepared statement. This command
|
||||
@ -2820,19 +2820,25 @@ static int test_bind_blob(
|
||||
int bytes;
|
||||
char *value;
|
||||
int rc;
|
||||
sqlite3_destructor_type xDestructor = SQLITE_TRANSIENT;
|
||||
|
||||
if( objc!=5 ){
|
||||
if( objc!=5 && objc!=6 ){
|
||||
Tcl_AppendResult(interp, "wrong # args: should be \"",
|
||||
Tcl_GetStringFromObj(objv[0], 0), " STMT N DATA BYTES", 0);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
if( objc==6 ){
|
||||
xDestructor = SQLITE_STATIC;
|
||||
objv++;
|
||||
}
|
||||
|
||||
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[4], &bytes) ) return TCL_ERROR;
|
||||
|
||||
rc = sqlite3_bind_blob(pStmt, idx, value, bytes, SQLITE_TRANSIENT);
|
||||
rc = sqlite3_bind_blob(pStmt, idx, value, bytes, xDestructor);
|
||||
if( sqlite3TestErrCode(interp, StmtToDb(pStmt), rc) ) return TCL_ERROR;
|
||||
if( rc!=SQLITE_OK ){
|
||||
return TCL_ERROR;
|
||||
|
@ -295,6 +295,7 @@ i64 sqlite3VdbeIntValue(Mem *pMem){
|
||||
return (i64)pMem->r;
|
||||
}else if( flags & (MEM_Str|MEM_Blob) ){
|
||||
i64 value;
|
||||
pMem->flags |= MEM_Str;
|
||||
if( sqlite3VdbeChangeEncoding(pMem, SQLITE_UTF8)
|
||||
|| sqlite3VdbeMemNulTerminate(pMem) ){
|
||||
return 0;
|
||||
@ -320,6 +321,7 @@ double sqlite3VdbeRealValue(Mem *pMem){
|
||||
return (double)pMem->u.i;
|
||||
}else if( pMem->flags & (MEM_Str|MEM_Blob) ){
|
||||
double val = 0.0;
|
||||
pMem->flags |= MEM_Str;
|
||||
if( sqlite3VdbeChangeEncoding(pMem, SQLITE_UTF8)
|
||||
|| sqlite3VdbeMemNulTerminate(pMem) ){
|
||||
return 0.0;
|
||||
|
@ -11,7 +11,7 @@
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this file is testing the CAST operator.
|
||||
#
|
||||
# $Id: cast.test,v 1.6 2007/05/16 11:55:57 drh Exp $
|
||||
# $Id: cast.test,v 1.7 2007/05/17 16:34:45 danielk1977 Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@ -262,5 +262,20 @@ do_test case-3.31 {
|
||||
execsql {SELECT CAST(NULL AS numeric)}
|
||||
} {{}}
|
||||
|
||||
# Test to see if it is possible to trick SQLite into reading past
|
||||
# the end of a blob when converting it to a number.
|
||||
do_test cast-3.32.1 {
|
||||
set blob "1234567890"
|
||||
set DB [sqlite3_connection_pointer db]
|
||||
set ::STMT [sqlite3_prepare $DB {SELECT CAST(? AS real)} -1 TAIL]
|
||||
sqlite3_bind_blob -static $::STMT 1 $blob 5
|
||||
sqlite3_step $::STMT
|
||||
} {SQLITE_ROW}
|
||||
do_test cast-3.32.2 {
|
||||
sqlite3_column_int $::STMT 0
|
||||
} {12345}
|
||||
do_test cast-3.32.3 {
|
||||
sqlite3_finalize $::STMT
|
||||
} {SQLITE_OK}
|
||||
|
||||
finish_test
|
||||
|
Loading…
Reference in New Issue
Block a user