pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter_e@gmx.net>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix assert in nested SQL procedure call
Date: Fri, 06 Jul 2018 21:38:26 +0000
Message-ID: <E1fbYQs-0001Nc-BY@gemulon.postgresql.org> (raw)

Fix assert in nested SQL procedure call

When executing CALL in PL/pgSQL, we need to set a snapshot before
invoking the to-be-called procedure.  Otherwise, the to-be-called
procedure might end up running without a snapshot.  For LANGUAGE SQL
procedures, this would result in an assertion failure.  (For most other
languages, this is usually not a problem, because those use SPI and SPI
sets snapshots in most cases.)  Setting the snapshot restores the
behavior of how CALL worked when it was handled as a generic SQL
statement in PL/pgSQL (exec_stmt_execsql()).

This change revealed another problem:  In SPI_commit(), we popped the
active snapshot before committing the transaction, to avoid "snapshot %p
still active" errors.  However, there is no particular reason why only
at most one snapshot should be on the stack.  So change this to pop all
active snapshots instead of only one.

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/2e78c5b522a91c7893decd92d6f5b31fef0027bd

Modified Files
--------------
src/backend/executor/spi.c                         |  7 ++++-
.../plpgsql/src/expected/plpgsql_transaction.out   | 19 +++++++++++++
src/pl/plpgsql/src/pl_exec.c                       | 32 ++++++++++++++++++----
src/pl/plpgsql/src/sql/plpgsql_transaction.sql     | 20 ++++++++++++++
4 files changed, 72 insertions(+), 6 deletions(-)



view thread (2+ messages)  latest in thread

Message-ID: <E1fbYQs-0001Nc-BY@gemulon.postgresql.org>
Permalink:  ../E1fbYQs-0001Nc-BY@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1fbYQs-0001Nc-BY@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: peter_e@gmx.net
  Subject: Re: pgsql: Fix assert in nested SQL procedure call
  In-Reply-To: <E1fbYQs-0001Nc-BY@gemulon.postgresql.org>
  References: <E1fbYQs-0001Nc-BY@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