Updated: 2022/Sep/29

Please read Privacy Policy. It's for your privacy.


SQLITE3_LOAD_EXTENSION(3)  Library Functions Manual  SQLITE3_LOAD_EXTENSION(3)

NAME
     sqlite3_load_extension - load an extension

SYNOPSIS
     #include <sqlite3.h>

     int
     sqlite3_load_extension(sqlite3 *db, const char *zFile, const char *zProc,
         char **pzErrMsg);

DESCRIPTION
     This interface loads an SQLite extension library from the named file.

     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.

     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 sqlite3_load_extension() interface shall attempt to fill
     *pzErrMsg with error message text stored in memory obtained from
     sqlite3_malloc().  The calling function should free this memory by
     calling sqlite3_free().  Extension loading must be enabled using
     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.

     Security warning: It is recommended that the
     SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION method be used to enable only this
     interface.  The use of the sqlite3_enable_load_extension() interface
     should be avoided.  This will keep the SQL function load_extension()
     disabled and prevent SQL injections from giving attackers access to
     extension loading capabilities.

     See also the load_extension() SQL function.

IMPLEMENTATION NOTES
     These declarations were extracted from the interface documentation at
     line 7025.

     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 */
     );

SEE ALSO
     sqlite3_db_config(3), sqlite3_enable_load_extension(3),
     sqlite3_malloc(3), SQLITE_DBCONFIG_MAINDBNAME(3), SQLITE_OK(3)

NetBSD 10.99                    August 24, 2023                   NetBSD 10.99