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: Prevent clobbering of utility statements in SQL function caches.
Date: Tue, 29 Nov 2022 16:46:47 +0000
Message-ID: <E1p03kt-001Jli-0e@gemulon.postgresql.org> (raw)

Prevent clobbering of utility statements in SQL function caches.

This is an oversight in commit 7c337b6b5: I apparently didn't think
about the possibility of a SQL function being executed multiple
times within a query.  In that case, functions.c's primitive caching
mechanism allows the same utility parse tree to be presented for
execution more than once.  We have to tell ProcessUtility to make
a working copy of the parse tree, or bad things happen.

Normally I'd add a regression test, but I think the reported crasher
is dependent on some rather random implementation choices that are
nowhere near functions.c, so its usefulness as a long-lived test
feels questionable.  In any case, this fix is clearly correct given
the design choices of 7c337b6b5.

Per bug #17702 from Xin Wen.  Thanks to Daniel Gustafsson for
analysis.  Back-patch to v14 where the faulty commit came in
(before that, the responsibility for copying scribble-able
utility parse trees lay elsewhere).

Discussion: https://postgr.es/m/17702-ad24fdcdd1e9047a@postgresql.org

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/5dfc2b753b0f40ea036bcf621f827b800a422aac

Modified Files
--------------
src/backend/executor/functions.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)



view thread (3+ messages)  latest in thread

Message-ID: <E1p03kt-001Jli-0e@gemulon.postgresql.org>
Permalink:  ../E1p03kt-001Jli-0e@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1p03kt-001Jli-0e@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: Prevent clobbering of utility statements in SQL function caches.
  In-Reply-To: <E1p03kt-001Jli-0e@gemulon.postgresql.org>
  References: <E1p03kt-001Jli-0e@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