Re: Assertions in PL/PgSQL

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Marko Tiikkaja <marko(at)joh(dot)to>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Assertions in PL/PgSQL
Date: 2013-09-14 21:55:24
Message-ID: CAFj8pRDcvURmTQspW-D3YpCCpRr36xvg1qJVLLyH6UXpoKLqbg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Dne 14. 9. 2013 23:35 "Marko Tiikkaja" <marko(at)joh(dot)to> napsal(a):
>
> 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_count syntax, which made
the feature an absolute nightmare to use.

a more than one asserts can be my personal preferrence (it is not
important).

but introduction a reserved keword for one very special purpose (without
extensibility) is not prudent.

plpgsql has still lot of relations to pl/sql and ada, and I don't think so
we have to introduce a new original syntax everytime.

>
>> 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2013-09-14 22:09:30 Re: Assertions in PL/PgSQL
Previous Message Andres Freund 2013-09-14 21:36:14 Re: INSERT...ON DUPLICATE KEY LOCK FOR UPDATE