pgsql: Run a portal's cleanup hook immediately when pushing it to FAILE

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Run a portal's cleanup hook immediately when pushing it to FAILE
Date: 2012-02-15 21:19:10
Message-ID: E1RxmFq-0007ZQ-Of@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Run a portal's cleanup hook immediately when pushing it to FAILED state.

This extends the changes of commit 6252c4f9e201f619e5eebda12fa867acd4e4200e
so that we run the cleanup hook earlier for failure cases as well as
success cases. As before, the point is to avoid an assertion failure from
an Assert I added in commit a874fe7b4c890d1fe3455215a83ca777867beadd, which
was meant to check that no user-written code can be called during portal
cleanup. This fixes a case reported by Pavan Deolasee in which the Assert
could be triggered during backend exit (see the new regression test case),
and also prevents the possibility that the cleanup hook is run after
portions of the portal's state have already been recycled. That doesn't
really matter in current usage, but it foreseeably could matter in the
future.

Back-patch to 9.1 where the Assert in question was added.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/4bfe68dfab009ce8fcaea79dc0832eadf3380051

Modified Files
--------------
src/backend/commands/portalcmds.c | 8 +++-
src/backend/tcop/pquery.c | 6 ++--
src/backend/utils/mmgr/portalmem.c | 53 ++++++++++++++++++++++++----
src/include/utils/portal.h | 1 +
src/test/regress/expected/transactions.out | 33 ++++-------------
src/test/regress/sql/transactions.sql | 13 ++++---
6 files changed, 72 insertions(+), 42 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Robert Haas 2012-02-16 16:52:14 pgsql: Invent on_exit_nicely for pg_dump.
Previous Message Robert Haas 2012-02-15 20:54:14 Re: [COMMITTERS] pgsql: Speed up in-memory tuplesorting.