Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 25A551337B84 for ; Fri, 29 Oct 2010 11:40:20 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 77531-08-2 for ; Fri, 29 Oct 2010 14:40:13 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id C38B71337BD0 for ; Fri, 29 Oct 2010 11:40:12 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id o9TEeCEw001363; Fri, 29 Oct 2010 10:40:12 -0400 (EDT) To: Sergey Konoplev cc: Dragos Valentin Moinescu , pgsql-admin@postgresql.org Subject: Re: plpythonu: how to catch plpy.execute() exceptions In-reply-to: References: Comments: In-reply-to Sergey Konoplev message dated "Fri, 29 Oct 2010 17:59:11 +0400" Date: Fri, 29 Oct 2010 10:40:12 -0400 Message-ID: <1362.1288363212@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201010/211 X-Sequence-Number: 35952 Sergey Konoplev writes: > On 29 October 2010 17:02, Dragos Valentin Moinescu > wrote: >> The thing is that I cannot catch the exception raised by plpy.execute(). > I came to this plpython function template. It handles errors properly > and works faster then usual function because of the code caching. Really? As far as I can see, it's entirely impossible for a plpython function to trap and recover from an error in plpy.execute. It can continue to run plain python code, but it won't be allowed to call plpy.execute again, and the error will be rethrown when control exits the function. There's no way to fix that short of setting up subtransactions, which is what the other PLs do. regards, tom lane