/ Check-in [95989717]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix the shells so that they always enable the codec if it is available, even if no key is supplied. (CVS 1226)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 95989717e17d52b2306374f5cf7613c3bd4e7801
User & Date: drh 2004-02-11 10:37:23
Context
2004-02-11
16:38
Only define _FILE_OFFSET_BITS if it is not already defined. Ticket #605. (CVS 1227) check-in: 300c5543 user: drh tags: trunk
10:37
Fix the shells so that they always enable the codec if it is available, even if no key is supplied. (CVS 1226) check-in: 95989717 user: drh tags: trunk
10:35
Fix an uninitialized variable in expr.c. Ticket #604. (CVS 1225) check-in: 1673bf7c user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/shell.c.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
508
509
510
511
512
513
514
515
516
517
518
519
520

521
522
523
524
525
526
527
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** 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 $
*/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "sqlite.h"
#include <ctype.h>

................................................................................
** Make sure the database is open.  If it is not, then open it.  If
** the database fails to open, print an error message and exit.
*/
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
    p->db = sqlite_open(p->zDbFilename, 0, &zErrMsg);

    if( p->db==0 ){
      if( zErrMsg ){
        fprintf(stderr,"Unable to open database \"%s\": %s\n", 
           p->zDbFilename, zErrMsg);
      }else{
        fprintf(stderr,"Unable to open database %s\n", p->zDbFilename);
      }







|







 







<
|
|
|
<

>







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
508
509
510
511
512
513
514

515
516
517

518
519
520
521
522
523
524
525
526
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains code to implement the "sqlite" command line
** utility for accessing SQLite databases.
**
** $Id: shell.c,v 1.87 2004/02/11 10:37:23 drh Exp $
*/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "sqlite.h"
#include <ctype.h>

................................................................................
** Make sure the database is open.  If it is not, then open it.  If
** the database fails to open, print an error message and exit.
*/
static void open_db(struct callback_data *p){
  if( p->db==0 ){
    char *zErrMsg = 0;
#ifdef SQLITE_HAS_CODEC

    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", 
           p->zDbFilename, zErrMsg);
      }else{
        fprintf(stderr,"Unable to open database %s\n", p->zDbFilename);
      }

Changes to src/tclsqlite.c.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
....
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071

1072
1073
1074
1075
1076
1077
1078
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** A TCL Interface to SQLite
**
** $Id: tclsqlite.c,v 1.56 2004/02/11 02:18:07 drh Exp $
*/
#ifndef NO_TCL     /* Omit this whole file if TCL is unavailable */

#include "sqliteInt.h"
#include "tcl.h"
#include <stdlib.h>
#include <string.h>
................................................................................
  if( p==0 ){
    Tcl_SetResult(interp, "malloc failed", TCL_STATIC);
    return TCL_ERROR;
  }
  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(zFile, mode, &zErrMsg);

  if( p->db==0 ){
    Tcl_SetResult(interp, zErrMsg, TCL_VOLATILE);
    Tcl_Free((char*)p);
    free(zErrMsg);
    return TCL_ERROR;
  }
  zArg = Tcl_GetStringFromObj(objv[1], 0);







|







 







<
|
|
<

>







7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
....
1060
1061
1062
1063
1064
1065
1066

1067
1068

1069
1070
1071
1072
1073
1074
1075
1076
1077
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** A TCL Interface to SQLite
**
** $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 */

#include "sqliteInt.h"
#include "tcl.h"
#include <stdlib.h>
#include <string.h>
................................................................................
  if( p==0 ){
    Tcl_SetResult(interp, "malloc failed", TCL_STATIC);
    return TCL_ERROR;
  }
  memset(p, 0, sizeof(*p));
  zFile = Tcl_GetStringFromObj(objv[2], 0);
#ifdef SQLITE_HAS_CODEC

  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);
    free(zErrMsg);
    return TCL_ERROR;
  }
  zArg = Tcl_GetStringFromObj(objv[1], 0);