xref: /netbsd-src/external/public-domain/sqlite/man/sqlite3_file_control.3 (revision b9988867a8ad969c45a52aa7628bc932ec98d46b)
1.Dd January 24, 2024
2.Dt SQLITE3_FILE_CONTROL 3
3.Os
4.Sh NAME
5.Nm sqlite3_file_control
6.Nd low-Level control of database files
7.Sh SYNOPSIS
8.In sqlite3.h
9.Ft int
10.Fo sqlite3_file_control
11.Fa "sqlite3*"
12.Fa "const char *zDbName"
13.Fa "int op"
14.Fa "void*"
15.Fc
16.Sh DESCRIPTION
17The
18.Fn sqlite3_file_control
19interface makes a direct call to the xFileControl method for the sqlite3_io_methods
20object associated with a particular database identified by the second
21argument.
22The name of the database is "main" for the main database or "temp"
23for the TEMP database, or the name that appears after the AS keyword
24for databases that are added using the ATTACH SQL command.
25A NULL pointer can be used in place of "main" to refer to the main
26database file.
27The third and fourth parameters to this routine are passed directly
28through to the second and third parameters of the xFileControl method.
29The return value of the xFileControl method becomes the return value
30of this routine.
31.Pp
32A few opcodes for
33.Fn sqlite3_file_control
34are handled directly by the SQLite core and never invoke the sqlite3_io_methods.xFileControl
35method.
36The SQLITE_FCNTL_FILE_POINTER value for the
37op parameter causes a pointer to the underlying sqlite3_file
38object to be written into the space pointed to by the 4th parameter.
39The SQLITE_FCNTL_JOURNAL_POINTER works
40similarly except that it returns the sqlite3_file object
41associated with the journal file instead of the main database.
42The SQLITE_FCNTL_VFS_POINTER opcode returns
43a pointer to the underlying sqlite3_vfs object for the file.
44The SQLITE_FCNTL_DATA_VERSION returns the
45data version counter from the pager.
46.Pp
47If the second parameter (zDbName) does not match the name of any open
48database file, then SQLITE_ERROR is returned.
49This error code is not remembered and will not be recalled by
50.Fn sqlite3_errcode
51or
52.Fn sqlite3_errmsg .
53The underlying xFileControl method might also return SQLITE_ERROR.
54There is no way to distinguish between an incorrect zDbName and an
55SQLITE_ERROR return from the underlying xFileControl method.
56.Pp
57.Sh IMPLEMENTATION NOTES
58These declarations were extracted from the
59interface documentation at line 8221.
60.Bd -literal
61SQLITE_API int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);
62.Ed
63.Sh SEE ALSO
64.Xr sqlite3_errcode 3 ,
65.Xr sqlite3_file 3 ,
66.Xr sqlite3_io_methods 3 ,
67.Xr sqlite3_vfs 3 ,
68.Xr SQLITE_FCNTL_LOCKSTATE 3
69