Merge pull request #243 from vanderhoorn/patch-1

PostgreSQL bugfix for invalid SQL in subqueries