pgsql: Fix crash in postgres_fdw for provably-empty remote UPDATE/DELET

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix crash in postgres_fdw for provably-empty remote UPDATE/DELET
Date: 2021-07-07 19:21:34
Message-ID: E1m1D70-0008FC-D0@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/b9734c13f168ef0d487aa122e486ca9b6dd6aa59

Modified Files
--------------
contrib/postgres_fdw/expected/postgres_fdw.out | 20 ++++++++++++++++++++
contrib/postgres_fdw/postgres_fdw.c | 4 +++-
contrib/postgres_fdw/sql/postgres_fdw.sql | 4 ++++
3 files changed, 27 insertions(+), 1 deletion(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2021-07-08 07:52:15 pgsql: Improve error messages about mismatching relkind
Previous Message Fujii Masao 2021-07-07 12:56:35 pgsql: doc: Fix description about pg_stat_statements.track_planning.