diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/auth.c | 5 | ||||
-rw-r--r-- | src/tclsqlite.c | 27 | ||||
-rw-r--r-- | src/where.c | 6 |
3 files changed, 28 insertions, 10 deletions
diff --git a/src/auth.c b/src/auth.c index ca5af14ba..933416fbd 100644 --- a/src/auth.c +++ b/src/auth.c @@ -14,7 +14,7 @@ ** systems that do not need this facility may omit it by recompiling ** the library with -DSQLITE_OMIT_AUTHORIZATION=1 ** -** $Id: auth.c,v 1.3 2003/01/13 23:27:32 drh Exp $ +** $Id: auth.c,v 1.4 2003/01/31 17:21:50 drh Exp $ */ #include "sqliteInt.h" @@ -71,6 +71,7 @@ static void sqliteAuthBadReturnCode(Parse *pParse, int rc){ " from the authorization function - should be SQLITE_OK, " "SQLITE_IGNORE, or SQLITE_DENY", 0); pParse->nErr++; + pParse->rc = SQLITE_MISUSE; } /* @@ -113,6 +114,7 @@ void sqliteAuthRead( sqliteSetString(&pParse->zErrMsg,"access to ", pTab->zName, ".", zCol, " is prohibited", 0); pParse->nErr++; + pParse->rc = SQLITE_AUTH; }else if( rc!=SQLITE_OK ){ sqliteAuthBadReturnCode(pParse, rc); } @@ -138,6 +140,7 @@ int sqliteAuthCheck( rc = db->xAuth(db->pAuthArg, code, zArg1, zArg2); if( rc==SQLITE_DENY ){ sqliteSetString(&pParse->zErrMsg, "not authorized", 0); + pParse->rc = SQLITE_AUTH; pParse->nErr++; }else if( rc!=SQLITE_OK && rc!=SQLITE_IGNORE ){ rc = SQLITE_DENY; diff --git a/src/tclsqlite.c b/src/tclsqlite.c index 2326f7533..bddcbb267 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -11,7 +11,7 @@ ************************************************************************* ** A TCL Interface to SQLite ** -** $Id: tclsqlite.c,v 1.43 2002/11/04 19:32:26 drh Exp $ +** $Id: tclsqlite.c,v 1.44 2003/01/31 17:21:50 drh Exp $ */ #ifndef NO_TCL /* Omit this whole file if TCL is unavailable */ @@ -52,6 +52,7 @@ struct SqliteDb { Tcl_Interp *interp; /* The interpreter used for this database */ char *zBusy; /* The busy callback routine */ SqlFunc *pFunc; /* List of SQL functions */ + int rc; /* Return code of most recent sqlite_exec() */ }; /* @@ -328,14 +329,15 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ int choice; static const char *DB_strs[] = { "busy", "changes", "close", - "complete", "eval", "function", - "last_insert_rowid", "open_aux_file", "timeout", - 0 + "complete", "errorcode", "eval", + "function", "last_insert_rowid", "open_aux_file", + "timeout", 0 }; enum DB_enum { DB_BUSY, DB_CHANGES, DB_CLOSE, - DB_COMPLETE, DB_EVAL, DB_FUNCTION, - DB_LAST_INSERT_ROWID, DB_OPEN_AUX_FILE, DB_TIMEOUT, + DB_COMPLETE, DB_ERRORCODE, DB_EVAL, + DB_FUNCTION, DB_LAST_INSERT_ROWID,DB_OPEN_AUX_FILE, + DB_TIMEOUT, }; if( objc<2 ){ @@ -430,6 +432,17 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ Tcl_SetBooleanObj(pResult, isComplete); break; } + + /* + ** $db errorcode + ** + ** Return the numeric error code that was returned by the most recent + ** call to sqlite_exec(). + */ + case DB_ERRORCODE: { + Tcl_SetObjResult(interp, Tcl_NewIntObj(pDb->rc)); + break; + } /* ** $db eval $sql ?array { ...code... }? @@ -483,6 +496,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ rc = sqlite_exec(pDb->db, zSql, DbEvalCallback2, pList, &zErrMsg); Tcl_SetObjResult(interp, pList); } + pDb->rc = rc; if( rc==SQLITE_ABORT ){ if( zErrMsg ) free(zErrMsg); rc = cbData.tcl_rc; @@ -571,6 +585,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ } zFilename = Tcl_GetStringFromObj(objv[2], 0); rc = sqlite_open_aux_file(pDb->db, zFilename, &zErrMsg); + pDb->rc = rc; if( rc!=0 ){ if( zErrMsg ){ Tcl_AppendResult(interp, zErrMsg, 0); diff --git a/src/where.c b/src/where.c index b99583c4c..7fa6f4171 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.71 2003/01/11 15:02:45 drh Exp $ +** $Id: where.c,v 1.72 2003/01/31 17:21:50 drh Exp $ */ #include "sqliteInt.h" @@ -62,8 +62,8 @@ static int exprSplit(int nSlot, ExprInfo *aSlot, Expr *pExpr){ aSlot[0].p = pExpr->pLeft; cnt = 1 + exprSplit(nSlot-1, &aSlot[1], pExpr->pRight); }else{ - cnt = exprSplit(nSlot, aSlot, pExpr->pRight); - cnt += exprSplit(nSlot-cnt, &aSlot[cnt], pExpr->pLeft); + cnt = exprSplit(nSlot, aSlot, pExpr->pLeft); + cnt += exprSplit(nSlot-cnt, &aSlot[cnt], pExpr->pRight); } return cnt; } |