aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2001-11-09 13:41:09 +0000
committerdrh <drh@noemail.net>2001-11-09 13:41:09 +0000
commitce927065c21c89a019ff8601da8ae64b473f048d (patch)
treee6f545fefbdce72d8e5146c0349a9fc59650ffe8 /src
parent487ab3ca18834979fe1a3e08ba03296caa2b518e (diff)
downloadsqlite-ce927065c21c89a019ff8601da8ae64b473f048d.tar.gz
sqlite-ce927065c21c89a019ff8601da8ae64b473f048d.zip
Bug fixes. (CVS 306)
FossilOrigin-Name: 84997fda33fd6ce93b821d3da3a7251cf60e06ec
Diffstat (limited to 'src')
-rw-r--r--src/tclsqlite.c35
-rw-r--r--src/test3.c4
-rw-r--r--src/where.c3
3 files changed, 24 insertions, 18 deletions
diff --git a/src/tclsqlite.c b/src/tclsqlite.c
index 4806a51d9..a604afc08 100644
--- a/src/tclsqlite.c
+++ b/src/tclsqlite.c
@@ -11,7 +11,7 @@
*************************************************************************
** A TCL Interface to SQLite
**
-** $Id: tclsqlite.c,v 1.27 2001/10/22 02:58:10 drh Exp $
+** $Id: tclsqlite.c,v 1.28 2001/11/09 13:41:10 drh Exp $
*/
#ifndef NO_TCL /* Omit this whole file if TCL is unavailable */
@@ -19,6 +19,7 @@
#include "tcl.h"
#include <stdlib.h>
#include <string.h>
+#include <assert.h>
/*
** If TCL uses UTF-8 and SQLite is configured to use iso8859, then we
@@ -50,7 +51,7 @@ struct CallbackData {
Tcl_Interp *interp; /* The TCL interpreter */
char *zArray; /* The array into which data is written */
Tcl_Obj *pCode; /* The code to execute for each row */
- int once; /* Set only for the first invocation of callback */
+ int once; /* Set for first callback only */
int tcl_rc; /* Return code from TCL script */
int nColName; /* Number of entries in the azColName[] array */
char **azColName; /* Column names translated to UTF-8 */
@@ -74,26 +75,29 @@ static int DbEvalCallback(
int i, rc;
Tcl_DString dCol;
Tcl_DStringInit(&dCol);
- if( azCol==0 || (cbData->once && cbData->zArray[0]) ){
- Tcl_SetVar2(cbData->interp, cbData->zArray, "*", "", 0);
- if( azCol ){
- cbData->azColName = malloc( nCol*sizeof(char*) );
- if( cbData->azColName==0 ){ return 1; }
+ if( cbData->azColName==0 ){
+ assert( cbData->once );
+ cbData->once = 0;
+ if( cbData->zArray[0] ){
+ Tcl_SetVar2(cbData->interp, cbData->zArray, "*", "", 0);
}
+ cbData->azColName = malloc( nCol*sizeof(char*) );
+ if( cbData->azColName==0 ){ return 1; }
cbData->nColName = nCol;
for(i=0; i<nCol; i++){
Tcl_ExternalToUtfDString(NULL, azN[i], -1, &dCol);
- if( azCol ){
- cbData->azColName[i] = malloc( Tcl_DStringLength(&dCol) + 1);
- if( cbData->azColName[i] ){
- strcpy(cbData->azColName[i], Tcl_DStringValue(&dCol));
- }
+ cbData->azColName[i] = malloc( Tcl_DStringLength(&dCol) + 1 );
+ if( cbData->azColName[i] ){
+ strcpy(cbData->azColName[i], Tcl_DStringValue(&dCol));
+ }else{
+ return 1;
+ }
+ if( cbData->zArray[0] ){
+ Tcl_SetVar2(cbData->interp, cbData->zArray, "*",
+ Tcl_DStringValue(&dCol), TCL_LIST_ELEMENT|TCL_APPEND_VALUE);
}
- Tcl_SetVar2(cbData->interp, cbData->zArray, "*", Tcl_DStringValue(&dCol),
- TCL_LIST_ELEMENT|TCL_APPEND_VALUE);
Tcl_DStringFree(&dCol);
}
- cbData->once = 0;
}
if( azCol!=0 ){
if( cbData->zArray[0] ){
@@ -414,6 +418,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
if( cbData.azColName[i] ) free(cbData.azColName[i]);
}
free(cbData.azColName);
+ cbData.azColName = 0;
}
#endif
return rc;
diff --git a/src/test3.c b/src/test3.c
index 978631159..54f946269 100644
--- a/src/test3.c
+++ b/src/test3.c
@@ -13,7 +13,7 @@
** is not included in the SQLite library. It is used for automated
** testing of the SQLite library.
**
-** $Id: test3.c,v 1.12 2001/09/23 02:35:53 drh Exp $
+** $Id: test3.c,v 1.13 2001/11/09 13:41:10 drh Exp $
*/
#include "sqliteInt.h"
#include "pager.h"
@@ -589,6 +589,8 @@ static int btree_move_to(
Tcl_AppendResult(interp, errorName(rc), 0);
return TCL_ERROR;
}
+ if( res<0 ) res = -1;
+ if( res>0 ) res = 1;
sprintf(zBuf,"%d",res);
Tcl_AppendResult(interp, zBuf, 0);
return SQLITE_OK;
diff --git a/src/where.c b/src/where.c
index 9efbef043..ba4f46ec8 100644
--- a/src/where.c
+++ b/src/where.c
@@ -13,7 +13,7 @@
** the WHERE clause of SQL statements. Also found here are subroutines
** to generate VDBE code to evaluate expressions.
**
-** $Id: where.c,v 1.26 2001/11/08 00:45:22 drh Exp $
+** $Id: where.c,v 1.27 2001/11/09 13:41:10 drh Exp $
*/
#include "sqliteInt.h"
@@ -409,7 +409,6 @@ WhereInfo *sqliteWhereBegin(
if( goDirect ){
/* Case 1: We can directly reference a single row using the ROWID field.
*/
- cont = brk;
for(k=0; k<nExpr; k++){
if( aExpr[k].p==0 ) continue;
if( aExpr[k].idxLeft==idx