pgsql: Fix error cleanup failure caused by 8.4 changes in plpgsql to try

From: tgl(at)postgresql(dot)org (Tom Lane)
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix error cleanup failure caused by 8.4 changes in plpgsql to try
Date: 2009-07-18 19:15:50
Message-ID: 20090718191550.AE2AB75331E@cvs.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Log Message:
-----------
Fix error cleanup failure caused by 8.4 changes in plpgsql to try to avoid
memory leakage in error recovery. We were calling FreeExprContext, and
therefore invoking ExprContextCallback callbacks, in both normal and error
exits from subtransactions. However this isn't very safe, as shown in
recent trouble report from Frank van Vugt, in which releasing a tupledesc
refcount failed. It's also unnecessary, since the resources that callbacks
might wish to release should be cleaned up by other error recovery mechanisms
(ie the resource owners). We only really want FreeExprContext to release
memory attached to the exprcontext in the error-exit case. So, add a bool
parameter to FreeExprContext to tell it not to call the callbacks.

A more general solution would be to pass the isCommit bool parameter on to
the callbacks, so they could do only safe things during error exit. But
that would make the patch significantly more invasive and possibly break
third-party code that registers ExprContextCallback callbacks. We might want
to do that later in HEAD, but for now I'll just do what seems reasonable to
back-patch.

Tags:
----
REL8_4_STABLE

Modified Files:
--------------
pgsql/src/backend/executor:
execUtils.c (r1.159 -> r1.159.2.1)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/executor/execUtils.c?r1=1.159&r2=1.159.2.1)
nodeBitmapIndexscan.c (r1.30 -> r1.30.2.1)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/executor/nodeBitmapIndexscan.c?r1=1.30&r2=1.30.2.1)
nodeIndexscan.c (r1.132 -> r1.132.2.1)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/executor/nodeIndexscan.c?r1=1.132&r2=1.132.2.1)
pgsql/src/include/executor:
executor.h (r1.155 -> r1.155.2.1)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/executor/executor.h?r1=1.155&r2=1.155.2.1)
pgsql/src/pl/plpgsql/src:
pl_exec.c (r1.244 -> r1.244.2.1)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/pl/plpgsql/src/pl_exec.c?r1=1.244&r2=1.244.2.1)

Browse pgsql-committers by date

  From Date Subject
Next Message User Dim 2009-07-18 21:17:53 preprepare - preprepare: Implement SELECT
Previous Message Tom Lane 2009-07-18 19:15:42 pgsql: Fix error cleanup failure caused by 8.4 changes in plpgsql to try