aboutsummaryrefslogtreecommitdiff
path: root/src/tclsqlite.c
diff options
context:
space:
mode:
authordanielk1977 <danielk1977@noemail.net>2004-05-22 09:21:21 +0000
committerdanielk1977 <danielk1977@noemail.net>2004-05-22 09:21:21 +0000
commit802908635d001eaa256ae0d31dbb64c93424dd1d (patch)
treefbf97f00cf16fa0494cf606d0a37b6a423bd11c4 /src/tclsqlite.c
parent28d47b57eccfb8cb19addc3d14b650ae8a4ed2c9 (diff)
downloadsqlite-802908635d001eaa256ae0d31dbb64c93424dd1d.tar.gz
sqlite-802908635d001eaa256ae0d31dbb64c93424dd1d.zip
Use the new form of the sqlite3_open() API everywhere. (CVS 1437)
FossilOrigin-Name: b449217318ade3196757bef8aaf7302634f0f9b6
Diffstat (limited to 'src/tclsqlite.c')
-rw-r--r--src/tclsqlite.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/tclsqlite.c b/src/tclsqlite.c
index 5d880f80e..a846ad6bc 100644
--- a/src/tclsqlite.c
+++ b/src/tclsqlite.c
@@ -11,7 +11,7 @@
*************************************************************************
** A TCL Interface to SQLite
**
-** $Id: tclsqlite.c,v 1.65 2004/05/11 06:17:22 danielk1977 Exp $
+** $Id: tclsqlite.c,v 1.66 2004/05/22 09:21:21 danielk1977 Exp $
*/
#ifndef NO_TCL /* Omit this whole file if TCL is unavailable */
@@ -1020,13 +1020,13 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
** correctly.
*/
static int DbMain(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
- int mode;
SqliteDb *p;
void *pKey = 0;
int nKey = 0;
const char *zArg;
char *zErrMsg;
const char *zFile;
+ const char *zOpts[2] = {0, 0};
char zBuf[80];
if( objc==2 ){
zArg = Tcl_GetStringFromObj(objv[1], 0);
@@ -1072,11 +1072,6 @@ static int DbMain(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
);
return TCL_ERROR;
}
- if( objc==3 ){
- mode = 0666;
- }else if( Tcl_GetIntFromObj(interp, objv[3], &mode)!=TCL_OK ){
- return TCL_ERROR;
- }
zErrMsg = 0;
p = (SqliteDb*)Tcl_Alloc( sizeof(*p) );
if( p==0 ){
@@ -1088,7 +1083,15 @@ static int DbMain(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
#ifdef SQLITE_HAS_CODEC
p->db = sqlite3_open_encrypted(zFile, pKey, nKey, 0, &zErrMsg);
#else
- p->db = sqlite3_open(zFile, mode, &zErrMsg);
+ if( objc>3 ){
+ zOpts[0] = Tcl_GetString(objv[3]);
+ }
+ sqlite3_open(zFile, &p->db, zOpts);
+ if( SQLITE_OK!=sqlite3_errcode(p->db) ){
+ zErrMsg = strdup(sqlite3_errmsg(p->db));
+ sqlite3_close(p->db);
+ p->db = 0;
+ }
#endif
if( p->db==0 ){
Tcl_SetResult(interp, zErrMsg, TCL_VOLATILE);