Re: Assertions in PL/PgSQL - Mailing list pgsql-hackers

From Pavel Stehule
Subject Re: Assertions in PL/PgSQL
Date
Msg-id CAFj8pRBy=wjkGL2bmntQVE2uYX4A5EQBGJRyKytwbtuTPaC-qA@mail.gmail.com
Whole thread Raw
In response to Re: Assertions in PL/PgSQL  (Marko Tiikkaja <marko@joh.to>)
Responses Re: Assertions in PL/PgSQL
List pgsql-hackers



2013/9/14 Marko Tiikkaja <marko@joh.to>
On 2013-09-14 22:40, I wrote:
Someone may prove me wrong here, but to me it looks like this would only
prevent ASSERT from being used as the name of a PL/PgSQL variable.

The comment at the beginning of pl_scanner.c seems to suggest same.

yes, there are no too much possibilities, how to do it.

Effective implementation needs a special PLpgSQL statement - but I am 100% happy with proposed syntax. We introduce a new special keyword just for one simple construct.

A some languages has a generic PRAGMA keyword. So I would be much more happy with something like

PRAGMA Assert(found);
 
It is much more close to ADA, and it allows a reuse of new keyword for any other usage in future (your proposal is too simply, without possibility open new doors in future). And we can define a some standard predefined asserts too - like Assert, AssertNotNull, AssertNotEmpty, ...

other issue - A asserts macros has one or two parameters usually. You should to support two params assert (with message).



Regards,
Marko Tiikkaja

pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: logical changeset generation v6
Next
From: Andres Freund
Date:
Subject: Re: [RFC] Extend namespace of valid guc names