pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #16405: Exception P0004 not caught in EXCEPTION WHEN OTHERS
3+ messages / 3 participants
[nested] [flat]

* BUG #16405: Exception P0004 not caught in EXCEPTION WHEN OTHERS
@ 2020-04-30 16:07  PG Bug reporting form <noreply@postgresql.org>
  0 siblings, 1 reply; 3+ messages in thread

From: PG Bug reporting form @ 2020-04-30 16:07 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: jacobcrell@gmail.com

The following bug has been logged on the website:

Bug reference:      16405
Logged by:          Jacob Crell
Email address:      jacobcrell@gmail.com
PostgreSQL version: 10.0
Operating system:   AWS Aurora
Description:        

Create below function to return assertion failue:
CREATE OR REPLACE FUNCTION assert_fail()
RETURNS void
LANGUAGE plpgsql
AS $function$
BEGIN
    ASSERT FALSE, 'Assertion Failed';
END;
$function$;

Create this function to call above function and catch error:
CREATE OR REPLACE FUNCTION catch_assert_fail()
RETURNS text
LANGUAGE plpgsql
AS $function$
BEGIN
   SELECT * FROM meta.assert_fail();
   RETURN 'Function Finished';
   EXCEPTION WHEN OTHERS THEN
        RETURN 'Hit the Other exception block';
END;
$function$;

Run below to call function
SELECT * FROM catch_assert_fail()

Excepted Behavior: P0004 exception is caught in EXCEPTION WHEN OTHERS,
function returns text 'Hit the Other exception block'.
Actual Behavior: P0004 exception is raised and remains uncaught.



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: BUG #16405: Exception P0004 not caught in EXCEPTION WHEN OTHERS
@ 2020-04-30 17:04  Tom Lane <tgl@sss.pgh.pa.us>
  parent: PG Bug reporting form <noreply@postgresql.org>
  0 siblings, 1 reply; 3+ messages in thread

From: Tom Lane @ 2020-04-30 17:04 UTC (permalink / raw)
  To: jacobcrell@gmail.com; +Cc: pgsql-bugs@lists.postgresql.org

PG Bug reporting form <noreply@postgresql.org> writes:
> Excepted Behavior: P0004 exception is caught in EXCEPTION WHEN OTHERS,
> function returns text 'Hit the Other exception block'.
> Actual Behavior: P0004 exception is raised and remains uncaught.

That's intentional, per the documentation [1]:

    The special condition name OTHERS matches every error type except
    QUERY_CANCELED and ASSERT_FAILURE. (It is possible, but often unwise,
    to trap those two error types by name.)

			regards, tom lane

[1] https://www.postgresql.org/docs/current/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING





^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: BUG #16405: Exception P0004 not caught in EXCEPTION WHEN OTHERS
@ 2020-04-30 17:15  Jacob Crell <jacobcrell@gmail.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 3+ messages in thread

From: Jacob Crell @ 2020-04-30 17:15 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-bugs@lists.postgresql.org

Thanks for the reply Tom! Makes sense.



On Thu, Apr 30, 2020 at 12:04 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:

> PG Bug reporting form <noreply@postgresql.org> writes:
> > Excepted Behavior: P0004 exception is caught in EXCEPTION WHEN OTHERS,
> > function returns text 'Hit the Other exception block'.
> > Actual Behavior: P0004 exception is raised and remains uncaught.
>
> That's intentional, per the documentation [1]:
>
>     The special condition name OTHERS matches every error type except
>     QUERY_CANCELED and ASSERT_FAILURE. (It is possible, but often unwise,
>     to trap those two error types by name.)
>
>                         regards, tom lane
>
> [1]
> https://www.postgresql.org/docs/current/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING
>

^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2020-04-30 17:15 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-04-30 16:07 BUG #16405: Exception P0004 not caught in EXCEPTION WHEN OTHERS PG Bug reporting form <noreply@postgresql.org>
2020-04-30 17:04 ` Tom Lane <tgl@sss.pgh.pa.us>
2020-04-30 17:15   ` Jacob Crell <jacobcrell@gmail.com>

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