/ Check-in [0bec7ebf]
Login

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

Overview
Comment:Do not segfault in the CLI if sqlite3_open() fails to create a database connection object. Ticket #3096. (CVS 5084)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 0bec7ebf41e9f52d3ef0449e27e3d631abfe948b
User & Date: drh 2008-05-05 16:27:24
Context
2008-05-05
16:56
Better error messages when trying to open a large file using a version of SQLite that omits large file support. Tickets #3096 and #3094. (CVS 5085) check-in: bdd89cd2 user: drh tags: trunk
16:27
Do not segfault in the CLI if sqlite3_open() fails to create a database connection object. Ticket #3096. (CVS 5084) check-in: 0bec7ebf user: drh tags: trunk
16:23
If an IO error occurs while locking the database and checking the cache validity, unlock the database before returning. Ticket #3030. (CVS 5083) check-in: 4ad18091 user: danielk1977 tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/shell.c.

     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains code to implement the "sqlite" command line
    13     13   ** utility for accessing SQLite databases.
    14     14   **
    15         -** $Id: shell.c,v 1.177 2008/04/15 18:50:02 pweilbacher Exp $
           15  +** $Id: shell.c,v 1.178 2008/05/05 16:27:24 drh Exp $
    16     16   */
    17     17   #include <stdlib.h>
    18     18   #include <string.h>
    19     19   #include <stdio.h>
    20     20   #include <assert.h>
    21     21   #include "sqlite3.h"
    22     22   #include <ctype.h>
................................................................................
   951    951   ** Make sure the database is open.  If it is not, then open it.  If
   952    952   ** the database fails to open, print an error message and exit.
   953    953   */
   954    954   static void open_db(struct callback_data *p){
   955    955     if( p->db==0 ){
   956    956       sqlite3_open(p->zDbFilename, &p->db);
   957    957       db = p->db;
   958         -    sqlite3_create_function(db, "shellstatic", 0, SQLITE_UTF8, 0,
   959         -        shellstaticFunc, 0, 0);
   960         -    if( SQLITE_OK!=sqlite3_errcode(db) ){
          958  +    if( db && sqlite3_errcode(db)==SQLITE_OK ){
          959  +      sqlite3_create_function(db, "shellstatic", 0, SQLITE_UTF8, 0,
          960  +          shellstaticFunc, 0, 0);
          961  +    }
          962  +    if( db==0 || SQLITE_OK!=sqlite3_errcode(db) ){
   961    963         fprintf(stderr,"Unable to open database \"%s\": %s\n", 
   962    964             p->zDbFilename, sqlite3_errmsg(db));
   963    965         exit(1);
   964    966       }
   965    967   #ifndef SQLITE_OMIT_LOAD_EXTENSION
   966    968       sqlite3_enable_load_extension(p->db, 1);
   967    969   #endif