aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/tclsqlite.c14
-rw-r--r--src/vdbeapi.c11
-rw-r--r--src/vdbemem.c13
-rw-r--r--src/where.c4
4 files changed, 30 insertions, 12 deletions
diff --git a/src/tclsqlite.c b/src/tclsqlite.c
index f928faab7..3f6d92803 100644
--- a/src/tclsqlite.c
+++ b/src/tclsqlite.c
@@ -11,7 +11,7 @@
*************************************************************************
** A TCL Interface to SQLite
**
-** $Id: tclsqlite.c,v 1.134 2005/11/26 00:25:03 drh Exp $
+** $Id: tclsqlite.c,v 1.135 2005/12/07 06:27:44 danielk1977 Exp $
*/
#ifndef NO_TCL /* Omit this whole file if TCL is unavailable */
@@ -402,7 +402,7 @@ static void tclSqlFunc(sqlite3_context *context, int argc, sqlite3_value**argv){
}
default: {
int bytes = sqlite3_value_bytes(pIn);
- pVal = Tcl_NewStringObj(sqlite3_value_text(pIn), bytes);
+ pVal = Tcl_NewStringObj((char *)sqlite3_value_text(pIn), bytes);
break;
}
}
@@ -449,8 +449,8 @@ static void tclSqlFunc(sqlite3_context *context, int argc, sqlite3_value**argv){
Tcl_GetWideIntFromObj(0, pVar, &v);
sqlite3_result_int64(context, v);
}else{
- data = Tcl_GetStringFromObj(pVar, &n);
- sqlite3_result_text(context, data, n, SQLITE_TRANSIENT);
+ data = (unsigned char *)Tcl_GetStringFromObj(pVar, &n);
+ sqlite3_result_text(context, (char *)data, n, SQLITE_TRANSIENT);
}
}
}
@@ -1285,8 +1285,8 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
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);
+ data = (unsigned char *)Tcl_GetStringFromObj(pVar, &n);
+ sqlite3_bind_text(pStmt, i, (char *)data, n, SQLITE_STATIC);
Tcl_IncrRefCount(pVar);
apParm[nParm++] = pVar;
}
@@ -1354,7 +1354,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
break;
}
default: {
- pVal = dbTextToObj(sqlite3_column_text(pStmt, i));
+ pVal = dbTextToObj((char *)sqlite3_column_text(pStmt, i));
break;
}
}
diff --git a/src/vdbeapi.c b/src/vdbeapi.c
index bc774b4f1..5d5e9cbb9 100644
--- a/src/vdbeapi.c
+++ b/src/vdbeapi.c
@@ -58,7 +58,7 @@ sqlite_int64 sqlite3_value_int64(sqlite3_value *pVal){
return sqlite3VdbeIntValue((Mem*)pVal);
}
const unsigned char *sqlite3_value_text(sqlite3_value *pVal){
- return (const char *)sqlite3ValueText(pVal, SQLITE_UTF8);
+ return (const unsigned char *)sqlite3ValueText(pVal, SQLITE_UTF8);
}
#ifndef SQLITE_OMIT_UTF16
const void *sqlite3_value_text16(sqlite3_value* pVal){
@@ -439,6 +439,7 @@ static const void *columnName(
const void *(*xFunc)(Mem*),
int useType
){
+ const void *ret;
Vdbe *p = (Vdbe *)pStmt;
int n = sqlite3_column_count(pStmt);
@@ -446,7 +447,13 @@ static const void *columnName(
return 0;
}
N += useType*n;
- return xFunc(&p->aColName[N]);
+ ret = xFunc(&p->aColName[N]);
+
+ /* A malloc may have failed inside of the xFunc() call. If this is the case,
+ ** clear the mallocFailed flag and return NULL.
+ */
+ sqlite3ClearMallocFailed();
+ return ret;
}
diff --git a/src/vdbemem.c b/src/vdbemem.c
index 8ee2e2bd2..31b0f3750 100644
--- a/src/vdbemem.c
+++ b/src/vdbemem.c
@@ -41,11 +41,21 @@ int sqlite3VdbeChangeEncoding(Mem *pMem, int desiredEnc){
#ifdef SQLITE_OMIT_UTF16
return SQLITE_ERROR;
#else
+
+ /* MemTranslate() may return SQLITE_OK or SQLITE_NOMEM. If NOMEM is returned,
+ ** then the encoding of the value may not have changed.
+ */
rc = sqlite3VdbeMemTranslate(pMem, desiredEnc);
+ assert(rc==SQLITE_OK || rc==SQLITE_NOMEM);
+ assert(rc==SQLITE_OK || pMem->enc!=desiredEnc);
+ assert(rc==SQLITE_NOMEM || pMem->enc==desiredEnc);
+
if( rc==SQLITE_NOMEM ){
+/*
sqlite3VdbeMemRelease(pMem);
pMem->flags = MEM_Null;
pMem->z = 0;
+*/
}
return rc;
#endif
@@ -746,7 +756,8 @@ const void *sqlite3ValueText(sqlite3_value* pVal, u8 enc){
}else if( !(pVal->flags&MEM_Blob) ){
sqlite3VdbeMemStringify(pVal, enc);
}
- return (const void *)(pVal->z);
+ assert(pVal->enc==enc || sqlite3Tsd()->mallocFailed);
+ return (const void *)(pVal->enc==enc ? (pVal->z) : 0);
}
/*
diff --git a/src/where.c b/src/where.c
index d952d078f..d643bde05 100644
--- a/src/where.c
+++ b/src/where.c
@@ -16,7 +16,7 @@
** so is applicable. Because this module is responsible for selecting
** indices, you might also think of this module as the "query optimizer".
**
-** $Id: where.c,v 1.186 2005/12/06 12:53:01 danielk1977 Exp $
+** $Id: where.c,v 1.187 2005/12/07 06:27:44 danielk1977 Exp $
*/
#include "sqliteInt.h"
@@ -521,7 +521,7 @@ static int isLikeOrGlob(
return 0;
}
sqlite3DequoteExpr(pRight);
- z = pRight->token.z;
+ z = (char *)pRight->token.z;
for(cnt=0; (c=z[cnt])!=0 && c!=wc[0] && c!=wc[1] && c!=wc[2]; cnt++){}
if( cnt==0 || 255==(u8)z[cnt] ){
return 0;