xref: /netbsd-src/external/public-domain/sqlite/man/sqlite3_load_extension.3 (revision 82d56013d7b633d116a93943de88e08335357a7c)
1.Dd December 19, 2018
2.Dt SQLITE3_LOAD_EXTENSION 3
3.Os
4.Sh NAME
5.Nm sqlite3_load_extension
6.Nd Load An Extension
7.Sh SYNOPSIS
8.Ft int
9.Fo sqlite3_load_extension
10.Fa "sqlite3 *db"
11.Fa "const char *zFile"
12.Fa "const char *zProc"
13.Fa "char **pzErrMsg       "
14.Fc
15.Sh DESCRIPTION
16This interface loads an SQLite extension library from the named file.
17.Pp
18The sqlite3_load_extension() interface attempts to load an SQLite extension
19library contained in the file zFile.
20If the file cannot be loaded directly, attempts are made to load with
21various operating-system specific extensions added.
22So for example, if "samplelib" cannot be loaded, then names like "samplelib.so"
23or "samplelib.dylib" or "samplelib.dll" might be tried also.
24.Pp
25The entry point is zProc.
26zProc may be 0, in which case SQLite will try to come up with an entry
27point name on its own.
28It first tries "sqlite3_extension_init".
29If that does not work, it constructs a name "sqlite3_X_init" where
30the X is consists of the lower-case equivalent of all ASCII alphabetic
31characters in the filename from the last "/" to the first following
32"." and omitting any initial "lib".
33The sqlite3_load_extension() interface returns SQLITE_OK on
34success and SQLITE_ERROR if something goes wrong.
35If an error occurs and pzErrMsg is not 0, then the sqlite3_load_extension()
36interface shall attempt to fill *pzErrMsg with error message text stored
37in memory obtained from sqlite3_malloc().
38The calling function should free this memory by calling sqlite3_free().
39.Pp
40Extension loading must be enabled using sqlite3_enable_load_extension()
41or sqlite3_db_config(db,SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION,1,NULL)
42prior to calling this API, otherwise an error will be returned.
43.Pp
44\fBSecurity warning:\fP It is recommended that the SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION
45method be used to enable only this interface.
46The use of the sqlite3_enable_load_extension()
47interface should be avoided.
48This will keep the SQL function load_extension() disabled
49and prevent SQL injections from giving attackers access to extension
50loading capabilities.
51.Pp
52See also the load_extension() SQL function.
53.Sh SEE ALSO
54.Xr sqlite3_db_config 3 ,
55.Xr sqlite3_enable_load_extension 3 ,
56.Xr sqlite3_malloc 3 ,
57.Xr sqlite3_load_extension 3 ,
58.Xr sqlite3_malloc 3 ,
59.Xr SQLITE_DBCONFIG_MAINDBNAME 3 ,
60.Xr SQLITE_OK 3
61