xref: /netbsd-src/external/public-domain/sqlite/man/sqlite3_auto_extension.3 (revision bdc22b2e01993381dcefeff2bc9b56ca75a4235c)
1.Dd March 11, 2017
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.Ft int
9.Fo sqlite3_auto_extension
10.Fa "void(*xEntryPoint)(void)"
11.Fc
12.Sh DESCRIPTION
13This interface causes the xEntryPoint() function to be invoked for
14each new database connection that is created.
15The idea here is that xEntryPoint() is the entry point for a statically
16linked SQLite extension that is to be automatically
17loaded into all new database connections.
18.Pp
19Even though the function prototype shows that xEntryPoint() takes no
20arguments and returns void, SQLite invokes xEntryPoint() with three
21arguments and expects an integer result as if the signature of the
22entry point where as follows:
23.Bd -ragged
24.Bd -literal
25   int xEntryPoint(      sqlite3 *db,      const char **pzErrMsg,
26const struct sqlite3_api_routines *pThunk    );
27.Ed
28.Pp
29.Ed
30.Pp
31If the xEntryPoint routine encounters an error, it should make *pzErrMsg
32point to an appropriate error message (obtained from sqlite3_mprintf())
33and return an appropriate error code.
34SQLite ensures that *pzErrMsg is NULL before calling the xEntryPoint().
35SQLite will invoke sqlite3_free() on *pzErrMsg after
36xEntryPoint() returns.
37If any xEntryPoint() returns an error, the sqlite3_open(),
38sqlite3_open16(), or sqlite3_open_v2()
39call that provoked the xEntryPoint() will fail.
40.Pp
41Calling sqlite3_auto_extension(X) with an entry point X that is already
42on the list of automatic extensions is a harmless no-op.
43No entry point will be called more than once for each database connection
44that is opened.
45.Pp
46.Sh SEE ALSO
47.Xr sqlite3 3 ,
48.Xr sqlite3_cancel_auto_extension 3 ,
49.Xr sqlite3_malloc 3 ,
50.Xr sqlite3_mprintf 3 ,
51.Xr sqlite3_open 3 ,
52.Xr sqlite3_reset_auto_extension 3
53