Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | The TCL interface binds variables as BLOB only if they have a bytearray representation but no text representation. Ticket #1287. (CVS 2528) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
8c99dca60aebee0ec5de9ed11350de86 |
User & Date: | drh 2005-06-25 19:31:48.000 |
Context
2005-06-25
| ||
19:42 | Documentation fixes. Ticket #1306. (CVS 2529) (check-in: 3dcdb7942e user: drh tags: trunk) | |
19:31 | The TCL interface binds variables as BLOB only if they have a bytearray representation but no text representation. Ticket #1287. (CVS 2528) (check-in: 8c99dca60a user: drh tags: trunk) | |
18:42 | Remove the blob(), text() and numeric() functions added in (2524) and replace them with the standard CAST operator. Ticket #1287. (CVS 2527) (check-in: 17631785f9 user: drh tags: trunk) | |
Changes
Changes to src/tclsqlite.c.
1 2 3 4 5 6 7 8 9 10 11 12 13 | /* ** 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. ** ************************************************************************* ** A TCL Interface to SQLite ** | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | /* ** 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. ** ************************************************************************* ** A TCL Interface to SQLite ** ** $Id: tclsqlite.c,v 1.126 2005/06/25 19:31:48 drh Exp $ */ #ifndef NO_TCL /* Omit this whole file if TCL is unavailable */ #include "sqliteInt.h" #include "hash.h" #include "tcl.h" #include <stdlib.h> |
︙ | ︙ | |||
279 280 281 282 283 284 285 | sqlite3_result_error(context, Tcl_GetStringResult(p->interp), -1); }else{ Tcl_Obj *pVar = Tcl_GetObjResult(p->interp); int n; u8 *data; char *zType = pVar->typePtr ? pVar->typePtr->name : ""; char c = zType[0]; | | > > > > > > | 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | sqlite3_result_error(context, Tcl_GetStringResult(p->interp), -1); }else{ Tcl_Obj *pVar = Tcl_GetObjResult(p->interp); 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 ){ /* Only load a BLOB type if the Tcl variable is a bytearray and ** has no string representation. */ data = Tcl_GetByteArrayFromObj(pVar, &n); sqlite3_result_blob(context, data, n, SQLITE_TRANSIENT); }else if( (c=='b' && strcmp(zType,"boolean")==0) || (c=='i' && strcmp(zType,"int")==0) ){ Tcl_GetIntFromObj(0, pVar, &n); sqlite3_result_int(context, n); }else if( c=='d' && strcmp(zType,"double")==0 ){ double r; Tcl_GetDoubleFromObj(0, pVar, &r); sqlite3_result_double(context, r); }else if( c=='w' && strcmp(zType,"wideInt")==0 ){ Tcl_WideInt v; Tcl_GetWideIntFromObj(0, pVar, &v); sqlite3_result_int64(context, v); }else{ data = Tcl_GetStringFromObj(pVar, &n); sqlite3_result_text(context, data, n, SQLITE_TRANSIENT); } } } |
︙ | ︙ | |||
920 921 922 923 924 925 926 | if( 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]; | | > > > > > > | 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 | if( 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 ){ /* Only load a BLOB type if the Tcl variable is a bytearray and ** has no string representation. */ 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); sqlite3_bind_int(pStmt, i, n); }else if( c=='d' && strcmp(zType,"double")==0 ){ double r; Tcl_GetDoubleFromObj(interp, pVar, &r); sqlite3_bind_double(pStmt, i, r); }else if( c=='w' && strcmp(zType,"wideInt")==0 ){ Tcl_WideInt v; Tcl_GetWideIntFromObj(interp, pVar, &v); sqlite3_bind_int64(pStmt, i, v); }else{ data = Tcl_GetStringFromObj(pVar, &n); sqlite3_bind_text(pStmt, i, data, n, SQLITE_STATIC); Tcl_IncrRefCount(pVar); apParm[nParm++] = pVar; } }else{ |
︙ | ︙ |
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 the printf() interface to SQLite. 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 the printf() interface to SQLite. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** ** $Id: test1.c,v 1.146 2005/06/25 19:31:48 drh Exp $ */ #include "sqliteInt.h" #include "tcl.h" #include "os.h" #include <stdlib.h> #include <string.h> |
︙ | ︙ |
Changes to test/cast.test.
|
| | | | 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.2 2005/06/25 19:31:48 drh 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 |
︙ | ︙ |
Added test/types3.test.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | # 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 interaction of SQLite manifest types # with Tcl dual-representations. # # $Id: types3.test,v 1.1 2005/06/25 19:31:48 drh Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl # A variable with only a string representation comes in as TEXT do_test types3-1.1 { set V {} append V {} concat [tcl_variable_type V] [execsql {SELECT typeof($::V)}] } {string text} # A variable with an integer representation comes in as INTEGER do_test types3-1.2 { set V [expr {1+2}] concat [tcl_variable_type V] [execsql {SELECT typeof($::V)}] } {int integer} do_test types3-1.3 { set V [expr {1+123456789012345}] concat [tcl_variable_type V] [execsql {SELECT typeof($::V)}] } {wideInt integer} # A double variable comes in as REAL do_test types3-1.4 { set V [expr {1.0+1}] concat [tcl_variable_type V] [execsql {SELECT typeof($::V)}] } {double real} # A byte-array variable comes in a BLOB if it has no string representation # or as TEXT if there is a string representation. # do_test types3-1.5 { set V [binary format a3 abc] concat [tcl_variable_type V] [execsql {SELECT typeof($::V)}] } {bytearray blob} do_test types3-1.6 { set V "abc" binary scan $V a3 x concat [tcl_variable_type V] [execsql {SELECT typeof($::V)}] } {bytearray text} # Check to make sure return values are of the right types. # do_test types3-2.1 { set V [db one {SELECT x'616263'}] tcl_variable_type V } bytearray do_test types3-2.2 { set V [db one {SELECT 123}] tcl_variable_type V } int do_test types3-2.3 { set V [db one {SELECT 1234567890123456}] tcl_variable_type V } wideInt do_test types3-2.4 { set V [db one {SELECT 1234567890123456.0}] tcl_variable_type V } double do_test types3-2.5 { set V [db one {SELECT '1234567890123456.0'}] tcl_variable_type V } {} do_test types3-2.6 { set V [db one {SELECT NULL}] tcl_variable_type V } {} finish_test |