Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id E8B69632FAB for ; Sat, 18 Jul 2009 16:15:54 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 01705-02 for ; Sat, 18 Jul 2009 16:15:41 -0300 (ADT) Received: from cvs.postgresql.org (cvs.postgresql.org [217.196.146.206]) by mail.postgresql.org (Postfix) with ESMTP id 4AAE46325D7 for ; Sat, 18 Jul 2009 16:15:44 -0300 (ADT) Received: by cvs.postgresql.org (Postfix, from userid 1007) id 752C875331E; Sat, 18 Jul 2009 19:15:42 +0000 (UTC) MIME-Version: 1.0 To: pgsql-committers@postgresql.org Subject: pgsql: Fix error cleanup failure caused by 8.4 changes in plpgsql to try X-Mailer: activitymail 1.24, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain Message-Id: <20090718191542.752C875331E@cvs.postgresql.org> Date: Sat, 18 Jul 2009 19:15:42 +0000 (UTC) From: tgl@postgresql.org (Tom Lane) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.002 tagged_above=0 required=5 tests=AWL=0.002 X-Spam-Level: X-Archive-Number: 200907/156 X-Sequence-Number: 37759 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. Modified Files: -------------- pgsql/src/backend/executor: execUtils.c (r1.159 -> r1.160) (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/executor/execUtils.c?r1=1.159&r2=1.160) nodeBitmapIndexscan.c (r1.30 -> r1.31) (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/executor/nodeBitmapIndexscan.c?r1=1.30&r2=1.31) nodeIndexscan.c (r1.132 -> r1.133) (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/executor/nodeIndexscan.c?r1=1.132&r2=1.133) pgsql/src/include/executor: executor.h (r1.155 -> r1.156) (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/executor/executor.h?r1=1.155&r2=1.156) pgsql/src/pl/plpgsql/src: pl_exec.c (r1.244 -> r1.245) (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/pl/plpgsql/src/pl_exec.c?r1=1.244&r2=1.245)