Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UyjXo-0002Pz-8t for pgsql-bugs@arkaria.postgresql.org; Mon, 15 Jul 2013 14:14:28 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1UyjXn-000256-M9 for pgsql-bugs@arkaria.postgresql.org; Mon, 15 Jul 2013 14:14:27 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UyhO7-0002QB-9E for pgsql-bugs@postgresql.org; Mon, 15 Jul 2013 11:56:19 +0000 Received: from franklin.sesda3.com ([4.31.164.37]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UyhO4-0007Hv-3q for pgsql-bugs@postgresql.org; Mon, 15 Jul 2013 11:56:18 +0000 Received: from localhost (localhost [127.0.0.1]) by franklin.sesda3.com (Postfix) with ESMTP id 573E7E441A; Mon, 15 Jul 2013 07:56:15 -0400 (EDT) X-DSPAM-Result: Innocent X-DSPAM-Class: Innocent X-DSPAM-Confidence: 0.87 X-DSPAM-Probability: 0.0000 X-DSPAM-Signature: N/A X-Virus-Scanned: amavisd-new at X-Spam-Flag: NO X-Spam-Score: -2.106 X-Spam-Level: X-Spam-Status: No, score=-2.106 tagged_above=-10 required=6.6 tests=[BAYES_00=-1.9, HELO_NO_DOMAIN=0.001, RDNS_NONE=0.793, DSPAM:Innocent=-1.000] autolearn=no Received: from franklin.sesda3.com ([127.0.0.1]) by localhost (franklin.sesda3.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vitD1T8T06MQ; Mon, 15 Jul 2013 07:56:10 -0400 (EDT) Received: from franklin.sesda3.com (franklin.sesda3.com [4.31.164.37]) by franklin.sesda3.com (Postfix) with ESMTP id 7FC3FE441C; Mon, 15 Jul 2013 07:56:08 -0400 (EDT) Date: Mon, 15 Jul 2013 07:56:08 -0400 (EDT) From: Ming Lai To: Alex Hunsaker Cc: pgsql-bugs@postgresql.org Message-ID: <2094773092.6107517.1373889368214.JavaMail.root@sesda3.com> In-Reply-To: Subject: Re: Unable to handle error in plperl MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [128.154.254.16] X-Mailer: Zimbra 7.2.1_GA_2790 (ZimbraWebClient - FF3.0 (Win)/7.2.1_GA_2790) X-Pg-Spam-Score: 0.4 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org I know how elog works. elog only show the status, but it does not allow me to execute another query when the current query fails because one of the invalid column was specified. Alex Lai ----- Original Message ----- From: "Alex Hunsaker" To: "Alex Lai" Cc: pgsql-bugs@postgresql.org Sent: Thursday, July 11, 2013 11:47:04 AM Subject: Re: [BUGS] Unable to handle error in plperl On Wed, Jul 10, 2013 at 2:36 PM, Alex Lai wrote: > Dear all, > > I have a situation. I am unable to pass control back to the function once > it hit the "undefined_column" error code. > I am not sure there's a way to return '123' instead exit from the function. > > Here is my code > > CREATE OR REPLACE FUNCTION foo() RETURNS text as $$ > my $sql = ""; > my $status = ""; > my $r = ""; > $sql = 'SELECT non_exist_column from a_table limit 1'; > eval { spi_exec_query($sql);}; > if ($@) { > $status = 'invalid: '.$@; > elog(ERROR, $status); Its this bit here that is tripping you up. Perhaps you meant elog(INFO, ...) or something? -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs