Documentation
¶
Overview ¶
Package dbpath names a SQLite database file the one way every handle on it will agree on.
SQLite coordinates the connections to a WAL-mode database through files whose names it derives from the path it was given (the -wal and -shm files, and on Windows the lock identity). Two handles that reach one file by different paths (a symlink, another spelling, a relative path, a different case on a case-insensitive file system, a hard link) can derive different names, each then believes it owns the WAL, and the database is corrupted: https://sqlite.org/howtocorrupt.html ("Multiple links to the same file", "Symlinks"). Canonical gives the path with symlinks resolved and made absolute, which removes every alias but a hard link; a hard link has no canonical name, so Canonical refuses a file with more than one.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrHardLinked = errors.New("dbpath: the database file has more than one hard link")
ErrHardLinked is wrapped by the error Canonical returns for a file with more than one hard link.
Functions ¶
func Canonical ¶
Canonical returns path with symlinks resolved and made absolute, keeping any "?query" and "file:" prefix; an in-memory path is returned as is. A file that does not exist is created empty first when create is true (SQLite takes an empty file for a new database, and the file needs to exist to be resolved), and left as the cleaned absolute path otherwise. It fails with an error wrapping ErrHardLinked for a file with more than one hard link.
func CheckLinks ¶
CheckLinks returns an error wrapping ErrHardLinked if the file at path has more than one hard link. A file whose links cannot be counted (it does not exist, or the platform cannot say) passes.
Types ¶
This section is empty.