Adjust SQL to work correctly with PostGres.

TABLE_SCHEMA == 'public' in Postgres so comparing it to $CFG->dbname causes no fields to be returned.