Peter,
Unfortunately, the only way to clear a mysql_error seems to be to run another of php's mysql function (like another query() or mysql_ping ()) or by closing the connection so my catch has to do something pretty inefficient to work around this.
Thanks for reporting this - few direct calls to mysql_error() slipped in lately, I've replaced them with Database::lastErrno() and Database::lastError() which deal with connection contexts properly. Fixed in 15645.
Domas