Re: Unable to handle error in plperl - Mailing list pgsql-bugs

From Ming Lai
Subject Re: Unable to handle error in plperl
Date
Msg-id 2094773092.6107517.1373889368214.JavaMail.root@sesda3.com
Whole thread Raw
In response to Re: Unable to handle error in plperl  (Alex Hunsaker <badalex@gmail.com>)
Responses Re: Unable to handle error in plperl  (Alex Hunsaker <badalex@gmail.com>)
List pgsql-bugs
I know how elog works.  elog only show the status, but it does not allow me to execute another query when the current
queryfails 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?

pgsql-bugs by date:

Previous
From: dek.mauleon@gmail.com
Date:
Subject: BUG #8295: crypt() function fails randomly
Next
From: Suat Suna
Date:
Subject: PostgreSQL error