Skip to content
Extraits de code Groupes Projets
Vérifiée Valider d72eb145 rédigé par Kubat's avatar Kubat
Parcourir les fichiers

Well, fix the del by range, now need to fix the deleteid

parent 8efad320
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!55Lkt fix
......@@ -306,15 +306,18 @@ error:
static bool
queue_rm_with_sql(sqlite3 *db, const char *sql, int arg)
{
bool res = false;
sqlite3_stmt *stmt = 0;
bool res = sqlite3_prepare_v2(db, sql, -1, &stmt, 0) == SQLITE_OK &&
sqlite3_bind_int(stmt, 1, arg) == SQLITE_OK &&
sqlite3_step(stmt) == SQLITE_DONE;
if (!res)
SQLITE_PREPARE(db, stmt, sql, err);
SQLITE_BIND_INT(db, stmt, 1, arg, err);
if (sqlite3_step(stmt) != SQLITE_DONE) {
fprintf(stderr, " ! del_kara_with_sql: Failed to delete kara: %s\n",
sqlite3_errmsg(db));
goto err;
}
res = true;
err:
sqlite3_finalize(stmt);
return res;
}
......@@ -322,8 +325,13 @@ queue_rm_with_sql(sqlite3 *db, const char *sql, int arg)
bool
database_queue_del_id(sqlite3 *db, int id)
{
static const char *SQL_DEL_KARA = "DELETE FROM queue WHERE kara_id = ?";
return queue_rm_with_sql(db, SQL_DEL_KARA, id);
static const char *SQL_DEL_KARA = "DELETE FROM queue WHERE kara_id = ?;";
if (!queue_rm_with_sql(db, SQL_DEL_KARA, id))
return false;
SQLITE_EXEC(db, "UPDATE queue_state SET current = current - 1;", err);
return true;
err:
return false;
}
bool
......@@ -336,7 +344,12 @@ database_queue_del_pos(sqlite3 *db, int pos)
" FROM queue_"
" WHERE position = ?"
" );";
return queue_rm_with_sql(db, SQL_DEL_POS, pos);
if (!queue_rm_with_sql(db, SQL_DEL_POS, pos))
return false;
SQLITE_EXEC(db, "UPDATE queue_state SET current = current - 1;", err);
return true;
err:
return false;
}
bool
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter