Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix a problem with casting blobs to numeric types. (CVS 4021) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
f2ce727c4d798c666e95876a2b67e8a3 |
User & Date: | danielk1977 2007-05-17 16:34:44.000 |
Context
2007-05-17
| ||
16:38 | Bring the autoconf based build system up to date with the recent changes. #2366, #2367 and #2368. (CVS 4022) (check-in: ae644bc7aa user: danielk1977 tags: trunk) | |
16:34 | Fix a problem with casting blobs to numeric types. (CVS 4021) (check-in: f2ce727c4d user: danielk1977 tags: trunk) | |
14:45 | Add speed3.test file. For testing performance issues related to overflow pages. (CVS 4020) (check-in: 684f765df3 user: danielk1977 tags: trunk) | |
Changes
Changes to src/test1.c.
︙ | ︙ | |||
9 10 11 12 13 14 15 | ** May you share freely, never taking more than you give. ** ************************************************************************* ** Code for testing all sorts of SQLite interfaces. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** | | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ** May you share freely, never taking more than you give. ** ************************************************************************* ** Code for testing all sorts of SQLite interfaces. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** ** $Id: test1.c,v 1.254 2007/05/17 16:34:44 danielk1977 Exp $ */ #include "sqliteInt.h" #include "tcl.h" #include "os.h" #include <stdlib.h> #include <string.h> |
︙ | ︙ | |||
2799 2800 2801 2802 2803 2804 2805 | } #endif /* SQLITE_OMIT_UTF16 */ return TCL_OK; } /* | | > | > > > > > | | 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 | } #endif /* SQLITE_OMIT_UTF16 */ return TCL_OK; } /* ** 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 ** binds a BLOB to the wildcard. The BLOB is BYTES bytes in size. */ static int test_bind_blob( void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ sqlite3_stmt *pStmt; int idx; int bytes; char *value; int rc; sqlite3_destructor_type xDestructor = SQLITE_TRANSIENT; 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, xDestructor); if( sqlite3TestErrCode(interp, StmtToDb(pStmt), rc) ) return TCL_ERROR; if( rc!=SQLITE_OK ){ return TCL_ERROR; } return TCL_OK; } |
︙ | ︙ |
Changes to src/vdbemem.c.
︙ | ︙ | |||
291 292 293 294 295 296 297 298 299 300 301 302 303 304 | int flags = pMem->flags; if( flags & MEM_Int ){ return pMem->u.i; }else if( flags & MEM_Real ){ return (i64)pMem->r; }else if( flags & (MEM_Str|MEM_Blob) ){ i64 value; if( sqlite3VdbeChangeEncoding(pMem, SQLITE_UTF8) || sqlite3VdbeMemNulTerminate(pMem) ){ return 0; } assert( pMem->z ); sqlite3Atoi64(pMem->z, &value); return value; | > | 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 | int flags = pMem->flags; if( flags & MEM_Int ){ return pMem->u.i; }else if( flags & MEM_Real ){ 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; } assert( pMem->z ); sqlite3Atoi64(pMem->z, &value); return value; |
︙ | ︙ | |||
316 317 318 319 320 321 322 323 324 325 326 327 328 329 | double sqlite3VdbeRealValue(Mem *pMem){ if( pMem->flags & MEM_Real ){ return pMem->r; }else if( pMem->flags & MEM_Int ){ return (double)pMem->u.i; }else if( pMem->flags & (MEM_Str|MEM_Blob) ){ double val = 0.0; if( sqlite3VdbeChangeEncoding(pMem, SQLITE_UTF8) || sqlite3VdbeMemNulTerminate(pMem) ){ return 0.0; } assert( pMem->z ); sqlite3AtoF(pMem->z, &val); return val; | > | 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 | double sqlite3VdbeRealValue(Mem *pMem){ if( pMem->flags & MEM_Real ){ return pMem->r; }else if( pMem->flags & MEM_Int ){ 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; } assert( pMem->z ); sqlite3AtoF(pMem->z, &val); return val; |
︙ | ︙ |
Changes to test/cast.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2005 June 25 # # 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. The # focus of this file is testing the CAST operator. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2005 June 25 # # 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. The # focus of this file is testing the CAST operator. # # $Id: cast.test,v 1.7 2007/05/17 16:34:45 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Only run these tests if the build includes the CAST operator ifcapable !cast { finish_test |
︙ | ︙ | |||
258 259 260 261 262 263 264 265 266 | execsql {SELECT CAST(CAST(x'39323233333732303336383534373734383030' AS real) AS integer)} } 9223372036854774784 } do_test case-3.31 { execsql {SELECT CAST(NULL AS numeric)} } {{}} finish_test | > > > > > > > > > > > > > > > | 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | execsql {SELECT CAST(CAST(x'39323233333732303336383534373734383030' AS real) AS integer)} } 9223372036854774784 } 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 |