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

From Pavel Stehule
Subject Re: Assertions in PL/PgSQL
Date
Msg-id CAFj8pRDcvURmTQspW-D3YpCCpRr36xvg1qJVLLyH6UXpoKLqbg@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
Re: Assertions in PL/PgSQL
List pgsql-hackers
<p dir="ltr"><br /> Dne 14. 9. 2013 23:35 "Marko Tiikkaja" <<a href="mailto:marko@joh.to">marko@joh.to</a>>
napsal(a):<br/> ><br /> > On 2013-09-14 23:05, Pavel Stehule wrote:<br /> >><br /> >> A some
languageshas a generic PRAGMA keyword. So I would be much more<br /> >> happy with something like<br />
>><br/> >> PRAGMA Assert(found);<br /> >><br /> >> It is much more close to ADA, and it allows
areuse of new keyword for any<br /> >> other usage in future (your proposal is too simply, without possibility<br
/>>> open new doors in future). And we can define a some standard predefined<br /> >> asserts too - like
Assert,AssertNotNull, AssertNotEmpty, ...<br /> ><br /> ><br /> > 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
theexpression is arbitrary SQL, and we'd have to do all kinds of different versions or people would be disappointed
(AssertNull,AssertNotNull, AssertExists, AssertNotExists, etc.).<br /> ><br /> > I see what you're trying to do,
butI don't think crippling new features just because we might do something similar at some point is a good idea.  I'm
guessingthis is what happened with the row_count syntax, which made the feature an absolute nightmare to use.<br /><p
dir="ltr">amore than one asserts can be my personal preferrence (it is not important). <p dir="ltr">but introduction a
reservedkeword for one very special purpose (without extensibility) is not prudent.<p dir="ltr">plpgsql has still lot
ofrelations to pl/sql and ada, and I don't think so we have to introduce a new original syntax everytime.<br /><p
dir="ltr">><br/> >> other issue - A asserts macros has one or two parameters usually. You<br /> >>
shouldto support two params assert (with message).<br /> ><br /> ><br /> > That I think is worth looking
into.<br/> ><br /> ><br /> > Regards,<br /> > Marko Tiikkaja<br /> 

pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: INSERT...ON DUPLICATE KEY LOCK FOR UPDATE
Next
From: Marko Tiikkaja
Date:
Subject: Re: Assertions in PL/PgSQL