Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

[videodb] we can't use REPLACE INTO when updating values during UpdateTables #5002

Merged
merged 1 commit into from

3 participants

@jmarshallnz
Owner

Reason is analytics aren't in place. Fixes problems where a show path appearing in more than one multipath being duplicated on update (thus failing).

Fixes #15334

@Montellese mind sanity checking (it's reasonably straight-forward!)

Jonathan Marshall [videodb] we can't use REPLACE INTO when updating values during Updat…
…eTables as analytics aren't in place. fixes problems where a show path appearing in more than one multipath being duplicated on update (thus failing). fixes #15334
ab4a25b
@Montellese
Owner

Are you sure this is equivalent? REPLACE INTO either

  • adds the new value if the ID doesn't already exist
  • delete the old value with the same ID and then adds the new value if the ID already exists

Your new code just adds the new value if the ID doesn't already exist.

@jmarshallnz
Owner

In this case they're equivalent, yes, as the uniqueness is on the two fields we're querying, and the two fields we're filling. Thus, delete + add is the same as "do nothing".

@Montellese
Owner

Okay.

@jmarshallnz
Owner

Thanks :)

@jmarshallnz jmarshallnz merged commit 5f031ff into xbmc:master
@jmarshallnz jmarshallnz deleted the jmarshallnz:tvshow_multipath_update_fix branch
@MartijnKaijser MartijnKaijser added this to the Helix 14.0-alpha1 milestone
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 11, 2014
  1. [videodb] we can't use REPLACE INTO when updating values during Updat…

    Jonathan Marshall authored
    …eTables as analytics aren't in place. fixes problems where a show path appearing in more than one multipath being duplicated on update (thus failing). fixes #15334
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 1 deletion.
  1. +3 −1 xbmc/video/VideoDatabase.cpp
View
4 xbmc/video/VideoDatabase.cpp
@@ -4627,7 +4627,9 @@ void CVideoDatabase::UpdateTables(int iVersion)
for (vector<string>::const_iterator j = paths.begin(); j != paths.end(); ++j)
{
int idPath = AddPath(*j, URIUtils::GetParentPath(*j));
- m_pDS->exec(PrepareSQL("REPLACE INTO tvshowlinkpath(idShow, idPath) VALUES(%i,%i)", i->show, idPath));
+ /* we can't rely on REPLACE INTO here as analytics (indices) aren't online yet */
+ if (GetSingleValue(PrepareSQL("SELECT 1 FROM tvshowlinkpath WHERE idShow=%i AND idPath=%i", i->show, idPath)).empty())
+ m_pDS->exec(PrepareSQL("INSERT INTO tvshowlinkpath(idShow, idPath) VALUES(%i,%i)", i->show, idPath));
}
m_pDS->exec(PrepareSQL("DELETE FROM tvshowlinkpath WHERE idShow=%i AND idPath=%i", i->show, i->pathId));
}
Something went wrong with that request. Please try again.