pgsql: Fix null-pointer crash in postgres_fdw's conversion_error_callba

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix null-pointer crash in postgres_fdw's conversion_error_callba
Date: 2021-10-06 19:50:47
Message-ID: E1mYCwB-0006zo-89@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix null-pointer crash in postgres_fdw's conversion_error_callback.

Commit c7b7311f6 adjusted conversion_error_callback to always use
information from the query's rangetable, to avoid doing catalog lookups
in an already-failed transaction. However, as a result of the utterly
inadequate documentation for make_tuple_from_result_row, I failed to
realize that fsstate could be NULL in some contexts. That led to a
crash if we got a conversion error in such a context. Fix by falling
back to the previous coding when fsstate is NULL. Improve the
commentary, too.

Per report from Andrey Borodin. Back-patch to 9.6, like the previous
patch.

Discussion: https://postgr.es/m/08916396-55E4-4D68-AB3A-BD6066F9E5C0@yandex-team.ru

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/3071bbfe44f36019710190a9273ad2bd4a947878

Modified Files
--------------
contrib/postgres_fdw/expected/postgres_fdw.out | 3 +
contrib/postgres_fdw/postgres_fdw.c | 108 +++++++++++++++++--------
contrib/postgres_fdw/sql/postgres_fdw.sql | 1 +
3 files changed, 77 insertions(+), 35 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2021-10-07 01:12:58 pgsql: Refactor per-destination file rotation in logging collector
Previous Message Tom Lane 2021-10-06 18:36:56 Re: pgsql: Avoid doing catalog lookups in postgres_fdw's conversion_error_c