Fix db upgrade from 12 -> 13

This commit is contained in:
Ron Pedde 2006-11-19 18:58:03 +00:00
parent 4d8e618f75
commit d5506fc46f
4 changed files with 31 additions and 28 deletions

View File

@ -65,7 +65,7 @@
<short_description>
Should the logfile get truncated on startup?
</short_description>
<type default_value="1">select</type>
<type default_value="0">select</type>
<options>
<option value="0">No</option>
<option value="1">Yes</option>

View File

@ -126,6 +126,7 @@ static CONF_ELEMENTS conf_elements[] = {
{ 0, 0, CONF_T_STRING,"general","never_transcode" },
{ 0, 0, CONF_T_MULTICOMMA,"general","compdirs" },
{ 0, 0, CONF_T_STRING,"general","logfile" },
{ 0, 0, CONF_T_INT,"general","truncate" },
{ 0, 0, CONF_T_EXISTPATH,"plugins","plugin_dir" },
{ 0, 0, CONF_T_MULTICOMMA,"plugins","plugins" },
{ 0, 0, CONF_T_INT,"daap","empty_strings" },
@ -349,7 +350,7 @@ int _conf_verify_element(char *section, char *key, char *value) {
return CONF_E_SUCCESS;
return CONF_E_INTEXPECTED;
break;
case CONF_T_MULTIPATH:
if(_conf_split(value,",",&valuearray) >= 0) {
index = 0;
@ -537,7 +538,7 @@ void _conf_apply(LL_HANDLE pll) {
/**
* reload the existing config file.
*
*
* @returns CONF_E_SUCCESS on success
*/
int conf_reload(void) {
@ -1370,7 +1371,7 @@ int _conf_split(char *s, char *delimiters, char ***argvp) {
if(strchr(delimiters,*tmp) && (*(tmp+1) != *tmp))
break;
if(strchr(delimiters,*tmp)) {
tmp += 2;
tmp += 2;
} else {
tmp++;
}
@ -1378,7 +1379,7 @@ int _conf_split(char *s, char *delimiters, char ***argvp) {
*tmp = '\0';
tmp++;
(*argvp)[i] = tokptr;
fix_src = fix_dst = tokptr;
while(*fix_src) {
if(strchr(delimiters,*fix_src) && (*(fix_src+1) == *fix_src)) {
@ -1634,7 +1635,7 @@ char *conf_get_filename(void) {
/**
* this is an ugly block of crap to carry around every
* time one wants the servername.
* time one wants the servername.
*/
char *conf_get_servername(void) {
char *retval;
@ -1709,7 +1710,7 @@ char *conf_get_servername(void) {
} else {
*dst++ = *src++;
}
}
return retval;

View File

@ -69,7 +69,7 @@ static char *db_sqlite2_enum_query;
static char db_sqlite2_path[PATH_MAX + 1];
#define DB_SQLITE2_VERSION 12
#define DB_SQLITE2_VERSION 13
/* Forwards */
@ -157,7 +157,8 @@ int db_sqlite2_open(char **pe, char *dsn) {
DPRINTF(E_LOG,L_DB,"Can't get db version. New database?\n");
} else if(ver != DB_SQLITE2_VERSION) {
/* we'll deal with this in the db handler */
DPRINTF(E_LOG,L_DB,"Old database version.\n");
DPRINTF(E_LOG,L_DB,"Old database version: %d, expecting %d\n",
ver, DB_SQLITE2_VERSION);
db_get_error(pe,DB_E_WRONGVERSION);
return DB_E_WRONGVERSION;
}
@ -328,13 +329,13 @@ int db_sqlite2_event(int event_type) {
if(!conf_get_int("database","quick_startup",0))
db_sqlite2_exec(NULL,E_FATAL,"vacuum");
/* make sure our indexes exist */
db_sqlite2_exec(NULL,E_DBG,"create index idx_path on "
"songs(path,idx)");
db_sqlite2_exec(NULL,E_DBG,"create index idx_songid on "
"playlistitems(songid)");
db_sqlite2_exec(NULL,E_DBG,"create index idx_playlistid on "
"playlistitems(playlistid,songid)");
/* make sure our indexes exist */
db_sqlite2_exec(NULL,E_DBG,"create index idx_path on "
"songs(path,idx)");
db_sqlite2_exec(NULL,E_DBG,"create index idx_songid on "
"playlistitems(songid)");
db_sqlite2_exec(NULL,E_DBG,"create index idx_playlistid on "
"playlistitems(playlistid,songid)");
db_sqlite2_reload=0;
break;

View File

@ -152,7 +152,8 @@ int db_sqlite3_open(char **pe, char *dsn) {
/* we'll catch this on the init */
DPRINTF(E_LOG,L_DB,"Can't get db version. New database?\n");
} else if(ver != DB_SQLITE3_VERSION) {
DPRINTF(E_LOG,L_DB,"Old database version.\n");
DPRINTF(E_LOG,L_DB,"Old database version: %d, expecting %d\n",
ver,DB_SQLITE3_VERSION);
db_get_error(pe,DB_E_WRONGVERSION);
return DB_E_WRONGVERSION;
}
@ -234,8 +235,8 @@ int db_sqlite3_enum_begin_helper(char **pe) {
if(!db_sqlite3_enum_query)
*((int*)NULL) = 1;
DPRINTF(E_DBG,L_DB,"Executing: %s\n",db_sqlite3_enum_query);
err=sqlite3_prepare(db_sqlite3_songs,db_sqlite3_enum_query,-1,
&db_sqlite3_stmt,&ptail);
@ -258,7 +259,7 @@ int db_sqlite3_enum_begin_helper(char **pe) {
}
/**
* fetch the next row. This will return DB_E_SUCCESS if it got a
* fetch the next row. This will return DB_E_SUCCESS if it got a
* row, or it's done. If it's done, the row will be empty, otherwise
* it will be full of data. Either way, if fetch fails, you must close.
*
@ -362,12 +363,12 @@ int db_sqlite3_event(int event_type) {
if(!conf_get_int("database","quick_startup",0))
db_sqlite3_exec(NULL,E_FATAL,"vacuum");
db_sqlite3_exec(NULL,E_DBG,"create index idx_path on "
"songs(path,idx)");
db_sqlite3_exec(NULL,E_DBG,"create index idx_songid on "
"playlistitems(songid)");
db_sqlite3_exec(NULL,E_DBG,"create index idx_playlistid on "
"playlistitems(playlistid,songid)");
db_sqlite3_exec(NULL,E_DBG,"create index idx_path on "
"songs(path,idx)");
db_sqlite3_exec(NULL,E_DBG,"create index idx_songid on "
"playlistitems(songid)");
db_sqlite3_exec(NULL,E_DBG,"create index idx_playlistid on "
"playlistitems(playlistid,songid)");
db_sqlite3_reload=0;
break;
@ -455,11 +456,11 @@ int db_sqlite3_event(int event_type) {
int db_sqlite3_insert_id(void) {
int result;
db_sqlite3_lock();
result = (int)sqlite3_last_insert_rowid(db_sqlite3_songs);
db_sqlite3_unlock();
return result;
}