aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2004-02-11 10:37:23 +0000
committerdrh <drh@noemail.net>2004-02-11 10:37:23 +0000
commiteb8ed70db540f4da50d3959ad6d413362fb0c1e3 (patch)
treeb4ee874628a6d29da79455b005cd82c6355ec592 /src
parent7e26d7509419ec076d498ebcf13dcde84c8f16b6 (diff)
downloadsqlite-eb8ed70db540f4da50d3959ad6d413362fb0c1e3.tar.gz
sqlite-eb8ed70db540f4da50d3959ad6d413362fb0c1e3.zip
Fix the shells so that they always enable the codec if it is available,
even if no key is supplied. (CVS 1226) FossilOrigin-Name: 95989717e17d52b2306374f5cf7613c3bd4e7801
Diffstat (limited to 'src')
-rw-r--r--src/shell.c11
-rw-r--r--src/tclsqlite.c9
2 files changed, 9 insertions, 11 deletions
diff --git a/src/shell.c b/src/shell.c
index e73b6a3a8..55438e8d6 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -12,7 +12,7 @@
** This file contains code to implement the "sqlite" command line
** utility for accessing SQLite databases.
**
-** $Id: shell.c,v 1.86 2004/02/11 02:18:07 drh Exp $
+** $Id: shell.c,v 1.87 2004/02/11 10:37:23 drh Exp $
*/
#include <stdlib.h>
#include <string.h>
@@ -512,12 +512,11 @@ static void open_db(struct callback_data *p){
if( p->db==0 ){
char *zErrMsg = 0;
#ifdef SQLITE_HAS_CODEC
- if( p->zKey && p->zKey[0] ){
- int n = strlen(p->zKey);
- p->db = sqlite_open_encrypted(p->zDbFilename, p->zKey, n, &zErrMsg);
- }else
-#endif
+ int n = p->zKey ? strlen(p->zKey) : 0;
+ p->db = sqlite_open_encrypted(p->zDbFilename, p->zKey, n, &zErrMsg);
+#else
p->db = sqlite_open(p->zDbFilename, 0, &zErrMsg);
+#endif
if( p->db==0 ){
if( zErrMsg ){
fprintf(stderr,"Unable to open database \"%s\": %s\n",
diff --git a/src/tclsqlite.c b/src/tclsqlite.c
index 39f3514ce..1857d50ab 100644
--- a/src/tclsqlite.c
+++ b/src/tclsqlite.c
@@ -11,7 +11,7 @@
*************************************************************************
** A TCL Interface to SQLite
**
-** $Id: tclsqlite.c,v 1.56 2004/02/11 02:18:07 drh Exp $
+** $Id: tclsqlite.c,v 1.57 2004/02/11 10:37:23 drh Exp $
*/
#ifndef NO_TCL /* Omit this whole file if TCL is unavailable */
@@ -1064,11 +1064,10 @@ static int DbMain(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
memset(p, 0, sizeof(*p));
zFile = Tcl_GetStringFromObj(objv[2], 0);
#ifdef SQLITE_HAS_CODEC
- if( nKey>0 ){
- p->db = sqlite_open_encrypted(zFile, pKey, nKey, &zErrMsg);
- }else
-#endif
+ p->db = sqlite_open_encrypted(zFile, pKey, nKey, &zErrMsg);
+#else
p->db = sqlite_open(zFile, mode, &zErrMsg);
+#endif
if( p->db==0 ){
Tcl_SetResult(interp, zErrMsg, TCL_VOLATILE);
Tcl_Free((char*)p);