Fossil SCM
During shutdown, check to see if the check-out database (".fslckout") contains a lot of free space, and if it does, VACUUM it.
Commit
bf681039e2a29672a6652531dc14a6a389060d0e
Parent
af8c8c67af75121…
1 file changed
+12
M
src/db.c
+12
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -1355,10 +1355,22 @@ | ||
| 1355 | 1355 | while( (pStmt = sqlite3_next_stmt(g.db, pStmt))!=0 ){ |
| 1356 | 1356 | fossil_warning("unfinalized SQL statement: [%s]", sqlite3_sql(pStmt)); |
| 1357 | 1357 | } |
| 1358 | 1358 | } |
| 1359 | 1359 | db_close_config(); |
| 1360 | + | |
| 1361 | + /* If the localdb (the check-out database) is open and if it has | |
| 1362 | + ** a lot of unused free space, then VACUUM it as we shut down. | |
| 1363 | + */ | |
| 1364 | + if( g.localOpen && strcmp(db_name("localdb"),"main")==0 ){ | |
| 1365 | + int nFree = db_int(0, "PRAGMA main.freelist_count"); | |
| 1366 | + int nTotal = db_int(0, "PRAGMA main.page_count"); | |
| 1367 | + if( nFree>nTotal/4 ){ | |
| 1368 | + db_multi_exec("VACUUM;"); | |
| 1369 | + } | |
| 1370 | + } | |
| 1371 | + | |
| 1360 | 1372 | if( g.db ){ |
| 1361 | 1373 | sqlite3_wal_checkpoint(g.db, 0); |
| 1362 | 1374 | sqlite3_close(g.db); |
| 1363 | 1375 | g.db = 0; |
| 1364 | 1376 | g.zMainDbType = 0; |
| 1365 | 1377 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -1355,10 +1355,22 @@ | |
| 1355 | while( (pStmt = sqlite3_next_stmt(g.db, pStmt))!=0 ){ |
| 1356 | fossil_warning("unfinalized SQL statement: [%s]", sqlite3_sql(pStmt)); |
| 1357 | } |
| 1358 | } |
| 1359 | db_close_config(); |
| 1360 | if( g.db ){ |
| 1361 | sqlite3_wal_checkpoint(g.db, 0); |
| 1362 | sqlite3_close(g.db); |
| 1363 | g.db = 0; |
| 1364 | g.zMainDbType = 0; |
| 1365 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -1355,10 +1355,22 @@ | |
| 1355 | while( (pStmt = sqlite3_next_stmt(g.db, pStmt))!=0 ){ |
| 1356 | fossil_warning("unfinalized SQL statement: [%s]", sqlite3_sql(pStmt)); |
| 1357 | } |
| 1358 | } |
| 1359 | db_close_config(); |
| 1360 | |
| 1361 | /* If the localdb (the check-out database) is open and if it has |
| 1362 | ** a lot of unused free space, then VACUUM it as we shut down. |
| 1363 | */ |
| 1364 | if( g.localOpen && strcmp(db_name("localdb"),"main")==0 ){ |
| 1365 | int nFree = db_int(0, "PRAGMA main.freelist_count"); |
| 1366 | int nTotal = db_int(0, "PRAGMA main.page_count"); |
| 1367 | if( nFree>nTotal/4 ){ |
| 1368 | db_multi_exec("VACUUM;"); |
| 1369 | } |
| 1370 | } |
| 1371 | |
| 1372 | if( g.db ){ |
| 1373 | sqlite3_wal_checkpoint(g.db, 0); |
| 1374 | sqlite3_close(g.db); |
| 1375 | g.db = 0; |
| 1376 | g.zMainDbType = 0; |
| 1377 |