Ensure temp db is open before executing a pragma like "temp.cachesize = xxx". Fix for #1682. (CVS 3104)
FossilOrigin-Name: 1e4644b2369547da65fcaa9a3c8ddd206a3c82ae
diff --git a/src/build.c b/src/build.c
index e370477..7d01283 100644
--- a/src/build.c
+++ b/src/build.c
@@ -22,7 +22,7 @@
** COMMIT
** ROLLBACK
**
-** $Id: build.c,v 1.386 2006/02/10 18:08:09 drh Exp $
+** $Id: build.c,v 1.387 2006/02/17 12:25:15 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@@ -2958,7 +2958,7 @@
** Make sure the TEMP database is open and available for use. Return
** the number of errors. Leave any error messages in the pParse structure.
*/
-static int sqlite3OpenTempDatabase(Parse *pParse){
+int sqlite3OpenTempDatabase(Parse *pParse){
sqlite3 *db = pParse->db;
if( db->aDb[1].pBt==0 && !pParse->explain ){
int rc = sqlite3BtreeFactory(db, 0, 0, MAX_PAGES, &db->aDb[1].pBt);
diff --git a/src/pragma.c b/src/pragma.c
index 973a8c5..3f39377 100644
--- a/src/pragma.c
+++ b/src/pragma.c
@@ -11,7 +11,7 @@
*************************************************************************
** This file contains code used to implement the PRAGMA command.
**
-** $Id: pragma.c,v 1.118 2006/02/11 01:25:51 drh Exp $
+** $Id: pragma.c,v 1.119 2006/02/17 12:25:16 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "os.h"
@@ -227,6 +227,13 @@
if( iDb<0 ) return;
pDb = &db->aDb[iDb];
+ /* If the temp database has been explicitly named as part of the
+ ** pragma, make sure it is open.
+ */
+ if( iDb==1 && sqlite3OpenTempDatabase(pParse) ){
+ return;
+ }
+
zLeft = sqlite3NameFromToken(pId);
if( !zLeft ) return;
if( minusFlag ){
@@ -948,10 +955,12 @@
** Reset the safety level, in case the fullfsync flag or synchronous
** setting changed.
*/
+#ifndef SQLITE_OMIT_PAGER_PRAGMAS
if( db->autoCommit ){
sqlite3BtreeSetSafetyLevel(pDb->pBt, pDb->safety_level,
(db->flags&SQLITE_FullFSync)!=0);
}
+#endif
}
pragma_out:
sqliteFree(zLeft);
diff --git a/src/sqliteInt.h b/src/sqliteInt.h
index e1b5614..6589d25 100644
--- a/src/sqliteInt.h
+++ b/src/sqliteInt.h
@@ -11,7 +11,7 @@
*************************************************************************
** Internal interface definitions for SQLite.
**
-** @(#) $Id: sqliteInt.h,v 1.484 2006/02/16 18:16:37 drh Exp $
+** @(#) $Id: sqliteInt.h,v 1.485 2006/02/17 12:25:16 danielk1977 Exp $
*/
#ifndef _SQLITEINT_H_
#define _SQLITEINT_H_
@@ -1743,6 +1743,7 @@
int sqlite3MallocFailed(void);
void sqlite3FailedMalloc(void);
void sqlite3AbortOtherActiveVdbes(sqlite3 *, Vdbe *);
+int sqlite3OpenTempDatabase(Parse *);
#ifndef SQLITE_OMIT_SHARED_CACHE
void sqlite3TableLock(Parse *, int, int, u8, const char *);