mirror of
https://github.com/owntone/owntone-server.git
synced 2025-02-03 01:46:02 -05:00
Vacuum on startup and also make index changes possible without schema updates
This commit is contained in:
parent
1f81b5ce7e
commit
829619be5d
42
src/db.c
42
src/db.c
@ -5448,10 +5448,6 @@ db_check_version(void)
|
|||||||
{
|
{
|
||||||
DPRINTF(E_LOG, L_DB, "Database schema outdated, schema upgrade needed v%d -> v%d\n", cur_ver, SCHEMA_VERSION);
|
DPRINTF(E_LOG, L_DB, "Database schema outdated, schema upgrade needed v%d -> v%d\n", cur_ver, SCHEMA_VERSION);
|
||||||
|
|
||||||
ret = db_drop_indices();
|
|
||||||
if (ret < 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
switch (cur_ver)
|
switch (cur_ver)
|
||||||
{
|
{
|
||||||
case 10:
|
case 10:
|
||||||
@ -5509,29 +5505,33 @@ db_check_version(void)
|
|||||||
DPRINTF(E_LOG, L_DB, "No upgrade path from DB schema v%d to v%d\n", cur_ver, SCHEMA_VERSION);
|
DPRINTF(E_LOG, L_DB, "No upgrade path from DB schema v%d to v%d\n", cur_ver, SCHEMA_VERSION);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = db_create_indices();
|
|
||||||
if (ret < 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
/* What about some housekeeping work, eh? */
|
|
||||||
DPRINTF(E_INFO, L_DB, "Now vacuuming database, this may take some time...\n");
|
|
||||||
|
|
||||||
ret = sqlite3_exec(hdl, Q_VACUUM, NULL, NULL, &errmsg);
|
|
||||||
if (ret != SQLITE_OK)
|
|
||||||
{
|
|
||||||
DPRINTF(E_LOG, L_DB, "Could not VACUUM database: %s\n", errmsg);
|
|
||||||
|
|
||||||
sqlite3_free(errmsg);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (cur_ver > SCHEMA_VERSION)
|
else if (cur_ver > SCHEMA_VERSION)
|
||||||
{
|
{
|
||||||
DPRINTF(E_LOG, L_DB, "Database schema is newer than the supported version\n");
|
DPRINTF(E_FATAL, L_DB, "Database schema is newer than the supported version\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Drop and create indices on startup so that change of a index can be done without a schema update */
|
||||||
|
ret = db_drop_indices();
|
||||||
|
if (ret < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
DPRINTF(E_INFO, L_DB, "Now vacuuming database, this may take some time...\n");
|
||||||
|
|
||||||
|
ret = sqlite3_exec(hdl, Q_VACUUM, NULL, NULL, &errmsg);
|
||||||
|
if (ret != SQLITE_OK)
|
||||||
|
{
|
||||||
|
DPRINTF(E_LOG, L_DB, "Could not VACUUM database: %s\n", errmsg);
|
||||||
|
|
||||||
|
sqlite3_free(errmsg);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = db_create_indices();
|
||||||
|
if (ret < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
#undef Q_VER
|
#undef Q_VER
|
||||||
|
Loading…
x
Reference in New Issue
Block a user