| Index: third_party/sqlite/src/src/attach.c
|
| diff --git a/third_party/sqlite/src/src/attach.c b/third_party/sqlite/src/src/attach.c
|
| index 48e0a28cf8f798c7a132cb1d1bdbf7d45a5d339e..462602d8d9fa48c7854d0d59d3d43363fb831769 100644
|
| --- a/third_party/sqlite/src/src/attach.c
|
| +++ b/third_party/sqlite/src/src/attach.c
|
| @@ -10,8 +10,6 @@
|
| **
|
| *************************************************************************
|
| ** This file contains code used to implement the ATTACH and DETACH commands.
|
| -**
|
| -** $Id: attach.c,v 1.93 2009/05/31 21:21:41 drh Exp $
|
| */
|
| #include "sqliteInt.h"
|
|
|
| @@ -126,9 +124,8 @@ static void attachFunc(
|
| ** it to obtain the database schema. At this point the schema may
|
| ** or may not be initialised.
|
| */
|
| - rc = sqlite3BtreeFactory(db, zFile, 0, SQLITE_DEFAULT_CACHE_SIZE,
|
| - db->openFlags | SQLITE_OPEN_MAIN_DB,
|
| - &aNew->pBt);
|
| + rc = sqlite3BtreeOpen(zFile, db, &aNew->pBt, 0,
|
| + db->openFlags | SQLITE_OPEN_MAIN_DB);
|
| db->nDb++;
|
| if( rc==SQLITE_CONSTRAINT ){
|
| rc = SQLITE_ERROR;
|
| @@ -145,13 +142,18 @@ static void attachFunc(
|
| }
|
| pPager = sqlite3BtreePager(aNew->pBt);
|
| sqlite3PagerLockingMode(pPager, db->dfltLockMode);
|
| - sqlite3PagerJournalMode(pPager, db->dfltJournalMode);
|
| + sqlite3BtreeSecureDelete(aNew->pBt,
|
| + sqlite3BtreeSecureDelete(db->aDb[0].pBt,-1) );
|
| }
|
| - aNew->zName = sqlite3DbStrDup(db, zName);
|
| aNew->safety_level = 3;
|
| + aNew->zName = sqlite3DbStrDup(db, zName);
|
| + if( rc==SQLITE_OK && aNew->zName==0 ){
|
| + rc = SQLITE_NOMEM;
|
| + }
|
| +
|
|
|
| -#if SQLITE_HAS_CODEC
|
| - {
|
| +#ifdef SQLITE_HAS_CODEC
|
| + if( rc==SQLITE_OK ){
|
| extern int sqlite3CodecAttach(sqlite3*, int, const void*, int);
|
| extern void sqlite3CodecGetKey(sqlite3*, int, void**, int*);
|
| int nKey;
|
| @@ -168,13 +170,13 @@ static void attachFunc(
|
| case SQLITE_BLOB:
|
| nKey = sqlite3_value_bytes(argv[2]);
|
| zKey = (char *)sqlite3_value_blob(argv[2]);
|
| - sqlite3CodecAttach(db, db->nDb-1, zKey, nKey);
|
| + rc = sqlite3CodecAttach(db, db->nDb-1, zKey, nKey);
|
| break;
|
|
|
| case SQLITE_NULL:
|
| /* No key specified. Use the key from the main database */
|
| sqlite3CodecGetKey(db, 0, (void**)&zKey, &nKey);
|
| - sqlite3CodecAttach(db, db->nDb-1, zKey, nKey);
|
| + rc = sqlite3CodecAttach(db, db->nDb-1, zKey, nKey);
|
| break;
|
| }
|
| }
|
| @@ -186,11 +188,9 @@ static void attachFunc(
|
| ** we found it.
|
| */
|
| if( rc==SQLITE_OK ){
|
| - (void)sqlite3SafetyOn(db);
|
| sqlite3BtreeEnterAll(db);
|
| rc = sqlite3Init(db, &zErrDyn);
|
| sqlite3BtreeLeaveAll(db);
|
| - (void)sqlite3SafetyOff(db);
|
| }
|
| if( rc ){
|
| int iDb = db->nDb - 1;
|
| @@ -286,7 +286,7 @@ detach_error:
|
| static void codeAttach(
|
| Parse *pParse, /* The parser context */
|
| int type, /* Either SQLITE_ATTACH or SQLITE_DETACH */
|
| - FuncDef *pFunc, /* FuncDef wrapper for detachFunc() or attachFunc() */
|
| + FuncDef const *pFunc,/* FuncDef wrapper for detachFunc() or attachFunc() */
|
| Expr *pAuthArg, /* Expression to pass to authorization callback */
|
| Expr *pFilename, /* Name of database file */
|
| Expr *pDbname, /* Name of the database to use internally */
|
| @@ -362,7 +362,7 @@ attach_end:
|
| ** DETACH pDbname
|
| */
|
| void sqlite3Detach(Parse *pParse, Expr *pDbname){
|
| - static FuncDef detach_func = {
|
| + static const FuncDef detach_func = {
|
| 1, /* nArg */
|
| SQLITE_UTF8, /* iPrefEnc */
|
| 0, /* flags */
|
| @@ -372,7 +372,8 @@ void sqlite3Detach(Parse *pParse, Expr *pDbname){
|
| 0, /* xStep */
|
| 0, /* xFinalize */
|
| "sqlite_detach", /* zName */
|
| - 0 /* pHash */
|
| + 0, /* pHash */
|
| + 0 /* pDestructor */
|
| };
|
| codeAttach(pParse, SQLITE_DETACH, &detach_func, pDbname, 0, 0, pDbname);
|
| }
|
| @@ -383,7 +384,7 @@ void sqlite3Detach(Parse *pParse, Expr *pDbname){
|
| ** ATTACH p AS pDbname KEY pKey
|
| */
|
| void sqlite3Attach(Parse *pParse, Expr *p, Expr *pDbname, Expr *pKey){
|
| - static FuncDef attach_func = {
|
| + static const FuncDef attach_func = {
|
| 3, /* nArg */
|
| SQLITE_UTF8, /* iPrefEnc */
|
| 0, /* flags */
|
| @@ -393,7 +394,8 @@ void sqlite3Attach(Parse *pParse, Expr *p, Expr *pDbname, Expr *pKey){
|
| 0, /* xStep */
|
| 0, /* xFinalize */
|
| "sqlite_attach", /* zName */
|
| - 0 /* pHash */
|
| + 0, /* pHash */
|
| + 0 /* pDestructor */
|
| };
|
| codeAttach(pParse, SQLITE_ATTACH, &attach_func, p, p, pDbname, pKey);
|
| }
|
|
|