AaronCrane.co.uk

MySQL whitespace insanity

Here’s some astonishingly bad MySQL insanity. (I know I rant about MySQL lossage a lot, but that’s because there’s just so much of it to rant about.)

mysql> select id, label, concat('[', label, ']') as literal
mysql> from tag where label = 'gpl' \G
*************************** 1. row ***************************
     id: 255649
  label: gpl
literal: [gpl ]

For the record, the column is of type varchar(255) character set utf8 collate utf8_bin — not char(N), and certainly not char(4). I don’t know how better I can tell MySQL that I really really care about equality of the actual values I’m trying to store in this column.

I’m prepared to believe that this is merely a bug in our particular point-release of the server, rather than a fundamental design flaw, but that doesn’t stop it being incredibly hateful: if I’m looking for something equal to an exemplar, then, no, something vaguely similar is not sufficient.