Enable auto vacuum.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4372 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2023-07-27 12:22:37 +00:00
parent d3029639de
commit 3e5abf3a4d
3 changed files with 21 additions and 6 deletions

View File

@ -77,6 +77,25 @@ void tf_ssb_db_init(tf_ssb_t* ssb)
{
sqlite3* db = tf_ssb_acquire_db_writer(ssb);
_tf_ssb_db_init_internal(db);
sqlite3_stmt* statement = NULL;
int auto_vacuum = 0;
if (sqlite3_prepare(db, "PRAGMA auto_vacuum", -1, &statement, NULL) == SQLITE_OK)
{
if (sqlite3_step(statement) == SQLITE_ROW)
{
auto_vacuum = sqlite3_column_int(statement, 0);
}
sqlite3_finalize(statement);
}
if (auto_vacuum != 1 /* FULL */)
{
tf_printf("Enabling auto-vacuum and performing full vacuum.\n");
_tf_ssb_db_exec(db, "PRAGMA auto_vacuum = FULL");
_tf_ssb_db_exec(db, "VACUUM main");
tf_printf("All clean.\n");
}
_tf_ssb_db_exec(db,
"CREATE TABLE IF NOT EXISTS messages ("
" author TEXT,"
@ -196,7 +215,6 @@ void tf_ssb_db_init(tf_ssb_t* ssb)
bool need_add_sequence_before_author = true;
bool need_convert_timestamp_to_real = false;
sqlite3_stmt* statement = NULL;
if (sqlite3_prepare(db, "PRAGMA table_info(messages)", -1, &statement, NULL) == SQLITE_OK)
{
int result = SQLITE_OK;