SQLite Forum

PRAGMA temp_store_directory
Login
Ah.  I see the problem.

You are confusing files which may be temporarily part of the database  
 - Rollback journals  
 - Master journals  
 - Write-ahead Log (WAL) files  
 - Shared-memory files  
and must live in very specific locations and must not be tampered with in any way if they exist (because they are an integral part of the database) with actual "temporary files" that are fleeting in nature and of no significance outside of their specific use at the moment, and which are automatically deleted (well, that is inaccurate, because they are temporary files so they may never actually be created):  
 - Statement journals  
 - TEMP databases  
 - Materializations of views and subqueries  
 - Transient indices  
 - Transient databases used by VACUUM  

The "temp store directory" only affects the location where these fleeting files are written.  This is because, for example, the default temp directory (/tmp perhaps) may only allow a few megabytes of space.  This might preclude being able to vacuum a database containing more that a few hundred kilobytes of data, for example.  Or perhaps prevent a query that needs a statement journal larger than available /tmp space from running.

Thus you can move the "temp store directory" to a bigger filesystem if need be.

True "temporary files" are just that, they are temporary.  The operating system will clean them up (in theory).  In *nix, a random file is basically opened and then deleted.  The file exists as an inode with no name until the file is closed, at which point the inode is freed.  Similarly on other OSes whatever mechanism is used to denote that the file is "temporary" are used to designate the file as being temporary so that when it is closed it ceases to exist.  The Operating System generates random "tempfile names" for temporary use and the Operating System guarantees that the namespace is collision free.

So the only reason you would want to change the temp store directory is because you want it to be bigger, otherwise it does nothing at all and there is only one "temp store directory" per process linkage of the SQLite3 library.