Fix crash in postgres_fdw for provably-empty remote UPDATE/DELETE.
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 7 Jul 2021 19:21:25 +0000 (15:21 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 7 Jul 2021 19:21:25 +0000 (15:21 -0400)
commitb9734c13f168ef0d487aa122e486ca9b6dd6aa59
tree0076995b29ba2dd520431156e29b276d7c56d8fb
parent9d2a7757347cb1adb48599fce4dcde0f1fc9e9ae
Fix crash in postgres_fdw for provably-empty remote UPDATE/DELETE.

In 86dc90056, I'd written find_modifytable_subplan with the assumption
that if the immediate child of a ModifyTable is a Result, it must be
a projecting Result with a subplan.  However, if the UPDATE or DELETE
has a provably-constant-false WHERE clause, that's not so: we'll
generate a dummy subplan with a childless Result.  Add the missing
null-check so we don't crash on such cases.

Per report from Alexander Pyhalov.

Discussion: https://postgr.es/m/b9a6f53549456b2f3e2fd150dcd79d72@postgrespro.ru
contrib/postgres_fdw/expected/postgres_fdw.out
contrib/postgres_fdw/postgres_fdw.c
contrib/postgres_fdw/sql/postgres_fdw.sql