Mysql: fix _dberror to raise tha appropriate values

Pull request build on top of https://github.com/dmwm/WMCore/pull/4875 (and including its code)

CRAB3 postjob check the return message of the filemetadata PUT and tries a POST it the file already exist. This was not working without the commit in this pull.