xref: /netbsd-src/external/public-domain/sqlite/man/sqlite3_snapshot_get.3 (revision bdc22b2e01993381dcefeff2bc9b56ca75a4235c)
1.Dd March 11, 2017
2.Dt SQLITE3_SNAPSHOT_GET 3
3.Os
4.Sh NAME
5.Nm sqlite3_snapshot_get
6.Nd Record A Database Snapshot
7.Sh SYNOPSIS
8.Ft int
9.Fo sqlite3_snapshot_get
10.Fa "sqlite3 *db"
11.Fa "const char *zSchema"
12.Fa "sqlite3_snapshot **ppSnapshot "
13.Fc
14.Sh DESCRIPTION
15The sqlite3_snapshot_get(D,S,P) interface
16attempts to make a new sqlite3_snapshot object that
17records the current state of schema S in database connection D.
18On success, the sqlite3_snapshot_get(D,S,P)
19interface writes a pointer to the newly created sqlite3_snapshot
20object into *P and returns SQLITE_OK.
21If there is not already a read-transaction open on schema S when this
22function is called, one is opened automatically.
23.Pp
24The following must be true for this function to succeed.
25If any of the following statements are false when sqlite3_snapshot_get()
26is called, SQLITE_ERROR is returned.
27The final value of *P is undefined in this case.
28.Bl -bullet
29.It
30The database handle must be in autocommit mode.
31.It
32Schema S of database connection D must be a WAL mode
33database.
34.It
35There must not be a write transaction open on schema S of database
36connection D.
37.It
38One or more transactions must have been written to the current wal
39file since it was created on disk (by any connection).
40This means that a snapshot cannot be taken on a wal mode database with
41no wal file immediately after it is first opened.
42At least one transaction must be written to it first.
43.El
44.Pp
45This function may also return SQLITE_NOMEM.
46If it is called with the database handle in autocommit mode but fails
47for some other reason, whether or not a read transaction is opened
48on schema S is undefined.
49.Pp
50The sqlite3_snapshot object returned from a successful
51call to sqlite3_snapshot_get() must be freed
52using sqlite3_snapshot_free() to avoid a memory
53leak.
54.Pp
55The sqlite3_snapshot_get() interface is only
56available when the SQLITE_ENABLE_SNAPSHOT compile-time option is used.
57.Sh SEE ALSO
58.Xr sqlite3_get_autocommit 3 ,
59.Xr sqlite3 3 ,
60.Xr sqlite3_snapshot 3 ,
61.Xr sqlite3_snapshot_free 3 ,
62.Xr sqlite3_snapshot_get 3
63