diff --git a/inc/lektor/internal/dbmacro.h b/inc/lektor/internal/dbmacro.h index e93d539b1ae5264b27d0d40ab311831adfe0b4e2..711783bbcb64c8819f9d2171ff50dfe6e4f6fbd5 100644 --- a/inc/lektor/internal/dbmacro.h +++ b/inc/lektor/internal/dbmacro.h @@ -71,8 +71,8 @@ #define SQLITE_STEP_ROW(db, stmt, error) SQLITE_STEP(db, stmt, SQLITE_ROW, error) #define SQLITE_STEP_DONE(db, stmt, error) SQLITE_STEP(db, stmt, SQLITE_DONE, error) -#define SQLITE_BEGIN_TRANSATION(db, error) SQLITE_EXEC(db, "BEGIN TRANSATION;", error) -#define SQLITE_END_TRANSATION(db, error) SQLITE_EXEC(db, "END TRANSATION;", error) +#define SQLITE_BEGIN_TRANSATION(db, error) SQLITE_EXEC(db, "BEGIN TRANSACTION;", error) +#define SQLITE_END_TRANSATION(db, error) SQLITE_EXEC(db, "END TRANSACTION;", error) #define SQLITE_DO_ROLLBACK(db) \ { \ LOG_WARN("DB-DEBUG", "DO ROLLBACK \\o/"); \ diff --git a/src/database/queue.c b/src/database/queue.c index f92eb02b348cd4027df0f1093816184e3f4aede1..aec4698df6d100e437c24e37664129923d39622f 100644 --- a/src/database/queue.c +++ b/src/database/queue.c @@ -537,7 +537,7 @@ ___database_back_propagate_priority(lkt_db *db) { /* Get the next kara with priority > 1 after the current in the queue */ static const char *SQL_GET_POS_WITH_PRIO_SUP_1 = - "SELECT position, priority" + "SELECT queue.position, queue.priority" " FROM queue" " JOIN queue_state ON" " queue_state.current <= queue.position AND queue.priority > 1" @@ -558,21 +558,24 @@ ___database_back_propagate_priority(lkt_db *db) /* Currently playing position */ SQLITE_PREPARE(db, stmt, SQL_GET_CURRENT, not_playing_or_no_need_to_back_propagate); SQLITE_STEP_ROW(db, stmt, not_playing_or_no_need_to_back_propagate); - currently_playing_position = sqlite3_column_int64(stmt, 1); + currently_playing_position = sqlite3_column_int64(stmt, 0); sqlite3_finalize(stmt); /* Next kara with priority > 1 */ SQLITE_PREPARE(db, stmt, SQL_GET_POS_WITH_PRIO_SUP_1, error); SQLITE_STEP_ROW(db, stmt, error); - next_kara_with_prio_sup_1 = sqlite3_column_int64(stmt, 1); - priority_to_back_propagate = sqlite3_column_int(stmt, 2); + next_kara_with_prio_sup_1 = sqlite3_column_int64(stmt, 0); + priority_to_back_propagate = sqlite3_column_int(stmt, 1); sqlite3_finalize(stmt); + LOG_DEBUG("DB", "Update priorities to %d from position %ld to %ld", priority_to_back_propagate, + currently_playing_position, next_kara_with_prio_sup_1); + /* Back-propagate the priority */ SQLITE_PREPARE(db, stmt, SQL_APPLY_PRIORITY_TO_RANGE, error); - SQLITE_BIND_INT(db, stmt, 0, priority_to_back_propagate, error); - SQLITE_BIND_INT64(db, stmt, 1, currently_playing_position, error); - SQLITE_BIND_INT64(db, stmt, 2, next_kara_with_prio_sup_1, error); + SQLITE_BIND_INT(db, stmt, 1, priority_to_back_propagate, error); + SQLITE_BIND_INT64(db, stmt, 2, currently_playing_position, error); + SQLITE_BIND_INT64(db, stmt, 3, next_kara_with_prio_sup_1, error); SQLITE_STEP_DONE(db, stmt, error); sqlite3_finalize(stmt); @@ -590,6 +593,7 @@ error: * - No kara with priority > 1 after the playing one, no need to * backpropagate the priority. */ not_playing_or_no_need_to_back_propagate: + LOG_DEBUG("DB", "Don't need to back propagate priorities!"); if (stmt != NULL) sqlite3_finalize(stmt); return true;