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@postgresql.org
Subject: pgsql: Repair unsafe use of shared typecast-lookup table in plpgsql DO
Date: Sat, 15 Aug 2015 16:01:03 +0000
Message-ID: <E1ZQdtH-0006Ax-Fw@gemulon.postgresql.org> (raw)
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-committers>

Repair unsafe use of shared typecast-lookup table in plpgsql DO blocks.

DO blocks use private simple_eval_estates to avoid intra-transaction memory
leakage, cf commit c7b849a89.  I had forgotten about that while writing
commit 0fc94a5ba, but it means that expression execution trees created
within a DO block disappear immediately on exiting the DO block, and hence
can't safely be linked into plpgsql's session-wide cast hash table.
To fix, give a DO block a private cast hash table to go with its private
simple_eval_estate.  This is less efficient than one could wish, since
DO blocks can no longer share any cast lookup work with other plpgsql
execution, but it shouldn't be too bad; in any case it's no worse than
what happened in DO blocks before commit 0fc94a5ba.

Per bug #13571 from Feike Steenbergen.  Preliminary analysis by
Oleksandr Shulgin.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/83604cc42353b6c0de2a3f3ac31f94759a9326ae

Modified Files
--------------
src/pl/plpgsql/src/pl_exec.c          |   79 +++++++++++++++++++++------------
src/pl/plpgsql/src/plpgsql.h          |    4 ++
src/test/regress/expected/plpgsql.out |    7 +++
src/test/regress/sql/plpgsql.sql      |    9 ++++
4 files changed, 71 insertions(+), 28 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


view thread (2+ messages)

Message-ID: <E1ZQdtH-0006Ax-Fw@gemulon.postgresql.org>
Permalink:  ../E1ZQdtH-0006Ax-Fw@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1ZQdtH-0006Ax-Fw@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: Repair unsafe use of shared typecast-lookup table in plpgsql DO
  In-Reply-To: <E1ZQdtH-0006Ax-Fw@gemulon.postgresql.org>
  References: <E1ZQdtH-0006Ax-Fw@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