Re: Assertions in PL/PgSQL

From: Marko Tiikkaja <marko(at)joh(dot)to>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Assertions in PL/PgSQL
Date: 2013-09-14 21:35:39
Message-ID: 5234D6AB.8030206@joh.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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_count syntax, 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2013-09-14 21:36:14 Re: INSERT...ON DUPLICATE KEY LOCK FOR UPDATE
Previous Message Andres Freund 2013-09-14 21:31:30 Re: [PATCH] bitmap indexes