Re: Assertions in PL/PgSQL

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Amit Khandekar <amit(dot)khandekar(at)enterprisedb(dot)com>, Jaime Casanova <jaime(at)2ndquadrant(dot)com>, Marko Tiikkaja <marko(at)joh(dot)to>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Assertions in PL/PgSQL
Date: 2013-10-09 16:57:25
Message-ID: CAFj8pRDEuX69oKxgBigBY6pKpUFsS9KDj7bQQBBm+TYiRdBuzQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello

2013/9/24 Robert Haas <robertmhaas(at)gmail(dot)com>

> On Mon, Sep 23, 2013 at 5:48 AM, Amit Khandekar
> <amit(dot)khandekar(at)enterprisedb(dot)com> wrote:
> >>> The assert levels sound a bit like a user might be confused by these
> >>> levels being present at both places: In the RAISE syntax itself, and
> the
> >>> assert GUC level. But I like the syntax. How about keeping the ASSERT
> >>> keyword optional ? When we have WHEN, we anyway mean that we ware
> asserting
> >>> that this condition must be true. So something like this :
> >>>
> >>> RAISE [ level ] 'format' [, expression [, ... ]] [ USING option =
> >>> expression [, ... ] ];
> >>> RAISE [ level ] condition_name [ USING option = expression [, ... ] ];
> >>> RAISE [ level ] SQLSTATE 'sqlstate' [ USING option = expression [, ...
> ]
> >>> ];
> >>> RAISE [ level ] USING option = expression [, ... ];
> >>> RAISE [ ASSERT ] WHEN bool_expression;
> >>> RAISE ;
> >>>
> >>
> >> I don't think so it is a good idea. WHEN clause should be independent on
> >> exception level.
> >
> >
> > I am ok with generalizing the WHEN clause across all levels. The main
> > proposal was for adding assertion support, so we can keep the WHEN
> > generalization as a nice-to-have stuff and do it only if it comes as a
> > natural extension in the assertion support patch.
>
> I think that's right: ISTM that at this point there are two different
> proposals here.
>
> 1. Allowing ASSERT as an argument to RAISE.
>
> 2. Allowing RAISE to have a WHEN clause.
>
> Those two things are logically separate. We could do either one
> without doing the other one.
>

here is a patch for RAISE WHEN clause

Regards

Pavel

>
> --
> Robert Haas
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>

Attachment Content-Type Size
plpgsql-raise-when_v1_20131009.patch application/octet-stream 14.8 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Joshua D. Drake 2013-10-09 17:02:12 Re: Auto-tuning work_mem and maintenance_work_mem
Previous Message Bruce Momjian 2013-10-09 16:56:46 Re: Auto-tuning work_mem and maintenance_work_mem