Bug 15116 - Incorrect collate on tracks_persistent after changing language
: Incorrect collate on tracks_persistent after changing language
Status: RESOLVED FIXED
Product: Logitech Media Server
Classification: Unclassified
Component: Database
: 7.4.2
: PC Other
: P3 normal with 2 votes (vote)
: 7.5.x
Assigned To: Andy Grundman
http://forums.slimdevices.com/showthr...
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-11-15 22:53 UTC by Erland Isaksson
Modified: 2010-11-03 11:35 UTC (History)
1 user (show)

See Also:
Category: ---


Attachments
Patch for playlist_track and tracks_persistent tables (332 bytes, patch)
2010-11-03 10:49 UTC, Erland Isaksson
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Erland Isaksson 2009-11-15 22:53:25 UTC
When I change the language in Squeezebox Server to some languages the tracks_persistent table in the database gets incorrect collate setting. The problem is reproducible at least by changing language to Swedish(Svenska), Norveigan(Norska), Spanish(Espanõl). It is not reproducible by changing language to German or French.

The problem is that all tables besides tracks_persistent change collate setting with you change the language setting in Squeezebox Center. The result is that tracks_persistent get a different collate setting than the tracks table making it impossible to join them in database.

I've tried to perform a full rescan and also to delete the Cache/MySQL directory but it doesn't solve the problem.

When trying to get a list of all high rated tracks like this:
select * from tracks,tracks_persistent where tracks.url=tracks_persistent.url and tracks.url and rating>80;

The database answers with:
ERROR 1267 (HY000): Illegal mix of collations (utf8_spanish_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation '='

When checking the collate setting on tracks with "show create table tracks" it looks like this (some columns removed from output to shorten it):
CREATE TABLE `tracks` (
  ...
  `url` text collate utf8_spanish_ci NOT NULL,
  ...
  `content_type` varchar(255) collate utf8_spanish_ci default NULL,
  ...
  `vbr_scale` varchar(255) collate utf8_spanish_ci default NULL,
  ...
  `tagversion` varchar(255) collate utf8_spanish_ci default NULL,
  ...
  `musicbrainz_id` varchar(40) collate utf8_spanish_ci default NULL,
  ...
  `extid` varchar(64) collate utf8_spanish_ci default NULL,
  ...
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci


When checking the collate setting on tracks_persistent with "show create table tracks_persistent" it looke like this (some columns removed from output to shorten it):
CREATE TABLE `tracks_persistent` (
  ...
  `url` text NOT NULL,
  ...
) ENGINE=InnoDB DEFAULT CHARSET=utf8

As you can see there aren't any collate setting in the database on tracks_persistent which makes it impossible to join it with other tables, for example tracks.

I haven't found any problem with the standard Squeezebox Server functionality, but that's probably just because it never joins tracks_persistent with any other tables. I'm guessing that the Song Info page just reads directly from tracks_persistent instead of joining it with tracks.

However, it makes it impossible for third party applications to retrieve lists of tracks based on data in tracks_persistent. For example:
- TrackStat plugin
- Custom Browse plugin (with TrackStat based menus)
- SQL Playlist plugin (with TrackStat based statistics)
- muso integration (with TrackStat data)


It feels like all database tables besides track_persistent is affected by the user interface language setting.
Comment 1 vagskal 2009-11-16 01:45:33 UTC
I do not want to delay the fix for this bug and I do not really know if this is related but I wanted to give references to a couple of other bugs regarding change of language in SBS:

https://bugs-archive.lyrion.org/show_bug.cgi?id=10756 (Change of language temporarily stops playback)

The sorting has been wrong for Swedish language a couple of times and the fix for that did not have effect before changing language in SBS from Swedish to English and back.
See https://bugs-archive.lyrion.org/show_bug.cgi?id=13600 (around comment #56) for 7.4 and https://bugs-archive.lyrion.org/show_bug.cgi?id=10114#c8 for 7.2 and 7.3
Comment 2 Chris Owens 2009-11-18 16:59:42 UTC
Note to self: Get Andy to talk about the ramifications of this bug at the next bug meeting.  Change importance at that time.
Comment 3 Chris Owens 2010-03-08 11:17:25 UTC
Moving P3 and lower bugs to next release target
Comment 4 Erland Isaksson 2010-11-03 10:49:46 UTC
Created attachment 7023 [details]
Patch for playlist_track and tracks_persistent tables

The attached patch solves this bug, this makes it possible to join the playlist_track and tracks_persistent tables with the other tables in the database.

I plan to start patching these tables from third party plugins unless this is included in the standard product because currently this bug makes the database pretty useless if you are using languages like Swedish, Norwegian or Spanish in the SBS web interface.
Comment 5 Andy Grundman 2010-11-03 10:58:07 UTC
Thanks, patch applied to 7.5.  I don't think it would cause a problem if you changed the collation in your plugins also, so that sounds fine to me.
Comment 6 SVN Bot 2010-11-03 10:58:53 UTC
 == Auto-comment from SVN commit #31488 to the slim repo by agrundman ==
 == http://svn.slimdevices.com/slim?view=revision&revision=31488 ==

Fixed bug 15116, patch from erland to change collation on playlist_track and tracks_persistent
Comment 7 vagskal 2010-11-03 11:35:15 UTC
Thanks, Erland!