|
SQLITE_EXTERN char *sqlite3_data_directory;
如果这个全局变量指向一个目录名字符串,那么所有指定相对路径的数据库文件和SQLite使用内置的windows VFS时创建或访问的数据库文件都将是相对这个目录。如果这个变量是一个NULL指针,那么SQLite假设所有指定相对路径的数据库文件都是相对进程的当前目录。只有windows VFS使用这个全局变量,unx VFS会忽略这个值。
If this global variable is made to point to a string which is
the name of a folder (a.k.a. directory), then all database files
specified with a relative pathname and created or accessed by
SQLite when using a built-in windows VFS will be assumed
to be relative to that directory. If this variable is a NULL
pointer, then SQLite assumes that all database files specified
with a relative pathname are relative to the current directory
for the process. Only the windows VFS makes use of this global
variable; it is ignored by the unix VFS.
在数据库连接打开后修改这个变量值会导致数据库损坏。
Changing the value of this variable while a database connection is
open can result in a corrupt database.
同时在一个以上的线程中修改或读取这个变量是不安全的。如果在其他的线程中已经使用了数据库连接,那么这时修改或读取这个变量是不安全的。这个变量被设计为只在进程初始化、调用其他任何SQLite接口之前执行一次,而在后续的过程中不会再修改这个变量。
It is not safe to read or modify this variable in more than one
thread at a time. It is not safe to read or modify this variable
if a database connection is being used at the same time in a separate
thread.
It is intended that this variable be set once
as part of process initialization and before any SQLite interface
routines have been called and that this variable remain unchanged
thereafter.
data_store_directory pragma可以修改这个变量,并使之指向一块从sqlite3_malloc获取的内存。另外data_store_directory pragma会假设这变量指定的字符串一定是存储在从sqlite3_malloc获取的内存中,并且会使用sqlite3_free来释放内存。因此,如果直接修改这个变量,那么要么设置为NULL,要么指向从sqlite3_malloc中分配的内存。否则,使用data_store_directory pragma可能会失效。
The data_store_directory pragma may modify this variable and cause
it to point to memory obtained from sqlite3_malloc. Furthermore,
the data_store_directory pragma always assumes that any string
that this variable points to is held in memory obtained from
sqlite3_malloc and the pragma may attempt to free that memory
using sqlite3_free.
Hence, if this variable is modified directly, either it should be
made NULL or made to point to memory obtained from sqlite3_malloc
or else the use of the data_store_directory pragma should be avoided.
另行参见Objects、Constants和Functions的列表。
See also lists of
Objects,
Constants, and
Functions.