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