diff options
author | drh <> | 2024-01-20 16:29:19 +0000 |
---|---|---|
committer | drh <> | 2024-01-20 16:29:19 +0000 |
commit | b23f61b73fcbb9e3e369b222c7c3559280a4f720 (patch) | |
tree | 1e586f2350b19ce39a7fc22e8a8865454e068934 /src | |
parent | 4c43f1881e86893c22ead7a72be6b14bbcd051eb (diff) | |
download | sqlite-b23f61b73fcbb9e3e369b222c7c3559280a4f720.tar.gz sqlite-b23f61b73fcbb9e3e369b222c7c3559280a4f720.zip |
Rig sqlite3_serialize() so that it will initialize a previously uninitialized
database prior to serializing it, so that it does not have a zero-byte size
and does not return NULL (except for OOM).
[forum:/forumpost/498777780e16880a|Forum thread 498777780e16880a].
FossilOrigin-Name: e638d5e408ea2e189b6771d16bbc2e42c606e88e05fbea78079b6e39e41f344c
Diffstat (limited to 'src')
-rw-r--r-- | src/memdb.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/memdb.c b/src/memdb.c index 657cb9ca6..d83a51d54 100644 --- a/src/memdb.c +++ b/src/memdb.c @@ -799,6 +799,14 @@ unsigned char *sqlite3_serialize( pOut = 0; }else{ sz = sqlite3_column_int64(pStmt, 0)*szPage; + if( sz==0 ){ + sqlite3_reset(pStmt); + sqlite3_exec(db, "BEGIN IMMEDIATE; COMMIT;", 0, 0, 0); + rc = sqlite3_step(pStmt); + if( rc==SQLITE_ROW ){ + sz = sqlite3_column_int64(pStmt, 0)*szPage; + } + } if( piSize ) *piSize = sz; if( mFlags & SQLITE_SERIALIZE_NOCOPY ){ pOut = 0; |