]> git.ipfire.org Git - thirdparty/postgresql.git/commit
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)
commit30a35bca3f9306f87ca8db095ddac2ba62156934
treec480327fb0ce2385cfc6c9fb2f7e05ac6e8405ad
parente48f2afee631be42739e50fbefd758503e8dcf82
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