| SQLITE3_SNAPSHOT_GET(3) | Library Functions Manual | SQLITE3_SNAPSHOT_GET(3) |
sqlite3_snapshot_get —
record a database snapshot
#include
<sqlite3.h>
int
sqlite3_snapshot_get(sqlite3
*db, const char *zSchema,
sqlite3_snapshot **ppSnapshot);
The sqlite3_snapshot_get(D,S,P) interface attempts to make a new sqlite3_snapshot object that records the current state of schema S in database connection D. On success, the sqlite3_snapshot_get(D,S,P) interface writes a pointer to the newly created sqlite3_snapshot object into *P and returns SQLITE_OK. If there is not already a read-transaction open on schema S when this function is called, one is opened automatically.
If a read-transaction is opened by this function, then it is guaranteed that the returned snapshot object may not be invalidated by a database writer or checkpointer until after the read-transaction is closed. This is not guaranteed if a read-transaction is already open when this function is called. In that case, any subsequent write or checkpoint operation on the database may invalidate the returned snapshot handle, even while the read-transaction remains open.
The following must be true for this function to succeed. If any of the following statements are false when sqlite3_snapshot_get() is called, SQLITE_ERROR is returned. The final value of *P is undefined in this case.
This function may also return SQLITE_NOMEM. If it is called with the database handle in autocommit mode but fails for some other reason, whether or not a read transaction is opened on schema S is undefined.
The sqlite3_snapshot object returned
from a successful call to
sqlite3_snapshot_get()
must be freed using
sqlite3_snapshot_free()
to avoid a memory leak.
The
sqlite3_snapshot_get()
interface is only available when the SQLITE_ENABLE_SNAPSHOT compile-time
option is used.
These declarations were extracted from the interface documentation at line 10956.
SQLITE_API int sqlite3_snapshot_get( sqlite3 *db, const char *zSchema, sqlite3_snapshot **ppSnapshot );
sqlite3(3), sqlite3_get_autocommit(3), sqlite3_snapshot(3), sqlite3_snapshot_free(3)
| April 29, 2026 | NetBSD 11.99 |