[postgres] handle DISTINCT correctly with backwards-compat (fixes #418)
code is loosely based AR 4.0 accounting for compat and Ruby 1.8