]> granicus.if.org Git - postgresql/commit
postgres_fdw: don't push ORDER BY with no vars (bug #15352)
authorAndrew Gierth <rhodiumtoad@postgresql.org>
Tue, 28 Aug 2018 13:43:51 +0000 (14:43 +0100)
committerAndrew Gierth <rhodiumtoad@postgresql.org>
Tue, 28 Aug 2018 14:04:24 +0000 (15:04 +0100)
commit64eed263ac474433d17f05b23df3018a38e71fca
tree81f6229622cc150e8e2229819058d5965be8515a
parentf6f61d937bfddbe2a5f6a37bc26a0587117d7837
postgres_fdw: don't push ORDER BY with no vars (bug #15352)

Commit aa09cd242 changed a condition in find_em_expr_for_rel from
being a bms_equal comparison of relids to bms_is_subset, in order to
support order by clauses on foreign joins. But this also allows
through the degenerate case of expressions with no Vars at all (and
hence empty relids), including integer constants which will be parsed
unexpectedly on the remote (viz. "ERROR: ORDER BY position 0 is not in
select list" as in the bug report).

Repair by adding an additional !bms_is_empty test.

Backpatch through to 9.6 where the aforementioned change was made.

Per bug #15352 from Maksym Boguk; analysis and patch by me.

Discussion: https://postgr.es/m/153518420278.1478.14875560810251994661@wrigleys.postgresql.org
contrib/postgres_fdw/postgres_fdw.c