pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix assert in nested SQL procedure call
2+ messages / 1 participants
[nested] [flat]

* pgsql: Fix assert in nested SQL procedure call
@ 2018-07-06 21:38 Peter Eisentraut <peter_e@gmx.net>
  0 siblings, 0 replies; 2+ messages in thread

From: Peter Eisentraut @ 2018-07-06 21:38 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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(-)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* pgsql: Fix assert in nested SQL procedure call
@ 2018-07-06 21:38 Peter Eisentraut <peter_e@gmx.net>
  0 siblings, 0 replies; 2+ messages in thread

From: Peter Eisentraut @ 2018-07-06 21:38 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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
------
REL_11_STABLE

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

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(-)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2018-07-06 21:38 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-07-06 21:38 pgsql: Fix assert in nested SQL procedure call Peter Eisentraut <peter_e@gmx.net>
2018-07-06 21:38 pgsql: Fix assert in nested SQL procedure call Peter Eisentraut <peter_e@gmx.net>

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