From: danielk1977 Date: Fri, 17 Feb 2006 12:25:14 +0000 (+0000) Subject: Ensure temp db is open before executing a pragma like "temp.cachesize = xxx". Fix... X-Git-Tag: version-3.6.10~3063 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ddfb2f036a2952aba3eeef254dfa9b7220e541f2;p=thirdparty%2Fsqlite.git Ensure temp db is open before executing a pragma like "temp.cachesize = xxx". Fix for #1682. (CVS 3104) FossilOrigin-Name: 1e4644b2369547da65fcaa9a3c8ddd206a3c82ae --- diff --git a/manifest b/manifest index 335e08dc86..80a62e0db0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Or\sthe\sSQLITE_UTF16_ALIGNED\swith\sthe\sencoding\sfield\sin\nsqlite3_create_collation\sand\sUTF16\sstrings\swill\salways\sbe\saligned\non\san\seven\sbyte\sboundary\swhen\spassed\sinto\sthe\scomparison\sfunction.\s(CVS\s3103) -D 2006-02-16T18:16:37 +C Ensure\stemp\sdb\sis\sopen\sbefore\sexecuting\sa\spragma\slike\s"temp.cachesize\s=\sxxx".\sFix\sfor\s#1682.\s(CVS\s3104) +D 2006-02-17T12:25:15 F Makefile.in 5d8dff443383918b700e495de42ec65bc1c8865b F Makefile.linux-gcc 74ba0eadf88748a9ce3fd03d2a3ede2e6715baec F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028 @@ -36,7 +36,7 @@ F src/attach.c d73a3505de3fb9e373d0a158978116c4212031d0 F src/auth.c 9ae84d2d94eb96195e04515715e08e85963e96c2 F src/btree.c 23bbfb4745e549ca224f6c933a6e9bc106d77f56 F src/btree.h 40055cfc09defd1146bc5b922399c035f969e56d -F src/build.c b46cd7d0e2daca775d9de0cba8abae1b1625caf4 +F src/build.c e0cecb858aa43d983ba7cfb9437b96107f06eda2 F src/callback.c 1bf497306c32229114f826707054df7ebe10abf2 F src/complete.c 7d1a44be8f37de125fcafd3d3a018690b3799675 F src/date.c cd2bd5d1ebc6fa12d6312f69789ae5b0a2766f2e @@ -62,7 +62,7 @@ F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b F src/pager.c c438aa5fc248e0523e80591eeae33a3993c47278 F src/pager.h 425a9e52d5404158de016799715cbc2c3d685178 F src/parse.y 6d666d60a3bb51ceeb0d30b395455a24856849b7 -F src/pragma.c 31d3e1b74cab2172807894e70c674d6a577501fd +F src/pragma.c 607b0f3b1916aa01918acd08499bd6ef21065c23 F src/prepare.c cf0fc8ebaf94409955ecb09ffeb0099c9ef44693 F src/printf.c c7d6ad9efb71c466305297a448308f467b6e2b6e F src/random.c d40f8d356cecbd351ccfab6eaedd7ec1b54f5261 @@ -70,7 +70,7 @@ F src/select.c 7d069e875d0eec05129c7e8b9c99422d7c9c6321 F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96 F src/shell.c 738f55ed75fb36731e764bfdb40756ac43b90b08 F src/sqlite.h.in 0bf6f03f9a14dde5f3a4f87471840803acaa4497 -F src/sqliteInt.h b067d282b2073c20ef143295a0fe1a2a1b204698 +F src/sqliteInt.h 0b52ba38f922dcb79ddf806aa33377620df9773c F src/table.c f64ec4fbfe333f8df925bc6ba494f55e05b0e75e F src/tclsqlite.c d9c26374b52cd47233ae0620d0a858a59b601f89 F src/test1.c 9d299609a0ce35157fe15cdf8b4c663db5d40386 @@ -212,7 +212,7 @@ F test/pager.test 6ee95e90ee8295e376e39a6c6566ef6df993601a F test/pager2.test 49c0f57c7da0b060f0486b85fdd074025caa694e F test/pager3.test 2323bf27fd5bd887b580247e5bce500ceee994b4 F test/pagesize.test 05c74ea49f790734ec1e9ab765d9bf1cce79b8f2 -F test/pragma.test 12e1b74e37964bb161f21fb8b1d3f31b2724b47e +F test/pragma.test 3e3673e42c665bf5ec1673961927ff9547a819fc F test/printf.test 9e10c74e16bf889f8495ddb3d6f5f891e75ff1b7 F test/progress.test 16496001da445e6534afb94562c286708316d82f x F test/quick.test e220b3b6e62fe4fb4e2a703ab2ba730fedfe0424 @@ -354,7 +354,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513 -P d7495be8060fe9e8fa2d2f81e215833d7085888b -R 032dc5ef4ca76c28ee2e5685cd84b988 -U drh -Z fd3c7b804d30b45bb57ec3ade082098a +P 7a1701e8c562087d364dff28cd7cad7ca4cdb5ae +R 9f6be0b8a587ac5dc16004f273a10940 +U danielk1977 +Z 5b1fc2d6ea9d692bde7c50e61899b51e diff --git a/manifest.uuid b/manifest.uuid index 8f9b543335..d461a54315 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7a1701e8c562087d364dff28cd7cad7ca4cdb5ae \ No newline at end of file +1e4644b2369547da65fcaa9a3c8ddd206a3c82ae \ No newline at end of file diff --git a/src/build.c b/src/build.c index e370477f85..7d01283842 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 @@ -2958,7 +2958,7 @@ void sqlite3RollbackTransaction(Parse *pParse){ ** 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 973a8c56e3..3f393773eb 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 @@ void sqlite3Pragma( 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 @@ void sqlite3Pragma( ** 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 e1b5614496..6589d25605 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 sqlite3ApiExit(sqlite3 *db, int); 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 *); diff --git a/test/pragma.test b/test/pragma.test index 831ea795d4..580948038e 100644 --- a/test/pragma.test +++ b/test/pragma.test @@ -12,7 +12,7 @@ # # This file implements tests for the PRAGMA command. # -# $Id: pragma.test,v 1.39 2006/02/09 16:52:24 drh Exp $ +# $Id: pragma.test,v 1.40 2006/02/17 12:25:16 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -770,6 +770,34 @@ ifcapable schema_pragmas { } {0 New_Collation 1 NOCASE 2 BINARY} } +ifcapable schema_pragmas&&tempdb { + do_test pragma-12.1 { + sqlite3 db2 test.db + execsql { + PRAGMA temp.table_info('abc'); + } db2 + } {} + db2 close + + do_test pragma-12.2 { + sqlite3 db2 test.db + execsql { + PRAGMA temp.default_cache_size = 200; + PRAGMA temp.default_cache_size; + } db2 + } {200} + db2 close + + do_test pragma-12.3 { + sqlite3 db2 test.db + execsql { + PRAGMA temp.cache_size = 400; + PRAGMA temp.cache_size; + } db2 + } {400} + db2 close +} + # Reset the sqlite3_temp_directory variable for the next run of tests: sqlite3 dbX :memory: dbX eval {PRAGMA temp_store_directory = ""}