Fixed #21504 -- Don't shadow database errors when testing for postgis version.

Thanks to trac user paultag for the report.