xbmc/xbmc — pull request #4122 by jmarshallnz (2014-02-01 03:49:44+00:00)
Title: Separate database analytics from schema. Fixes mysql issues on update (bad indices/views/triggers)

This replaces #4066. We split the analytics (indices/views/triggers) creation away from the table creation and table updating. Instead, on update the analytics and dropped and then recreated, ensuring that we always have in-sync analytics. Previously, mysql had no triggers on update (and possibly also a lack of indices?)

The main potential gotchas are:
1. There's a separation of create statements between indices and tables, so it's a bit harder to see which tables have indexes. A bunch of code could probably be saved by having the link tables autocreate by storing their scheme in the baseclass.

2. The UpdateTables/OldVersion function operates without indices, triggers and views. Currently (and historically) this hasn't been an issue, but it might possibly be going forward. The goal of this function is to just update tables, so it is probably OK like this.

3. I've removed the return true's from the UpdateOldVersion function as in most cases it just returned true anyway. Further, the database throws on error anyway rather than returning false, and this is caught in the outer function.

@SantaFox I'd greatly appreciate your thoughts and review.
@Koying: please review the mysql stuff.
@opdenkamp: there's a couple changes to the PVR/EPG databases that could do with a look - pretty sure I got everything, but there was some odd cases of updating add-ons that might need another look.

@Montellese, @night199uk any comments most appreciated.

@MartijnKaijser, @NedScott, Some testing of this would be appreciated - in particular updating from existing Gotham alpha(11 or 12 or whatever) and from Frodo.