pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix possible loss of sync between rectypeid and underlying PLpgS
Date: Thu, 26 Dec 2019 20:19:53 +0000
Message-ID: <E1ikZbt-0007eU-IK@gemulon.postgresql.org> (raw)

Fix possible loss of sync between rectypeid and underlying PLpgSQL_type.

When revalidate_rectypeid() acts to update a stale record type OID
in plpgsql's data structures, it fixes the active PLpgSQL_rec struct
as well as the PLpgSQL_type struct it references.  However, the latter
is shared across function executions while the former is not.  In a
later function execution, the PLpgSQL_rec struct would be reinitialized
by copy_plpgsql_datums and would then contain a stale type OID,
typically leading to "could not open relation with OID NNNN" errors.
revalidate_rectypeid() can easily fix this, fortunately, just by
treating typ->typoid as authoritative.

Per report and diagnosis from Ashutosh Sharma, though this is not his
suggested fix.  Back-patch to v11 where this code came in.

Discussion: https://postgr.es/m/CAE9k0Pkd4dZwt9J5pS9xhJFWpUtqs05C9xk_GEwPzYdV=GxwWg@mail.gmail.com

Branch
------
REL_11_STABLE

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

Modified Files
--------------
src/pl/plpgsql/src/expected/plpgsql_record.out |  6 ++++++
src/pl/plpgsql/src/pl_exec.c                   | 11 ++++++++++-
src/pl/plpgsql/src/sql/plpgsql_record.sql      |  1 +
3 files changed, 17 insertions(+), 1 deletion(-)



view thread (3+ messages)  latest in thread

Message-ID: <E1ikZbt-0007eU-IK@gemulon.postgresql.org>
Permalink:  ../E1ikZbt-0007eU-IK@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1ikZbt-0007eU-IK@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Fix possible loss of sync between rectypeid and underlying PLpgS
  In-Reply-To: <E1ikZbt-0007eU-IK@gemulon.postgresql.org>
  References: <E1ikZbt-0007eU-IK@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox