Normal for mysql to strip trailing spaces?

I have a table users, with u_username field varchar(20)
Im using mysql v5

select u_userid from users where u_username = ‘carpii’
returns user id 17

select u_userid from users where u_username = 'carpii ’
also returns user id 17

Is this normal behavior for mysql?
Can it be changed?

That’s indeed weired… we’re using Mysql 5.0.19 and it’s the same behaviour as you describe. That also happens on 5.0.22.

If you do the same query using like instead of =,

… where u_username like 'carpi ’

it doesn’t happen. I don’t know if that is expected behaviour by ANSI standard or mysql.

Greetings
Christian

UPDATE: Guess its expected behaviour by ANSI-Standard. While looking in bugs.mysql.com I’ve found the following bug. At the end you can see a comment in the mysql source code, that says they ‘have’ to do it. )

http://bugs.mysql.com/bug.php?id=14637

Yeah,

This is far from being obvious but this is how it is designed.

See: http://www.mysql.org/doc/refman/5.1/en/char.html