Training courses

Kernel and Embedded Linux

Bootlin training courses

Embedded Linux, kernel,
Yocto Project, Buildroot, real-time,
graphics, boot time, debugging...

Bootlin logo

Elixir Cross Referencer

.Dd December 19, 2018
.Dt SQLITE3_SERIALIZE 3
.Os
.Sh NAME
.Nm sqlite3_serialize
.Nd Serialize a database
.Sh SYNOPSIS
.Ft unsigned char *
.Fo sqlite3_serialize
.Fa "sqlite3 *db"
.Fa "const char *zSchema"
.Fa "sqlite3_int64 *piSize"
.Fa "unsigned int mFlags    "
.Fc
.Sh DESCRIPTION
The sqlite3_serialize(D,S,P,F) interface returns a pointer to memory
that is a serialization of the S database on database connection
D.
If P is not a NULL pointer, then the size of the database in bytes
is written into *P.
.Pp
For an ordinary on-disk database file, the serialization is just a
copy of the disk file.
For an in-memory database or a "TEMP" database, the serialization is
the same sequence of bytes which would be written to disk if that database
where backed up to disk.
.Pp
The usual case is that sqlite3_serialize() copies the serialization
of the database into memory obtained from sqlite3_malloc64()
and returns a pointer to that memory.
The caller is responsible for freeing the returned value to avoid a
memory leak.
However, if the F argument contains the SQLITE_SERIALIZE_NOCOPY bit,
then no memory allocations are made, and the sqlite3_serialize() function
will return a pointer to the contiguous memory representation of the
database that SQLite is currently using for that database, or NULL
if the no such contiguous memory representation of the database exists.
A contiguous memory representation of the database will usually only
exist if there has been a prior call to sqlite3_deserialize(D,S,...)
with the same values of D and S.
The size of the database is written into *P even if the SQLITE_SERIALIZE_NOCOPY
bit is set but no contiguous copy of the database exists.
.Pp
A call to sqlite3_serialize(D,S,P,F) might return NULL even if the
SQLITE_SERIALIZE_NOCOPY bit is omitted from argument F if a memory
allocation error occurs.
.Pp
This interface is only available if SQLite is compiled with the SQLITE_ENABLE_DESERIALIZE
option.
.Sh SEE ALSO
.Xr sqlite3 3 ,
.Xr sqlite3_malloc 3