mirror of
https://github.com/sqlite/sqlite.git
synced 2025-10-24 09:53:10 +03:00
Add the ability to specify a alternative temporary file directory using the
"sqlite_temp_directory" global variable. (CVS 1885) FossilOrigin-Name: fce56ba6a3c53843fabdfad4f545e35a83a01aa9
This commit is contained in:
16
manifest
16
manifest
@@ -1,5 +1,5 @@
|
||||
C Version\s3.0.4\s(beta)\s(CVS\s1884)
|
||||
D 2004-08-09T00:26:58
|
||||
C Add\sthe\sability\sto\sspecify\sa\salternative\stemporary\sfile\sdirectory\susing\sthe\n"sqlite_temp_directory"\sglobal\svariable.\s(CVS\s1885)
|
||||
D 2004-08-14T17:10:11
|
||||
F Makefile.in 4a5e570a9e2d35b09c31b3cf01b78cea764ade4b
|
||||
F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
|
||||
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
|
||||
@@ -47,7 +47,7 @@ F src/os_mac.c 3d31e26be1411acfb7961033098631b4f3486fdf
|
||||
F src/os_mac.h 51d2445f47e182ed32d3bd6937f81070c6fd9bd4
|
||||
F src/os_test.c 6bf10100de2ca199a91fe7ac6474561c8a7166ae
|
||||
F src/os_test.h 6a26a4978492e4bbdbf385554958418ff02db162
|
||||
F src/os_unix.c d084e3443211e1556f1a33fe48580e135facbcf7
|
||||
F src/os_unix.c 3239a45dbd2f50195bfc97f1ed35cb8fe5a3f60c
|
||||
F src/os_unix.h f3097815e041e82e24d92505e1ff61ba24172d13
|
||||
F src/os_win.c 54181eb73cb4783c4241feca9eaa490768b39008
|
||||
F src/os_win.h babd4e912967c6b09088cfe38a45e8005a07ba44
|
||||
@@ -59,11 +59,11 @@ F src/printf.c 17b28a1eedfe8129b05de981719306c18c3f1327
|
||||
F src/random.c eff68e3f257e05e81eae6c4d50a51eb88beb4ff3
|
||||
F src/select.c cbed45f4af76ad7fdfc0a0df6878b2b3827ae1d4
|
||||
F src/shell.c 69d8036a8871c53603016cc6d240a3efaa9584df
|
||||
F src/sqlite.h.in c340a12b4d0521efb474dd000fba3bdfb18d76da
|
||||
F src/sqlite.h.in 7fa206b3c7740d891d087cd87c36f6885ce03e70
|
||||
F src/sqliteInt.h 251662c89dd35c4ed745681ff00758d19ffd0906
|
||||
F src/table.c 4521c278892f60e4d630788c0ea5cf4db1e75c49
|
||||
F src/tclsqlite.c cece44ee1d4427185e4ac85ddec79f31ac26965a
|
||||
F src/test1.c 9389fafc3c3a2a3b6bf4f7cffe1c7e8ccdd0be38
|
||||
F src/test1.c 56e7980918737ef6c45a6cb3afeb1b23e68ed19e
|
||||
F src/test2.c f4c2f3928f1998fd8cb75a81e33a60e025ea85d4
|
||||
F src/test3.c 94d0a2a90bccd85802488cb42c69ec8afd2e4646
|
||||
F src/test4.c c38766914e924091516030b6a8b677d849c08bf0
|
||||
@@ -242,7 +242,7 @@ F www/tclsqlite.tcl 06a86cba4d7fc88e2bcd633b57702d3d16abebb5
|
||||
F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9
|
||||
F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0
|
||||
F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
|
||||
P 72fb719bdd627694d89ea523dda3cf44537463a9
|
||||
R 90e96fde8e9b7dffc0f3f68d9146eaac
|
||||
P 98edbdd5176704a3a8cbcb19614b51c59d748fda
|
||||
R 982c1729c0a5e72a7a4f118d1decb57a
|
||||
U drh
|
||||
Z 1c62f6e94ef5d400623d97aff1d08313
|
||||
Z 0b11b5a9cffe643b71abfc4d5fdccfb3
|
||||
|
||||
@@ -1 +1 @@
|
||||
98edbdd5176704a3a8cbcb19614b51c59d748fda
|
||||
fce56ba6a3c53843fabdfad4f545e35a83a01aa9
|
||||
@@ -568,12 +568,20 @@ int sqlite3OsOpenDirectory(
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
** If the following global variable points to a string which is the
|
||||
** name of a directory, then that directory will be used to store
|
||||
** temporary files.
|
||||
*/
|
||||
const char *sqlite_temp_directory = 0;
|
||||
|
||||
/*
|
||||
** Create a temporary file name in zBuf. zBuf must be big enough to
|
||||
** hold at least SQLITE_TEMPNAME_SIZE characters.
|
||||
*/
|
||||
int sqlite3OsTempFileName(char *zBuf){
|
||||
static const char *azDirs[] = {
|
||||
0,
|
||||
"/var/tmp",
|
||||
"/usr/tmp",
|
||||
"/tmp",
|
||||
@@ -586,7 +594,9 @@ int sqlite3OsTempFileName(char *zBuf){
|
||||
int i, j;
|
||||
struct stat buf;
|
||||
const char *zDir = ".";
|
||||
azDirs[0] = sqlite_temp_directory;
|
||||
for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); i++){
|
||||
if( azDirs[i]==0 ) continue;
|
||||
if( stat(azDirs[i], &buf) ) continue;
|
||||
if( !S_ISDIR(buf.st_mode) ) continue;
|
||||
if( access(azDirs[i], 07) ) continue;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
** This header file defines the interface that the SQLite library
|
||||
** presents to client programs.
|
||||
**
|
||||
** @(#) $Id: sqlite.h.in,v 1.112 2004/08/01 00:10:45 drh Exp $
|
||||
** @(#) $Id: sqlite.h.in,v 1.113 2004/08/14 17:10:12 drh Exp $
|
||||
*/
|
||||
#ifndef _SQLITE_H_
|
||||
#define _SQLITE_H_
|
||||
@@ -1115,6 +1115,19 @@ int sqlite3_rekey(
|
||||
const void *pKey, int nKey /* The new key */
|
||||
);
|
||||
|
||||
/*
|
||||
** If the following global variable is made to point to a constant
|
||||
** string which is the name of a directory, then all temporary files
|
||||
** created by SQLite will be placed in that directory. If this variable
|
||||
** is NULL pointer, then SQLite does a search for an appropriate temporary
|
||||
** file directory.
|
||||
**
|
||||
** This variable should only be changed when there are no open databases.
|
||||
** Once sqlite3_open() has been called, this variable should not be changed
|
||||
** until all database connections are closed.
|
||||
*/
|
||||
extern const char *sqlite_temp_directory;
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* End of the 'extern "C"' block */
|
||||
#endif
|
||||
|
||||
25
src/test1.c
25
src/test1.c
@@ -13,7 +13,7 @@
|
||||
** is not included in the SQLite library. It is used for automated
|
||||
** testing of the SQLite library.
|
||||
**
|
||||
** $Id: test1.c,v 1.96 2004/07/26 12:24:23 drh Exp $
|
||||
** $Id: test1.c,v 1.97 2004/08/14 17:10:12 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include "tcl.h"
|
||||
@@ -2339,6 +2339,26 @@ static int test_sqlite3OsUnlock(
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
** Usage: sqlite3OsTempFileName
|
||||
*/
|
||||
static int test_sqlite3OsTempFileName(
|
||||
void * clientData,
|
||||
Tcl_Interp *interp,
|
||||
int objc,
|
||||
Tcl_Obj *CONST objv[]
|
||||
){
|
||||
char zFile[SQLITE_TEMPNAME_SIZE];
|
||||
int rc;
|
||||
|
||||
rc = sqlite3OsTempFileName(zFile);
|
||||
if( rc!=SQLITE_OK ){
|
||||
Tcl_SetResult(interp, (char *)errorName(rc), TCL_STATIC);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
Tcl_AppendResult(interp, zFile, 0);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
** Register commands with the TCL interpreter.
|
||||
@@ -2424,6 +2444,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
|
||||
{ "sqlite3OsOpenReadWrite",test_sqlite3OsOpenReadWrite, 0 },
|
||||
{ "sqlite3OsClose", test_sqlite3OsClose, 0 },
|
||||
{ "sqlite3OsLock", test_sqlite3OsLock, 0 },
|
||||
{ "sqlite3OsTempFileName", test_sqlite3OsTempFileName, 0 },
|
||||
|
||||
/* Custom test interfaces */
|
||||
{ "sqlite3OsUnlock", test_sqlite3OsUnlock, 0 },
|
||||
@@ -2456,5 +2477,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
|
||||
(char*)&sqlite3_os_trace, TCL_LINK_INT);
|
||||
Tcl_LinkVar(interp, "sqlite_static_bind_value",
|
||||
(char*)&sqlite_static_bind_value, TCL_LINK_STRING);
|
||||
Tcl_LinkVar(interp, "sqlite_temp_directory",
|
||||
(char*)&sqlite_temp_directory, TCL_LINK_STRING);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user