summaryrefslogtreecommitdiff
path: root/static/netbsd/man3/sqlite3_load_extension.3
blob: c8bf84a1fdd116acd1bdd66a8c82e7ad8b3a4631 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
.Dd January 24, 2024
.Dt SQLITE3_LOAD_EXTENSION 3
.Os
.Sh NAME
.Nm sqlite3_load_extension
.Nd load an extension
.Sh SYNOPSIS
.In sqlite3.h
.Ft int
.Fo sqlite3_load_extension
.Fa "sqlite3 *db"
.Fa "const char *zFile"
.Fa "const char *zProc"
.Fa "char **pzErrMsg"
.Fc
.Sh DESCRIPTION
This interface loads an SQLite extension library from the named file.
.Pp
The sqlite3_load_extension() interface attempts to load an SQLite extension
library contained in the file zFile.
If the file cannot be loaded directly, attempts are made to load with
various operating-system specific extensions added.
So for example, if "samplelib" cannot be loaded, then names like "samplelib.so"
or "samplelib.dylib" or "samplelib.dll" might be tried also.
.Pp
The entry point is zProc.
zProc may be 0, in which case SQLite will try to come up with an entry
point name on its own.
It first tries "sqlite3_extension_init".
If that does not work, it constructs a name "sqlite3_X_init" where
the X is consists of the lower-case equivalent of all ASCII alphabetic
characters in the filename from the last "/" to the first following
"." and omitting any initial "lib".
The sqlite3_load_extension() interface returns SQLITE_OK on
success and SQLITE_ERROR if something goes wrong.
If an error occurs and pzErrMsg is not 0, then the
.Fn sqlite3_load_extension
interface shall attempt to fill *pzErrMsg with error message text stored
in memory obtained from
.Fn sqlite3_malloc .
The calling function should free this memory by calling
.Fn sqlite3_free .
Extension loading must be enabled using
.Fn sqlite3_enable_load_extension
or sqlite3_db_config(db,SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION,1,NULL)
prior to calling this API, otherwise an error will be returned.
.Pp
\fBSecurity warning:\fP It is recommended that the SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION
method be used to enable only this interface.
The use of the
.Fn sqlite3_enable_load_extension
interface should be avoided.
This will keep the SQL function
.Fn load_extension
disabled and prevent SQL injections from giving attackers access to
extension loading capabilities.
.Pp
See also the load_extension() SQL function.
.Sh IMPLEMENTATION NOTES
These declarations were extracted from the
interface documentation at line 7129.
.Bd -literal
SQLITE_API int sqlite3_load_extension(
  sqlite3 *db,          /* Load the extension into this database connection */
  const char *zFile,    /* Name of the shared library containing extension */
  const char *zProc,    /* Entry point.  Derived from zFile if 0 */
  char **pzErrMsg       /* Put error message here if not 0 */
);
.Ed
.Sh SEE ALSO
.Xr sqlite3_db_config 3 ,
.Xr sqlite3_enable_load_extension 3 ,
.Xr sqlite3_malloc 3 ,
.Xr SQLITE_DBCONFIG_MAINDBNAME 3 ,
.Xr SQLITE_OK 3