quote identifiers in queries

I'm not sure why identifier quoting was omitted upstream in the first place. This patch might not be extensive: there could be places where queries are composed without passing identifiers through `opt.quote_name`.