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

From Marko Tiikkaja
Subject Re: Assertions in PL/PgSQL
Date
Msg-id 5234D6AB.8030206@joh.to
Whole thread Raw
In response to Re: Assertions in PL/PgSQL  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: Assertions in PL/PgSQL
List pgsql-hackers
On 2013-09-14 23:05, Pavel Stehule wrote:
> 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, ...

I don't see why e.g. PRAGMA AssertNotEmpty(foo);  would be better than 
ASSERT NotEmpty(foo);  and the NotNull version is even sillier 
considering the expression is arbitrary SQL, and we'd have to do all 
kinds of different versions or people would be disappointed (AssertNull, 
AssertNotNull, AssertExists, AssertNotExists, etc.).

I see what you're trying to do, but I don't think crippling new features 
just because we might do something similar at some point is a good idea.  I'm guessing this is what happened with the
row_countsyntax, which 
 
made the feature an absolute nightmare to use.

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

That I think is worth looking into.


Regards,
Marko Tiikkaja



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: [PATCH] bitmap indexes
Next
From: Andres Freund
Date:
Subject: Re: INSERT...ON DUPLICATE KEY LOCK FOR UPDATE