-C Fix\sa\scomment.\s(CVS\s2184)
-D 2005-01-08T15:43:19
+C Fixes\sto\sthe\stemp_store_directory\spragma.\s(CVS\s2185)
+D 2005-01-08T15:44:26
F Makefile.in ecf441ac5ca1ccfc8748a8a9537706e69893dfa4
F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
F README a01693e454a00cc117967e3f9fdab2d4d52e9bc1
F src/os_mac.h 608fdf39eafa1ce25fc8cb223b8b0a073341d4da
F src/os_test.c 91e5f22dd89491e5e1554820e715805f43fa4ece
F src/os_test.h 6a26a4978492e4bbdbf385554958418ff02db162
-F src/os_unix.c f3835451ffa69072ea88f30cfd6f3ed12b728cfa
+F src/os_unix.c 08340c864822115bf87c6c1735780a0996278b81
F src/os_unix.h f3097815e041e82e24d92505e1ff61ba24172d13
-F src/os_win.c 39525c414e57ca3f18d860d40d6d38df85689522
+F src/os_win.c 3c0b0a3bc33318cf555a1cd130232ad1b9a5a711
F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
F src/pager.c 4a14410a4e67173bb121a919c7f2033b93822186
F src/pager.h 9eba8c53dd91eae7f3f90743b2ee242da02a9862
F src/parse.y ceba179b9703657180963568f54b0e75f33e36e1
-F src/pragma.c 0394f9361a497b7f74c1e5909bfc95a1f5bf0ce4
+F src/pragma.c 1b6f9f4caa2c441b18bf0c8793a4b4b8f3214d03
F src/printf.c 3d20b21cfecadacecac3fb7274e746cb81d3d357
F src/random.c eff68e3f257e05e81eae6c4d50a51eb88beb4ff3
F src/select.c af6ffcf0201f8f4e2697eea25689077dc61c6109
F test/pager2.test 49c0f57c7da0b060f0486b85fdd074025caa694e
F test/pager3.test 647f696a9cf7409df00a1e0047c2eb55585a1b85
F test/pagesize.test 1b826d1608fd86d2303aa895b5586052ad07eba1
-F test/pragma.test 6d6f7db667aabd7cfbb57a8daec6022f3eb68400
+F test/pragma.test 3673c0eb920cf2489410dc58f9875384cf4acdce
F test/printf.test 92ba4c510b4fc61120ffa4a01820446ed917ae57
F test/progress.test 5ddba78cb6011fba36093973cfb3ac473b8fb96a x
F test/quick.test 91e5b8ae6663dc9e3e754b271f0384f0cae706e6
F www/vdbe.tcl 095f106d93875c94b47367384ebc870517431618
F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0
F www/whentouse.tcl c3b50d3ac31c54be2a1af9b488a89d22f1e6e746
-P fb3bf68d0e83b463c7e2f95b4502ba6f8158c074
-R 7b899dfdb34524e0b647e71db3f94a04
+P 26fbac8f031b305fe98add4422ab606ed116844a
+R f87c924f62a99bca5faef617ba021d39
U drh
-Z dc33d0b51c02b0380f298c0fa7efa871
+Z 08c214dff6b3942d3cd4bb3f84fb288c
-26fbac8f031b305fe98add4422ab606ed116844a
\ No newline at end of file
+0a90eaf398aa4a689cd8326cd017951513ca748a
\ No newline at end of file
return SQLITE_OK;
}
+#ifndef SQLITE_OMIT_PAGER_PRAGMAS
/*
** Check that a given pathname is a directory and is writable
**
int sqlite3OsIsDirWritable(char *zBuf){
struct stat buf;
if( zBuf==0 ) return 0;
- if( strlen(zBuf)==0 ) return 0;
+ if( zBuf[0]==0 ) return 0;
if( stat(zBuf, &buf) ) return 0;
if( !S_ISDIR(buf.st_mode) ) return 0;
if( access(zBuf, 07) ) return 0;
return 1;
}
+#endif /* SQLITE_OMIT_PAGER_PRAGMAS */
/*
** Read data from a file into a buffer. Return SQLITE_OK if all
return res;
}
+#ifndef SQLITE_OMIT_PAGER_PRAGMAS
/*
** Check that a given pathname is a directory and is writable
**
if(! isNT() && strlen(zBuf) > MAX_PATH ) return 0;
fileAttr = GetFileAttributesA(zBuf);
if( fileAttr == 0xffffffff ) return 0;
- if( (fileAttr & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY ) return 0;
+ if( (fileAttr & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY ){
+ return 0;
+ }
return 1;
}
-
+#endif /* SQLITE_OMIT_PAGER_PRAGMAS */
/*
** Lock the file with the lock specified by parameter locktype - one
*************************************************************************
** This file contains code used to implement the PRAGMA command.
**
-** $Id: pragma.c,v 1.81 2004/12/25 01:03:14 drh Exp $
+** $Id: pragma.c,v 1.82 2005/01/08 15:44:26 drh Exp $
*/
#include "sqliteInt.h"
+#include "os.h"
#include <ctype.h>
/* Ignore this whole file if pragmas are disabled
sqlite3VdbeAddOp(v, OP_Callback, 1, 0);
}
}else{
- if( strlen(zRight)==0 ){
- /* empty path, set to default. allows os_{unix,win}.c to choose directory */
- if( sqlite3_temp_directory ){
- /* previous temp_store_directory defined, free and invalidate */
- sqlite3FreeX(sqlite3_temp_directory);
- if( db->temp_store==1 ) {
- /* temp storage is "file", so invalidate temp */
- invalidateTempStorage( pParse );
- }
- }
- sqlite3_temp_directory = 0;
+ if( zRight[0] && !sqlite3OsIsDirWritable(zRight) ){
+ sqlite3ErrorMsg(pParse, "not a writable directory");
+ goto pragma_out;
+ }
+ if( TEMP_STORE==0
+ || (TEMP_STORE==1 && db->temp_store<=1)
+ || (TEMP_STORE==2 && db->temp_store==1)
+ ){
+ invalidateTempStorage(pParse);
+ }
+ sqliteFree(sqlite3_temp_directory);
+ if( zRight[0] ){
+ sqlite3_temp_directory = zRight;
+ zRight = 0;
}else{
- /* check if previous directory defined, free and alloc if needed */
- if( sqlite3_temp_directory ){
- if( strlen(sqlite3_temp_directory) < strlen(zRight) + 1){
- sqlite3FreeX(sqlite3_temp_directory);
- sqlite3_temp_directory = sqliteMalloc( strlen(zRight) + 1 );
- if( sqlite3_temp_directory==0 ){
- goto pragma_out;
- }
- sqlite3_temp_directory[0] = '\0';
- }
- }else{
- sqlite3_temp_directory = sqliteMalloc( strlen(zRight) + 1 );
- if( sqlite3_temp_directory==0 ){
- goto pragma_out;
- }
- sqlite3_temp_directory[0] = '\0';
- }
- /* check that directory exists and is writable */
- if( sqlite3OsIsDirWritable( zRight ) ){
- strcpy(sqlite3_temp_directory, zRight);
- if( db->temp_store==1 ) {
- /* temp storage is "file", so invalidate temp */
- invalidateTempStorage( pParse );
- }
- }else{
- sqlite3ErrorMsg(pParse, "not a directory, or not writable");
- }
+ sqlite3_temp_directory = 0;
}
}
}else
#
# This file implements tests for the PRAGMA command.
#
-# $Id: pragma.test,v 1.29 2005/01/07 10:42:48 danielk1977 Exp $
+# $Id: pragma.test,v 1.30 2005/01/08 15:44:26 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
PRAGMA user_version;
}
} {-450}
-
} ; # ifcapable schema_version
# Test temp_store and temp_store_directory pragmas
#
+ifcapable pager_pragmas {
do_test pragma-9.1 {
db close
sqlite3 db test.db
}
} {}
do_test pragma-9.5 {
- execsql " \
- PRAGMA temp_store_directory='[pwd]'; \
+ set pwd [string map {' ''} [pwd]]
+ execsql "
+ PRAGMA temp_store_directory='$pwd';
"
} {}
do_test pragma-9.6 {
}
} [pwd]
do_test pragma-9.7 {
- set result ""
- catch {
- execsql {
- PRAGMA temp_store_directory='/NON/EXISTENT/PATH/FOOBAR';
- }
- } result
- set result
-} {not a directory, or not writable}
+ catchsql {
+ PRAGMA temp_store_directory='/NON/EXISTENT/PATH/FOOBAR';
+ }
+} {1 {not a writable directory}}
do_test pragma-9.8 {
execsql {
PRAGMA temp_store_directory='';
}
} {2}
do_test pragma-9.10 {
- set result ""
- catch {
- execsql " \
- PRAGMA temp_store_directory='[pwd]'; \
- SELECT * FROM temp_store_directory_test;
- "
- } result
- set result
-} {no such table: temp_store_directory_test}
-
-
+ catchsql "
+ PRAGMA temp_store_directory='$pwd';
+ SELECT * FROM temp_store_directory_test;
+ "
+} {1 {no such table: temp_store_directory_test}}
+} ;# ifcapable pager_pragmas
finish_test