Unable to add new movie to videodb after cleaning the db

Blog Category: cfzr.com — Blogged by: jack on March 11, 2010 at 8:35 pm
  • I use revision number 7969 and here's what the log says:
    15:16:23 M: 28741632 ERROR: SQLite: Abort due to constraint violation
    Query: update movie set idMovie=2 where idMovie=0
    15:16:23 M: 28741632 ERROR: CVideoDatabase::AddMovie(G:VideosMoviesMovie.mp g) failed
    To reproduce this bug, backup your videodb and delete it. Add two movies to a fresh videodb, rename or delete the first file you added, let xbmc know that you changed it (either browse to the folder the file is in and confirm the name is changed or gone or restart xbmc) and then clean your videodb. If you try to add a new movie now, you will get the above error. This will happen whenever videodb cleanup removes entries other than the last one from the movie table and xbmc then tries to give new movies a taken idMovie. I think that the problem is when you add a movie and use "sqlite3_last_insert_rowid()" to get an idMovie, you risk getting a taken one, since idMovie is not a primary key in the movie table and doesn't necessarily match rowid. So I've solved the problem temporarily on my xbox by making idMovie the primary key in 'movie' and removing the unique index 'ix_movie', since I don't think it's necessary anymore. In "AddMovie()" I replaced "insert into movie (idMovie) values (0)" with "insert into movie (idMovie) values ( NULL)"
    And removed:
    strSQL=FormatSQL("update movie set idMovie=%i where idMovie=0",lMovieId);
    m_pDS->exec(strSQL.c_str());
    This seems to work fine for me, but I guess you didn't make 'idMovie' a primary key on purpose, so maybe I've broken some other function now?:confused2:

    Also while looking for this bug I noticed what I believe are typos in "CleanDatabase()": CLog::Log(LOGDEBUG, __FUNCTION__" Cleaning genre table");
    sql = "delete from genre where idGenre not in (select distinct idGenre from genrelinkmovie)";
    m_pDS->exec(sql.c_str()); is written twice in a row and the debug message for cleaning directorlinkmovie table says "Cleaning genrelinkmovie table".

    Anyway thanks for a great app and I hope to see a fix for this.:D


  • Thanks for pointing this out :)

    Will fix ASAP.







  • #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about Unable to add new movie to videodb after cleaning the db , Please add it free.