mysql: replace all "cast(foo as integer)" to "cast(foo as signed integer)" and not just the first one #4331

Merged
merged 1 commit into from Mar 8, 2014

Conversation

Projects
None yet
3 participants
Owner

Montellese commented Mar 4, 2014

The current code in the MySQL db wrapper has some logic to replace

cast(foo as integer)

with

cast(foo as signed integer)

in SQL queries because MySQL doesn't understand the first one (SQLite does). But the logic that takes care of this is only applied once so if there are multiple occurances that need to be fixed only the first is caught and the rest isn't which results in invalid SQL queries on MySQL.

@koying: Would you mind testing this? Easiest is probably to create a smartplaylist for movies and add two rules for the runtime/duration (which is movie.c11 and results in the usage of above SQL snippets).

Owner

koying commented Mar 8, 2014

Sorry for late reply.
Does this come from an actual issue or is it a potential one?

Anyway, you produce an endless loop, don't you?
"as signed signed signed ... integer"

Member

jmarshallnz commented Mar 8, 2014

It's matching "as integer" which doesn't happen once "signed" is inserted into it.

Owner

Montellese commented Mar 8, 2014

It's an actual issue with smartplaylists using multiple conditions on playcount, duration or any other integer field. And I don't create an infinite loop because I'm looking for "as integer)" and then replace it with "as signed integer)" so the previous search doesn't match that part anymore.

Owner

koying commented Mar 8, 2014

Yeah, was about to retract the endless loop part ;)
Fine for me.

Owner

koying commented Mar 8, 2014

PS If you prefer an actual test, you'll have to consider me as an end-user as I never used smartplaylists at all ;)

Owner

Montellese commented Mar 8, 2014

This is the actual ticket: http://trac.xbmc.org/ticket/14496

@koying: an actual test would be nice. Just put http://pastebin.com/UJNUniwU into your userdata/playlists/video/ directory and choose some filename ending with ".xsp". Then go into XBMC, Videos -> Library -> Playlists and open the "randomunplayedmovie" item. Then please check your logs for the appropraite GetMoviesByWhere call for that smartplaylist.

Owner

koying commented Mar 8, 2014

Thanks.
Confirmed ok.

@jmarshallnz jmarshallnz added a commit that referenced this pull request Mar 8, 2014

@jmarshallnz jmarshallnz Merge pull request #4331 from Montellese/mysql_integer_cast_fix
mysql: replace all "cast(foo as integer)" to "cast(foo as signed integer)" and not just the first one
eb45236

@jmarshallnz jmarshallnz merged commit eb45236 into xbmc:master Mar 8, 2014

Member

jmarshallnz commented Mar 8, 2014

Thanks :)

jmarshallnz removed the Gotham label Mar 8, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment