On a server running MySql 5.0.27, with a very simple query that uses REPLACE —
SELECT familyname, replace('{0} test' , '{0}', `familyname`) AS `formattedname`
FROM family
I get a result where the second column has only been evaluated once:
familyname formattedname
Andersen Andersen test
Baker Andersen test
Charles Andersen test
On a development machine running MySql 5.5.9, same query and data, the results are as I would expect:
Andersen Andersen test
Baker Baker test
Charles Charles test
Is this a MySql bug in the older version, or is there some other possibility (a server misconfiguration, an index error, etc?).
Thanks!
This is a known bug. It was reported here.
Either you can live with it, or you need to upgrade at least to MySQL 5.1.
And if your software is compatible, why not upgrade to MySQL 5.5?
I found the bug report using the search engine in the Mysql bugs database.