On 2014-09-09 07:54, Craig Ringer wrote:
> On 09/05/2014 05:21 PM, Pavel Stehule wrote:
>>
>> *shrug* Doing it in SQL would probably break more stuff. I'm trying to
>> contain the damage. And arguably, this is mostly only useful in PL/PgSQL.
>
> I've wanted assertions in SQL enough that I often write trivial wrappers
> around `raise` in PL/PgSQL for use in `CASE` statements etc.
Yeah, as have I. I've also advocated that there should be a
raise_exception(text, anyelement) anyelement function shipped with
postgres.
But this is something different; this is just a single statement which
asserts that some expression evaluates to true. Even if we allowed it
to be used as a scalar expression, there's still the problem anyelement
is commonly used to work around.
.marko