Wouldn't be easier to simply add a parameter to sqlite3_initialize()? E.g., a char const pointer to the tmp directory? That, if null, defaults to something reasonable as James mentioned?
Maybe I am oversensitive, but I found strange I have to use setenv to setup a command line option about "where to put tmp files" in my program... On Tue, Aug 18, 2015 at 11:02 PM, James K. Lowden <jklowden at schemamania.org> wrote: > On Sat, 15 Aug 2015 01:17:28 +0100 > Simon Slavin <slavins at bigfraud.org> wrote: > >> > BTW, Posix is almost silent on the question. It says TMPDIR will >> > define the location of a temporary store, but not how. >> >> I'm okay if the documentation simply says something like ... >> >> For Darwin (Mac), it's always /tmp/ >> For Linux, see the TMPDIR environment variable >> For Windows see [whatever it is] > > Agreed, although IIUC it could be simpler than that, see next. > >> However I suspect things may be more complicated than that. For >> instance, does .NET respect the OS's choice of temporary directory no >> matter which OS it's running under ? I have no idea. > > What I'm suggesting is that there is no "OS's choice", really. > > There are a few functions in the C standard library, e.g. tmpfile(3), > that may consult the environment. The variable's name varies by > implementation. Some implementations, notably GNU's (if the > documentation is correct), do not consult the environment. > > I would guess .NET is written atop the Win32 API and uses > GetTempFileName or somesuch. That uses GetTempPath, whose return value > is affected by TMP and TEMP. > (https://msdn.microsoft.com/en-us/library/windows/desktop/aa364992 > (v=vs.85).aspx). > > GetTempPath and tmpnam(3) on Windows both honor TMP, but the fallback > policies differ. So it's not really a question of what the OS's choice > is, because the *OS* offers no "temporary file" function. It's really a > question of which library function is called, and how that function is > implemented. > > But none of that matters unless those functions are used. An > application -- or library, as in SQLite's case -- need not use them, > which in any case aren't all that helpful. AIUI SQLite does *not* use > those functions, but rather has its own way to determine where temporary > files go. In that case the rule could be quite simple and > OS-independent. For instance, > > 1. Use "SQLITE_TMPDIR" if defined > 2. Use current working directory otherwise > > where the value is set by sqlite3_initialize and cannot be changed > thereafter. > > --jkl > > _______________________________________________ > sqlite-users mailing list > sqlite-users at mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users