Re: Unable to handle error in plperl

From: Alex Hunsaker <badalex(at)gmail(dot)com>
To: Alex Lai <mlai(at)sesda3(dot)com>
Cc: "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: Unable to handle error in plperl
Date: 2013-07-11 15:47:04
Message-ID: CAFaPBrQcU4V=Hh8wXuyT-e4LMc8pocsRt6iaJX8H2brQaodZzA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Wed, Jul 10, 2013 at 2:36 PM, Alex Lai <mlai(at)sesda3(dot)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?

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message dek.mauleon 2013-07-11 18:08:07 BUG #8295: crypt() function fails randomly
Previous Message hkraju 2013-07-11 10:08:58 Re: BUG #5807: psql fails to launch with "Cannot read termcap database; using dumb terminal settings. Aborted"