1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-07 02:42:48 +03:00

Use the new form of the sqlite3_open() API everywhere. (CVS 1437)

FossilOrigin-Name: b449217318ade3196757bef8aaf7302634f0f9b6
This commit is contained in:
danielk1977
2004-05-22 09:21:21 +00:00
parent 28d47b57ec
commit 802908635d
9 changed files with 93 additions and 188 deletions

View File

@@ -1,5 +1,5 @@
C Tests\sfor\sthe\sfunctions\sin\sutf.c.\s(CVS\s1436) C Use\sthe\snew\sform\sof\sthe\ssqlite3_open()\sAPI\severywhere.\s(CVS\s1437)
D 2004-05-22T08:16:11 D 2004-05-22T09:21:21
F Makefile.in ab7b0d5118e2da97bac66be8684a1034e3500f5a F Makefile.in ab7b0d5118e2da97bac66be8684a1034e3500f5a
F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906 F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@@ -37,7 +37,7 @@ F src/func.c cfbb7096efb58e2857e3b312a8958a12774b625a
F src/hash.c 440c2f8cb373ee1b4e13a0988489c7cd95d55b6f F src/hash.c 440c2f8cb373ee1b4e13a0988489c7cd95d55b6f
F src/hash.h 762d95f1e567664d1eafc1687de755626be962fb F src/hash.h 762d95f1e567664d1eafc1687de755626be962fb
F src/insert.c e510d62d23b4de4d901e7ccbbe7833b7fb3b9570 F src/insert.c e510d62d23b4de4d901e7ccbbe7833b7fb3b9570
F src/main.c 25f197c6e2d8dd24f993a218824c81356cf269e5 F src/main.c 6b59eda1481376df6c8e2b5fa2f24b4c101ffd72
F src/md5.c 8e39fdae6d8776b87558e91dcc94740c9b635a9c F src/md5.c 8e39fdae6d8776b87558e91dcc94740c9b635a9c
F src/os.c ddcda92f7fd71b4513c57c1ec797917f206d504e F src/os.c ddcda92f7fd71b4513c57c1ec797917f206d504e
F src/os.h 6e446a17cbeb6c2ce470683a0bb8d9c63abe8607 F src/os.h 6e446a17cbeb6c2ce470683a0bb8d9c63abe8607
@@ -48,22 +48,22 @@ F src/pragma.c aeeba7dc5bc32a6f0980e6516cb2a48a50973fab
F src/printf.c ef750e8e2398ca7e8b58be991075f08c6a7f0e53 F src/printf.c ef750e8e2398ca7e8b58be991075f08c6a7f0e53
F src/random.c eff68e3f257e05e81eae6c4d50a51eb88beb4ff3 F src/random.c eff68e3f257e05e81eae6c4d50a51eb88beb4ff3
F src/select.c 7d77a8bed7eeac23216d42fc1be006fb4352fcdc F src/select.c 7d77a8bed7eeac23216d42fc1be006fb4352fcdc
F src/shell.c 0c4662e13bfbfd3d13b066c5859cc97ad2f95d21 F src/shell.c 657623c2a3df126538d41842c2146cadbd52b154
F src/sqlite.h.in 75b6eb9eeff3e84052444584b5ad4f0d9a81b8ac F src/sqlite.h.in 56eb3abf26b35ad58bd0d7615673065572e53253
F src/sqliteInt.h 4b45892cb082f4883efb58c5e13328c42cbc7642 F src/sqliteInt.h 4b45892cb082f4883efb58c5e13328c42cbc7642
F src/table.c af14284fa36c8d41f6829e3f2819dce07d3e2de2 F src/table.c af14284fa36c8d41f6829e3f2819dce07d3e2de2
F src/tclsqlite.c fbf0fac73624ae246551a6c671f1de0235b5faa1 F src/tclsqlite.c f241854328ee2b06006efded270d84799159f760
F src/test1.c e5ba63a9a36fe34f48e3363887984c4d71dbf066 F src/test1.c 4ed0aee9bd363068b1bf6a8ad58f5c94172a5db1
F src/test2.c 6195a1ca2c8d0d2d93644e86da3289b403486872 F src/test2.c 6195a1ca2c8d0d2d93644e86da3289b403486872
F src/test3.c 5e4a6d596f982f6f47a5f9f75ede9b4a3b739968 F src/test3.c 5e4a6d596f982f6f47a5f9f75ede9b4a3b739968
F src/test4.c b3fab9aea7a8940a8a7386ce1c7e2157b09bd296 F src/test4.c b9947c319a5c023c10c1e953e6610abd571c2283
F src/test5.c 9a1f15133f6955f067c5246e564723b5f23ff221 F src/test5.c 9a1f15133f6955f067c5246e564723b5f23ff221
F src/tokenize.c e7536dd31205d5afb76c1bdc832dea009c7a3847 F src/tokenize.c e7536dd31205d5afb76c1bdc832dea009c7a3847
F src/trigger.c 11afe9abfba13a2ba142944c797c952e162d117f F src/trigger.c 11afe9abfba13a2ba142944c797c952e162d117f
F src/update.c 1a5e9182596f3ea8c7a141e308a3d2a7e5689fee F src/update.c 1a5e9182596f3ea8c7a141e308a3d2a7e5689fee
F src/utf.c 537e1c98cddc623628d44497ec02c2246cf66dea F src/utf.c 537e1c98cddc623628d44497ec02c2246cf66dea
F src/util.c 5cbeb452da09cfc7248de9948c15b14d840723f7 F src/util.c 5cbeb452da09cfc7248de9948c15b14d840723f7
F src/vacuum.c c134702e023db8778e6be59ac0ea7b02315b5476 F src/vacuum.c 8734f89742f246abd91dbd3e087fc153bddbfbad
F src/vdbe.c 3ce76c80887e5a5a0a850b2cb7ea1e353c113e36 F src/vdbe.c 3ce76c80887e5a5a0a850b2cb7ea1e353c113e36
F src/vdbe.h 391d5642a83af686f35c228fcd36cb4456d68f44 F src/vdbe.h 391d5642a83af686f35c228fcd36cb4456d68f44
F src/vdbeInt.h f40e8048d644c8389cda16f46479376f763d56e6 F src/vdbeInt.h f40e8048d644c8389cda16f46479376f763d56e6
@@ -196,7 +196,7 @@ F www/sqlite.tcl 3c83b08cf9f18aa2d69453ff441a36c40e431604
F www/tclsqlite.tcl b9271d44dcf147a93c98f8ecf28c927307abd6da F www/tclsqlite.tcl b9271d44dcf147a93c98f8ecf28c927307abd6da
F www/vdbe.tcl 9b9095d4495f37697fd1935d10e14c6015e80aa1 F www/vdbe.tcl 9b9095d4495f37697fd1935d10e14c6015e80aa1
F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4 F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
P 7f00ca5801889724c0e768961aa15f5ce0b8e7b5 P 802d65affcafffda33e2ff1cbd4e4869dc3814df
R 8442d8a6a5753b4c2931adc8bac1ca3e R 8b27932509e64c7f6375a72db4ed8e0b
U danielk1977 U danielk1977
Z 0cdfb634a2070ac93ca8bd36da159a9e Z bed47f028169fc74361bb2f3dd3e6944

View File

@@ -1 +1 @@
802d65affcafffda33e2ff1cbd4e4869dc3814df b449217318ade3196757bef8aaf7302634f0f9b6

View File

@@ -14,7 +14,7 @@
** other files are for internal use by SQLite and should not be ** other files are for internal use by SQLite and should not be
** accessed by users of the library. ** accessed by users of the library.
** **
** $Id: main.c,v 1.183 2004/05/22 08:09:40 danielk1977 Exp $ ** $Id: main.c,v 1.184 2004/05/22 09:21:21 danielk1977 Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include "os.h" #include "os.h"
@@ -1199,6 +1199,19 @@ static int openDatabase(
int rc, i; int rc, i;
char *zErrMsg = 0; char *zErrMsg = 0;
#ifdef SQLITE_TEST
for(i=0; options && options[i]; i++){
char const *zOpt = options[i];
if( 0==sqlite3StrICmp(zOpt, "-utf8") ){
def_enc = TEXT_Utf8;
}else if( 0==sqlite3StrICmp(zOpt, "-utf16le") ){
def_enc = TEXT_Utf16le;
}else if( 0==sqlite3StrICmp(zOpt, "-utf16be") ){
def_enc = TEXT_Utf16be;
}
}
#endif
/* Allocate the sqlite data structure */ /* Allocate the sqlite data structure */
db = sqliteMalloc( sizeof(sqlite) ); db = sqliteMalloc( sizeof(sqlite) );
if( db==0 ) goto opendb_out; if( db==0 ) goto opendb_out;
@@ -1257,26 +1270,12 @@ opendb_out:
/* /*
** Open a new database handle. ** Open a new database handle.
*/ */
int sqlite3_open_new( int sqlite3_open(
const char *zFilename, const char *zFilename,
sqlite3 **ppDb, sqlite3 **ppDb,
const char **options const char **options
){ ){
return openDatabase(zFilename, ppDb, options, TEXT_Utf8); return openDatabase(zFilename, ppDb, options, TEXT_Utf8);
/* return openDatabase(zFilename, ppDb, options, TEXT_Utf16le); */
}
sqlite *sqlite3_open(const char *zFilename, int mode, char **pzErrMsg){
sqlite3 *db;
int rc;
rc = sqlite3_open_new(zFilename, &db, 0);
if( rc!=SQLITE_OK && pzErrMsg ){
char *err = sqlite3_errmsg(db);
*pzErrMsg = malloc(strlen(err)+1);
strcpy(*pzErrMsg, err);
}
return db;
} }
/* /*
@@ -1298,6 +1297,8 @@ int sqlite3_open16(
return SQLITE_NOMEM; return SQLITE_NOMEM;
} }
/* FIX ME: Also need to translate the option strings */
if( SQLITE3_BIGENDIAN ){ if( SQLITE3_BIGENDIAN ){
rc = openDatabase(zFilename8, ppDb, options, TEXT_Utf16be); rc = openDatabase(zFilename8, ppDb, options, TEXT_Utf16be);
}else{ }else{
@@ -1335,115 +1336,3 @@ int sqlite3_reset_new(sqlite3_stmt *pStmt){
return rc; return rc;
} }
#if 0
/*
** sqlite3_open
**
*/
int sqlite3_open(const char *filename, sqlite3 **pDb, const char **options){
*pDb = sqlite3_open(filename, 0, &errmsg);
return (*pDb?SQLITE_OK:SQLITE_ERROR);
}
int sqlite3_open16(const void *filename, sqlite3 **pDb, const char **options){
int rc;
char * filename8;
filename8 = sqlite3utf16to8(filename, -1, SQLITE3_BIGENDIAN);
if( !filename8 ){
return SQLITE_NOMEM;
}
rc = sqlite3_open(filename8, pDb, options);
sqliteFree(filename8);
return rc;
}
/*
** sqlite3_close
**
*/
int sqlite3_close(sqlite3 *db){
return sqlite3_close(db);
}
/*
** sqlite3_errmsg
**
** TODO: !
*/
const char *sqlite3_errmsg(sqlite3 *db){
assert(!"TODO");
}
const void *sqlite3_errmsg16(sqlite3 *db){
assert(!"TODO");
}
/*
** sqlite3_errcode
**
** TODO: !
*/
int sqlite3_errcode(sqlite3 *db){
assert(!"TODO");
}
struct sqlite_stmt {
};
/*
** sqlite3_finalize
*/
int sqlite3_finalize(sqlite3_stmt *stmt){
return sqlite3_finalize(stmt, 0);
}
/*
** sqlite3_reset
*/
int sqlite3_reset(sqlite3_stmt*){
return sqlite3_reset(stmt, 0);
}
/*
** sqlite3_step
*/
int sqlite3_step(sqlite3_stmt *pStmt){
return sqlite3_step(pStmt);
}
int sqlite3_column_count(sqlite3_stmt*){
}
int sqlite3_column_type(sqlite3_stmt*,int){
}
const char *sqlite3_column_decltype(sqlite3_stmt*,int){
}
const void *sqlite3_column_decltype16(sqlite3_stmt*,int){
}
const char *sqlite3_column_name(sqlite3_stmt*,int){
}
const void *sqlite3_column_name16(sqlite3_stmt*,int){
}
const unsigned char *sqlite3_column_data(sqlite3_stmt*,int){
}
const void *sqlite3_column_data16(sqlite3_stmt*,int){
}
int sqlite3_column_bytes(sqlite3_stmt*,int){
}
long long int sqlite3_column_int(sqlite3_stmt*,int){
}
double sqlite3_column_float(sqlite3_stmt*,int){
}
#endif

View File

@@ -12,7 +12,7 @@
** This file contains code to implement the "sqlite" command line ** This file contains code to implement the "sqlite" command line
** utility for accessing SQLite databases. ** utility for accessing SQLite databases.
** **
** $Id: shell.c,v 1.96 2004/05/14 11:00:53 danielk1977 Exp $ ** $Id: shell.c,v 1.97 2004/05/22 09:21:21 danielk1977 Exp $
*/ */
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@@ -510,20 +510,17 @@ static void process_input(struct callback_data *p, FILE *in);
*/ */
static void open_db(struct callback_data *p){ static void open_db(struct callback_data *p){
if( p->db==0 ){ if( p->db==0 ){
char *zErrMsg = 0;
#ifdef SQLITE_HAS_CODEC #ifdef SQLITE_HAS_CODEC
int n = p->zKey ? strlen(p->zKey) : 0; int n = p->zKey ? strlen(p->zKey) : 0;
db = p->db = sqlite3_open_encrypted(p->zDbFilename, p->zKey, n, 0, &zErrMsg); db = p->db = sqlite3_open_encrypted(p->zDbFilename, p->zKey, n, 0, &zErrMsg);
assert(0); /* Encrypted databases are broken in SQLite 3 */
#else #else
db = p->db = sqlite3_open(p->zDbFilename, 0, &zErrMsg); sqlite3_open(p->zDbFilename, &p->db, 0);
db = p->db;
#endif #endif
if( p->db==0 ){ if( SQLITE_OK!=sqlite3_errcode(db) ){
if( zErrMsg ){ fprintf(stderr,"Unable to open database \"%s\": %s\n",
fprintf(stderr,"Unable to open database \"%s\": %s\n", p->zDbFilename, sqlite3_errmsg(db));
p->zDbFilename, zErrMsg);
}else{
fprintf(stderr,"Unable to open database %s\n", p->zDbFilename);
}
exit(1); exit(1);
} }
} }

View File

@@ -12,7 +12,7 @@
** This header file defines the interface that the SQLite library ** This header file defines the interface that the SQLite library
** presents to client programs. ** presents to client programs.
** **
** @(#) $Id: sqlite.h.in,v 1.68 2004/05/21 10:08:54 danielk1977 Exp $ ** @(#) $Id: sqlite.h.in,v 1.69 2004/05/22 09:21:21 danielk1977 Exp $
*/ */
#ifndef _SQLITE_H_ #ifndef _SQLITE_H_
#define _SQLITE_H_ #define _SQLITE_H_
@@ -58,25 +58,6 @@ extern const char sqlite3_encoding[];
*/ */
typedef struct sqlite sqlite; typedef struct sqlite sqlite;
/*
** A function to open a new sqlite database.
**
** If the database does not exist and mode indicates write
** permission, then a new database is created. If the database
** does not exist and mode does not indicate write permission,
** then the open fails, an error message generated (if errmsg!=0)
** and the function returns 0.
**
** If mode does not indicates user write permission, then the
** database is opened read-only.
**
** The Truth: As currently implemented, all databases are opened
** for writing all the time. Maybe someday we will provide the
** ability to open a database readonly. The mode parameters is
** provided in anticipation of that enhancement.
*/
sqlite *sqlite3_open(const char *filename, int mode, char **errmsg);
/* /*
** A function to close the database. ** A function to close the database.
** **
@@ -1203,12 +1184,42 @@ int sqlite3_finalize_new(sqlite3_stmt *pStmt);
*/ */
int sqlite3_reset_new(sqlite3_stmt *pStmt); int sqlite3_reset_new(sqlite3_stmt *pStmt);
int sqlite3_open_new( /*
** Open the sqlite database file "filename", where "filename" is UTF-8
** encoded. An sqlite3* handle is returned in *ppDb, even if an error
** occurs. If the database is opened (or created) successfully, then
** SQLITE_OK is returned. Otherwise an error code is returned and the
** sqlite3_errmsg() function may be used to obtain an English language
** explanation of the error.
**
** If the database file does not exist, then a new database is created
** using UTF-8 text encoding.
**
** Whether or not an error occurs when it is opened, resources associated
** with the sqlite3* handle should be released by passing it to
** sqlite3_close() when it is no longer required.
*/
int sqlite3_open(
const char *filename, /* Database filename (UTF-8) */ const char *filename, /* Database filename (UTF-8) */
sqlite3 **ppDb, /* OUT: SQLite db handle */ sqlite3 **ppDb, /* OUT: SQLite db handle */
const char **args /* Null terminated array of option strings */ const char **args /* Null terminated array of option strings */
); );
/*
** Open the sqlite database file "filename", where "filename" is native
** byte order UTF-16 encoded. An sqlite3* handle is returned in *ppDb, even
** if an error occurs. If the database is opened (or created) successfully,
** then SQLITE_OK is returned. Otherwise an error code is returned and the
** sqlite3_errmsg() function may be used to obtain an English language
** explanation of the error.
**
** If the database file does not exist, then a new database is created
** using UTF-16 text encoding in the machines native byte order.
**
** Whether or not an error occurs when it is opened, resources associated
** with the sqlite3* handle should be released by passing it to
** sqlite3_close() when it is no longer required.
*/
int sqlite3_open16( int sqlite3_open16(
const void *filename, /* Database filename (UTF-16) */ const void *filename, /* Database filename (UTF-16) */
sqlite3 **ppDb, /* OUT: SQLite db handle */ sqlite3 **ppDb, /* OUT: SQLite db handle */

View File

@@ -11,7 +11,7 @@
************************************************************************* *************************************************************************
** A TCL Interface to SQLite ** 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 */ #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. ** correctly.
*/ */
static int DbMain(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ static int DbMain(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
int mode;
SqliteDb *p; SqliteDb *p;
void *pKey = 0; void *pKey = 0;
int nKey = 0; int nKey = 0;
const char *zArg; const char *zArg;
char *zErrMsg; char *zErrMsg;
const char *zFile; const char *zFile;
const char *zOpts[2] = {0, 0};
char zBuf[80]; char zBuf[80];
if( objc==2 ){ if( objc==2 ){
zArg = Tcl_GetStringFromObj(objv[1], 0); 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; return TCL_ERROR;
} }
if( objc==3 ){
mode = 0666;
}else if( Tcl_GetIntFromObj(interp, objv[3], &mode)!=TCL_OK ){
return TCL_ERROR;
}
zErrMsg = 0; zErrMsg = 0;
p = (SqliteDb*)Tcl_Alloc( sizeof(*p) ); p = (SqliteDb*)Tcl_Alloc( sizeof(*p) );
if( p==0 ){ 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 #ifdef SQLITE_HAS_CODEC
p->db = sqlite3_open_encrypted(zFile, pKey, nKey, 0, &zErrMsg); p->db = sqlite3_open_encrypted(zFile, pKey, nKey, 0, &zErrMsg);
#else #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 #endif
if( p->db==0 ){ if( p->db==0 ){
Tcl_SetResult(interp, zErrMsg, TCL_VOLATILE); Tcl_SetResult(interp, zErrMsg, TCL_VOLATILE);

View File

@@ -13,7 +13,7 @@
** is not included in the SQLite library. It is used for automated ** is not included in the SQLite library. It is used for automated
** testing of the SQLite library. ** testing of the SQLite library.
** **
** $Id: test1.c,v 1.45 2004/05/21 10:08:54 danielk1977 Exp $ ** $Id: test1.c,v 1.46 2004/05/22 09:21:21 danielk1977 Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include "tcl.h" #include "tcl.h"
@@ -1367,7 +1367,7 @@ static int test_open(
} }
zFilename = Tcl_GetString(objv[1]); zFilename = Tcl_GetString(objv[1]);
rc = sqlite3_open_new(zFilename, &db, 0); rc = sqlite3_open(zFilename, &db, 0);
if( makePointerStr(interp, zBuf, db) ) return TCL_ERROR; if( makePointerStr(interp, zBuf, db) ) return TCL_ERROR;
Tcl_AppendResult(interp, zBuf, 0); Tcl_AppendResult(interp, zBuf, 0);

View File

@@ -11,7 +11,7 @@
************************************************************************* *************************************************************************
** Code for testing the the SQLite library in a multithreaded environment. ** Code for testing the the SQLite library in a multithreaded environment.
** **
** $Id: test4.c,v 1.5 2004/05/10 10:34:53 danielk1977 Exp $ ** $Id: test4.c,v 1.6 2004/05/22 09:21:21 danielk1977 Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include "tcl.h" #include "tcl.h"
@@ -65,7 +65,12 @@ static void *thread_main(void *pArg){
if( p->db ){ if( p->db ){
sqlite3_close(p->db); sqlite3_close(p->db);
} }
p->db = sqlite3_open(p->zFilename, 0, &p->zErr); sqlite3_open(p->zFilename, &p->db, 0);
if( SQLITE_OK!=sqlite3_errcode(p->db) ){
p->zErr = strdup(sqlite3_errmsg(p->db));
sqlite3_close(p->db);
p->db = 0;
}
p->vm = 0; p->vm = 0;
p->completed = 1; p->completed = 1;
while( p->opnum<=p->completed ) sched_yield(); while( p->opnum<=p->completed ) sched_yield();

View File

@@ -14,7 +14,7 @@
** Most of the code in this file may be omitted by defining the ** Most of the code in this file may be omitted by defining the
** SQLITE_OMIT_VACUUM macro. ** SQLITE_OMIT_VACUUM macro.
** **
** $Id: vacuum.c,v 1.15 2004/05/10 10:35:00 danielk1977 Exp $ ** $Id: vacuum.c,v 1.16 2004/05/22 09:21:21 danielk1977 Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include "os.h" #include "os.h"
@@ -266,10 +266,9 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite *db){
} }
dbNew = sqlite3_open(zTemp, 0, &zErrMsg); if( SQLITE_OK!=sqlite3_open(zTemp, &dbNew, 0) ){
if( dbNew==0 ){
sqlite3SetString(pzErrMsg, "unable to open a temporary database at ", sqlite3SetString(pzErrMsg, "unable to open a temporary database at ",
zTemp, " - ", zErrMsg, (char*)0); zTemp, " - ", sqlite3_errmsg(dbNew), (char*)0);
goto end_of_vacuum; goto end_of_vacuum;
} }
if( (rc = execsql(pzErrMsg, db, "BEGIN"))!=0 ) goto end_of_vacuum; if( (rc = execsql(pzErrMsg, db, "BEGIN"))!=0 ) goto end_of_vacuum;
@@ -313,6 +312,7 @@ end_of_vacuum:
sqliteFree(zTemp); sqliteFree(zTemp);
sqliteFree(sVac.s1.z); sqliteFree(sVac.s1.z);
sqliteFree(sVac.s2.z); sqliteFree(sVac.s2.z);
if( dbNew ) sqlite3_close(dbNew);
if( zErrMsg ) sqlite3_freemem(zErrMsg); if( zErrMsg ) sqlite3_freemem(zErrMsg);
if( rc==SQLITE_ABORT ) sVac.rc = SQLITE_ERROR; if( rc==SQLITE_ABORT ) sVac.rc = SQLITE_ERROR;
return sVac.rc; return sVac.rc;