Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | In the TCL bindings, if a TCL variable has a bytearray representation and the host parameter starts with @ instead of $, then always store the content as a BLOB not as a string even if a string representation is also available. (CVS 4092) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
dcb104bd41f5e992d4c84b8947cb5099 |
User & Date: | drh 2007-06-19 17:15:47.000 |
Context
2007-06-19
| ||
17:48 | Cleanup the TCL interface source code and add documentation for recently added methods on the SQLite object of TCL. (CVS 4093) (check-in: d88b79818a user: drh tags: trunk) | |
17:15 | In the TCL bindings, if a TCL variable has a bytearray representation and the host parameter starts with @ instead of $, then always store the content as a BLOB not as a string even if a string representation is also available. (CVS 4092) (check-in: dcb104bd41 user: drh tags: trunk) | |
15:23 | Change the name of the "limits.h" source file to "sqliteLimit.h". Ticket #2428. (CVS 4091) (check-in: 64bcc41f12 user: drh tags: trunk) | |
Changes
Changes to src/tclsqlite.c.
︙ | ︙ | |||
8 9 10 11 12 13 14 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** A TCL Interface to SQLite. Append this file to sqlite3.c and ** compile the whole thing to build a TCL-enabled version of SQLite. ** | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** A TCL Interface to SQLite. Append this file to sqlite3.c and ** compile the whole thing to build a TCL-enabled version of SQLite. ** ** $Id: tclsqlite.c,v 1.190 2007/06/19 17:15:47 drh Exp $ */ #include "tcl.h" #include <errno.h> /* ** Some additional include files are needed if this file is not ** appended to the amalgamation. |
︙ | ︙ | |||
1583 1584 1585 1586 1587 1588 1589 | if( nVar>sizeof(aParm)/sizeof(aParm[0]) ){ apParm = (Tcl_Obj**)Tcl_Alloc(nVar*sizeof(apParm[0])); }else{ apParm = aParm; } for(i=1; i<=nVar; i++){ const char *zVar = sqlite3_bind_parameter_name(pStmt, i); | | | > | > | 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 | if( nVar>sizeof(aParm)/sizeof(aParm[0]) ){ apParm = (Tcl_Obj**)Tcl_Alloc(nVar*sizeof(apParm[0])); }else{ apParm = aParm; } for(i=1; i<=nVar; i++){ const char *zVar = sqlite3_bind_parameter_name(pStmt, i); if( zVar!=0 && (zVar[0]=='$' || zVar[0]==':' || zVar[0]=='@') ){ Tcl_Obj *pVar = Tcl_GetVar2Ex(interp, &zVar[1], 0, 0); if( pVar ){ int n; u8 *data; char *zType = pVar->typePtr ? pVar->typePtr->name : ""; char c = zType[0]; if( c=='b' && strcmp(zType,"bytearray")==0 && (pVar->bytes==0 || zVar[0]=='@') ){ /* Only load a BLOB type if the Tcl variable is a bytearray and ** either it has no string representation or the host ** parameter name begins with "@". */ data = Tcl_GetByteArrayFromObj(pVar, &n); sqlite3_bind_blob(pStmt, i, data, n, SQLITE_STATIC); Tcl_IncrRefCount(pVar); apParm[nParm++] = pVar; }else if( (c=='b' && strcmp(zType,"boolean")==0) || (c=='i' && strcmp(zType,"int")==0) ){ Tcl_GetIntFromObj(interp, pVar, &n); |
︙ | ︙ |
Changes to test/tclsqlite.test.
︙ | ︙ | |||
11 12 13 14 15 16 17 | # This file implements regression tests for TCL interface to the # SQLite library. # # Actually, all tests are based on the TCL interface, so the main # interface is pretty well tested. This file contains some addition # tests for fringe issues that the main test suite does not cover. # | | | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | # This file implements regression tests for TCL interface to the # SQLite library. # # Actually, all tests are based on the TCL interface, so the main # interface is pretty well tested. This file contains some addition # tests for fringe issues that the main test suite does not cover. # # $Id: tclsqlite.test,v 1.58 2007/06/19 17:15:47 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Check the error messages generated by tclsqlite # if {[sqlite3 -has-codec]} { |
︙ | ︙ | |||
450 451 452 453 454 455 456 457 | do_test tcl-12.1 { unset -nocomplain a b c version set version [db version] scan $version "%d.%d.%d" a b c expr $a*1000000 + $b*1000 + $c } [sqlite3_libversion_number] finish_test | > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 | do_test tcl-12.1 { unset -nocomplain a b c version set version [db version] scan $version "%d.%d.%d" a b c expr $a*1000000 + $b*1000 + $c } [sqlite3_libversion_number] # Check to see that when bindings of the form @aaa are used instead # of $aaa, that objects with a bytearray representation are inserted # as BLOBs even if they also have a string representation. # do_test tcl-13.1 { db eval {CREATE TABLE t5(x BLOB)} set x abc123 db eval {INSERT INTO t5 VALUES($x)} db eval {SELECT typeof(x) FROM t5} } {text} do_test tcl-13.2 { binary scan $x H notUsed db eval { DELETE FROM t5; INSERT INTO t5 VALUES($x); SELECT typeof(x) FROM t5; } } {text} do_test tcl-13.3 { btree_breakpoint db eval { DELETE FROM t5; INSERT INTO t5 VALUES(@x); SELECT typeof(x) FROM t5; } } {blob} finish_test |