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: Fix plpgsql's handling of "simple" expression evaluation.
Date: Thu, 28 Oct 2010 17:03:55 +0000
Message-ID: <E1PBVtL-0007vN-7K@gemulon.postgresql.org> (raw)

Fix plpgsql's handling of "simple" expression evaluation.

In general, expression execution state trees aren't re-entrantly usable,
since functions can store private state information in them.
For efficiency reasons, plpgsql tries to cache and reuse state trees for
"simple" expressions.  It can get away with that most of the time, but it
can fail if the state tree is dirty from a previous failed execution (as
in an example from Alvaro) or is being used recursively (as noted by me).

Fix by tracking whether a state tree is in use, and falling back to the
"non-simple" code path if so.  This results in a pretty considerable speed
hit when the non-simple path is taken, but the available alternatives seem
even more unpleasant because they add overhead in the simple path.  Per
idea from Heikki.

Back-patch to all supported branches.

Branch
------
REL8_1_STABLE

Details
-------
http://git.postgresql.org/gitweb?p=postgresql.git;a=commitdiff;h=c0486e9dea9135d434b0451becab91bee28...

Modified Files
--------------
src/pl/plpgsql/src/pl_exec.c          |   20 +++++++++++++-
src/pl/plpgsql/src/plpgsql.h          |    8 +++--
src/test/regress/expected/plpgsql.out |   47 +++++++++++++++++++++++++++++++++
src/test/regress/sql/plpgsql.sql      |   42 +++++++++++++++++++++++++++++
4 files changed, 113 insertions(+), 4 deletions(-)



view thread (12+ messages)  latest in thread

Message-ID: <E1PBVtL-0007vN-7K@gemulon.postgresql.org>
Permalink:  ../E1PBVtL-0007vN-7K@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1PBVtL-0007vN-7K@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 using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Fix plpgsql's handling of "simple" expression evaluation.
  In-Reply-To: <E1PBVtL-0007vN-7K@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