xref: /netbsd-src/external/public-domain/sqlite/man/sqlite3_temp_directory.3 (revision 06dfa8449cb5e76c0044ec0f3badf7d5180af0f5)
1.Dd December 19, 2018
2.Dt SQLITE3_TEMP_DIRECTORY 3
3.Os
4.Sh NAME
5.Nm sqlite3_temp_directory
6.Nd Name Of The Folder Holding Temporary Files
7.Sh SYNOPSIS
8.Vt char *sqlite3_temp_directory;
9.Sh DESCRIPTION
10If this global variable is made to point to a string which is the name
11of a folder (a.k.a.
12directory), then all temporary files created by SQLite when using a
13built-in  VFS will be placed in that directory.
14If this variable is a NULL pointer, then SQLite performs a search for
15an appropriate temporary file directory.
16.Pp
17Applications are strongly discouraged from using this global variable.
18It is required to set a temporary folder on Windows Runtime (WinRT).
19But for all other platforms, it is highly recommended that applications
20neither read nor write this variable.
21This global variable is a relic that exists for backwards compatibility
22of legacy applications and should be avoided in new projects.
23.Pp
24It is not safe to read or modify this variable in more than one thread
25at a time.
26It is not safe to read or modify this variable if a database connection
27is being used at the same time in a separate thread.
28It is intended that this variable be set once as part of process initialization
29and before any SQLite interface routines have been called and that
30this variable remain unchanged thereafter.
31.Pp
32The temp_store_directory pragma may modify
33this variable and cause it to point to memory obtained from sqlite3_malloc.
34Furthermore, the temp_store_directory pragma
35always assumes that any string that this variable points to is held
36in memory obtained from sqlite3_malloc and the pragma
37may attempt to free that memory using sqlite3_free.
38Hence, if this variable is modified directly, either it should be made
39NULL or made to point to memory obtained from sqlite3_malloc
40or else the use of the temp_store_directory pragma
41should be avoided.
42Except when requested by the temp_store_directory pragma,
43SQLite does not free the memory that sqlite3_temp_directory points
44to.
45If the application wants that memory to be freed, it must do so itself,
46taking care to only do so after all database connection
47objects have been destroyed.
48.Pp
49\fBNote to Windows Runtime users:\fP  The temporary directory must be set
50prior to calling sqlite3_open or sqlite3_open_v2.
51Otherwise, various features that require the use of temporary files
52may fail.
53Here is an example of how to do this using C++ with the Windows Runtime:
54.Bd -ragged
55.Bd -literal
56LPCWSTR zPath = Windows::Storage::ApplicationData::Current->
57TemporaryFolder->Path->Data(); char zPathBuf[MAX_PATH + 1]; memset(zPathBuf,
580, sizeof(zPathBuf)); WideCharToMultiByte(CP_UTF8, 0, zPath, -1, zPathBuf,
59sizeof(zPathBuf),       NULL, NULL); sqlite3_temp_directory = sqlite3_mprintf("%s",
60zPathBuf);
61.Ed
62.Pp
63.Ed
64.Pp
65.Sh SEE ALSO
66.Xr sqlite3 3 ,
67.Xr sqlite3_malloc 3 ,
68.Xr sqlite3_open 3 ,
69.Xr sqlite3_vfs 3
70