From: | Bryn Llewellyn <bryn(at)yugabyte(dot)com> |
---|---|
To: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
Cc: | pgsql-general list <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Re: The P0004 assert_failure exception assert_failure exception seems to be unhandleable |
Date: | 2022-05-09 04:07:22 |
Message-ID: | 5857CBE7-3B3C-4023-B8C3-D179D1404209@yugabyte.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
> david(dot)g(dot)johnston(at)gmail(dot)com wrote:
>
>> bryn(at)yugabyte(dot)com wrote:
>>
>> «
>> Note that ASSERT is meant for detecting program bugs, not for reporting ordinary error conditions. Use the RAISE statement, described above, for that.
>> »
>>
>> But it takes quite a stretch of the imagination to infer that this means that the "assert_failure" exception cannot be handled.
>
> Agreed. But as the pl/pgsql section “trapping errors” notes:
>
> “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.)”
>
> i.e., you must trap it explicitly, not as part of others.
Thanks again, David. I don't yet know my way around the overall PG doc well enough to make sure that I read everything that relates to my current interest. Thanks for reminding me about this:
43.6.8. Trapping Errors
https://www.postgresql.org/docs/14/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING
in the section:
43.6. Control Structures
https://www.postgresql.org/docs/14/plpgsql-control-structures.html
in chapter:
Chapter 43. PL/pgSQL — SQL Procedural Language
https://www.postgresql.org/docs/14/plpgsql.html
All is clear now. And the caveat "It is possible, but often unwise, to trap those two error types by name" makes sense.
From | Date | Subject | |
---|---|---|---|
Next Message | Rajamoorthy-CW, Thirumurugan 8361 | 2022-05-09 06:46:36 | Need to install Postgres Version 14 in Linux server with Client and migration steps. |
Previous Message | Bryn Llewellyn | 2022-05-09 03:49:59 | Re: "A transaction cannot be ended inside a block with exception handlers." |