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 22:09:30
Message-ID: CAFj8pRCjQ_jKJxD2VWzNvRU+KUMA5ob03YSeWWXx6L0i1pfjiw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Dne 14. 9. 2013 23:55 "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com> napsal(a):
>
>
> 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

this is a possibility for introduction a new hook and possibility implement
asserions and similar task in generic form (as extension). it can be
assertions, tracing, profiling.

I like a integrated assertions, but I would not close a door to future
enhancing (probably there will not be a possibility intriduce a new keyword
for tracing - although I would to implement a difference between
development an production usage.

so I am against to your proposal - it doesn't allow any extensibility.

>
> >> 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 Marko Tiikkaja 2013-09-14 22:09:34 Re: Assertions in PL/PgSQL
Previous Message Pavel Stehule 2013-09-14 21:55:24 Re: Assertions in PL/PgSQL