Index: third_party/sqlite/src/src/vacuum.c |
diff --git a/third_party/sqlite/src/src/vacuum.c b/third_party/sqlite/src/src/vacuum.c |
index 4d0c0976a182a01a0195b047dc5289bca1095cb4..adc802e60b4330608c511829857dd14c74c597ce 100644 |
--- a/third_party/sqlite/src/src/vacuum.c |
+++ b/third_party/sqlite/src/src/vacuum.c |
@@ -94,7 +94,7 @@ static int execExecSql(sqlite3 *db, char **pzErrMsg, const char *zSql){ |
** overwriting the database with the vacuumed content. |
** |
** Only 1x temporary space and only 1x writes would be required if |
-** the copy of step (3) were replace by deleting the original database |
+** the copy of step (3) were replaced by deleting the original database |
** and renaming the transient database as the original. But that will |
** not work if other processes are attached to the original database. |
** And a power loss in between deleting the original and renaming the |
@@ -184,7 +184,7 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){ |
** cause problems for the call to BtreeSetPageSize() below. */ |
sqlite3BtreeCommit(pTemp); |
- nRes = sqlite3BtreeGetReserve(pMain); |
+ nRes = sqlite3BtreeGetOptimalReserve(pMain); |
/* A VACUUM cannot change the pagesize of an encrypted database. */ |
#ifdef SQLITE_HAS_CODEC |
@@ -250,6 +250,8 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){ |
** an "INSERT INTO vacuum_db.xxx SELECT * FROM main.xxx;" to copy |
** the contents to the temporary database. |
*/ |
+ assert( (db->flags & SQLITE_Vacuum)==0 ); |
+ db->flags |= SQLITE_Vacuum; |
rc = execExecSql(db, pzErrMsg, |
"SELECT 'INSERT INTO vacuum_db.' || quote(name) " |
"|| ' SELECT * FROM main.' || quote(name) || ';'" |
@@ -257,6 +259,8 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){ |
"WHERE type = 'table' AND name!='sqlite_sequence' " |
" AND coalesce(rootpage,1)>0" |
); |
+ assert( (db->flags & SQLITE_Vacuum)!=0 ); |
+ db->flags &= ~SQLITE_Vacuum; |
if( rc!=SQLITE_OK ) goto end_of_vacuum; |
/* Copy over the sequence table |