1.Dd January 24, 2024 2.Dt SQLITE3_AUTO_EXTENSION 3 3.Os 4.Sh NAME 5.Nm sqlite3_auto_extension 6.Nd automatically load statically linked extensions 7.Sh SYNOPSIS 8.In sqlite3.h 9.Ft int 10.Fo sqlite3_auto_extension 11.Fa "void(*xEntryPoint)(void)" 12.Fc 13.Sh DESCRIPTION 14This interface causes the xEntryPoint() function to be invoked for 15each new database connection that is created. 16The idea here is that xEntryPoint() is the entry point for a statically 17linked SQLite extension that is to be automatically 18loaded into all new database connections. 19.Pp 20Even though the function prototype shows that xEntryPoint() takes no 21arguments and returns void, SQLite invokes xEntryPoint() with three 22arguments and expects an integer result as if the signature of the 23entry point where as follows: 24.Bd -ragged 25.Bd -literal 26 int xEntryPoint( sqlite3 *db, const char **pzErrMsg, 27const struct sqlite3_api_routines *pThunk ); 28.Ed 29.Pp 30.Ed 31.Pp 32If the xEntryPoint routine encounters an error, it should make *pzErrMsg 33point to an appropriate error message (obtained from 34.Fn sqlite3_mprintf ) 35and return an appropriate error code. 36SQLite ensures that *pzErrMsg is NULL before calling the xEntryPoint(). 37SQLite will invoke 38.Fn sqlite3_free 39on *pzErrMsg after xEntryPoint() returns. 40If any xEntryPoint() returns an error, the 41.Fn sqlite3_open , 42.Fn sqlite3_open16 , 43or 44.Fn sqlite3_open_v2 45call that provoked the xEntryPoint() will fail. 46.Pp 47Calling sqlite3_auto_extension(X) with an entry point X that is already 48on the list of automatic extensions is a harmless no-op. 49No entry point will be called more than once for each database connection 50that is opened. 51.Pp 52.Sh IMPLEMENTATION NOTES 53These declarations were extracted from the 54interface documentation at line 7207. 55.Bd -literal 56SQLITE_API int sqlite3_auto_extension(void(*xEntryPoint)(void)); 57.Ed 58.Sh SEE ALSO 59.Xr sqlite3 3 , 60.Xr sqlite3_cancel_auto_extension 3 , 61.Xr sqlite3_malloc 3 , 62.Xr sqlite3_mprintf 3 , 63.Xr sqlite3_open 3 , 64.Xr sqlite3_reset_auto_extension 3 65