xref: /netbsd-src/external/public-domain/sqlite/man/sqlite3session_create.3 (revision b9988867a8ad969c45a52aa7628bc932ec98d46b)
1.Dd January 24, 2024
2.Dt SQLITE3SESSION_CREATE 3
3.Os
4.Sh NAME
5.Nm sqlite3session_create
6.Nd create a new session object
7.Sh SYNOPSIS
8.In sqlite3.h
9.Ft int
10.Fo sqlite3session_create
11.Fa "sqlite3 *db"
12.Fa "const char *zDb"
13.Fa "sqlite3_session **ppSession"
14.Fc
15.Sh DESCRIPTION
16Create a new session object attached to database handle db.
17If successful, a pointer to the new object is written to *ppSession
18and SQLITE_OK is returned.
19If an error occurs, *ppSession is set to NULL and an SQLite error code
20(e.g. SQLITE_NOMEM) is returned.
21.Pp
22It is possible to create multiple session objects attached to a single
23database handle.
24.Pp
25Session objects created using this function should be deleted using
26the
27.Fn sqlite3session_delete
28function before the database handle that they are attached to is itself
29closed.
30If the database handle is closed before the session object is deleted,
31then the results of calling any session module function, including
32.Fn sqlite3session_delete
33on the session object are undefined.
34.Pp
35Because the session module uses the
36.Fn sqlite3_preupdate_hook
37API, it is not possible for an application to register a pre-update
38hook on a database handle that has one or more session objects attached.
39Nor is it possible to create a session object attached to a database
40handle for which a pre-update hook is already defined.
41The results of attempting either of these things are undefined.
42.Pp
43The session object will be used to create changesets for tables in
44database zDb, where zDb is either "main", or "temp", or the name of
45an attached database.
46It is not an error if database zDb is not attached to the database
47when the session object is created.
48.Sh IMPLEMENTATION NOTES
49These declarations were extracted from the
50interface documentation at line 10953.
51.Bd -literal
52SQLITE_API int sqlite3session_create(
53  sqlite3 *db,                    /* Database handle */
54  const char *zDb,                /* Name of db (e.g. "main") */
55  sqlite3_session **ppSession     /* OUT: New session object */
56);
57.Ed
58.Sh SEE ALSO
59.Xr sqlite3_preupdate_hook 3 ,
60.Xr sqlite3session_delete 3
61