pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ming Lai <mlai@sesda3.com>
To: Alex Hunsaker <badalex@gmail.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: Unable to handle error in plperl
Date: Mon, 15 Jul 2013 07:56:08 -0400 (EDT)
Message-ID: <2094773092.6107517.1373889368214.JavaMail.root@sesda3.com> (raw)
In-Reply-To: <CAFaPBrQcU4V=Hh8wXuyT-e4LMc8pocsRt6iaJX8H2brQaodZzA@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

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" <badalex@gmail.com>
To: "Alex Lai" <mlai@sesda3.com>
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 <mlai@sesda3.com> 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



view thread (4+ messages)  latest in thread

Message-ID: <2094773092.6107517.1373889368214.JavaMail.root@sesda3.com>
Permalink:  ../2094773092.6107517.1373889368214.JavaMail.root@sesda3.com/
Also on:    postgresql.org/message-id/2094773092.6107517.1373889368214.JavaMail.root@sesda3.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: mlai@sesda3.com, badalex@gmail.com
  Subject: Re: Unable to handle error in plperl
  In-Reply-To: <2094773092.6107517.1373889368214.JavaMail.root@sesda3.com>
  References: <CAFaPBrQcU4V=Hh8wXuyT-e4LMc8pocsRt6iaJX8H2brQaodZzA@mail.gmail.com> <2094773092.6107517.1373889368214.JavaMail.root@sesda3.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox