Re: proposal: plpgsql - Assert statement

From: Jim Nasby <Jim(dot)Nasby(at)BlueTreble(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Marko Tiikkaja <marko(at)joh(dot)to>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Simon Riggs <simon(at)2ndquadrant(dot)com>, Petr Jelinek <petr(at)2ndquadrant(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: proposal: plpgsql - Assert statement
Date: 2015-03-25 17:52:39
Message-ID: 5512F5E7.7040508@BlueTreble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 3/25/15 1:21 AM, Pavel Stehule wrote:
> 2015-03-25 0:17 GMT+01:00 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us
> <mailto:tgl(at)sss(dot)pgh(dot)pa(dot)us>>:
>
> Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com
> <mailto:pavel(dot)stehule(at)gmail(dot)com>> writes:
> > updated version with Jim Nasby's doc and rebase against last changes in
> > plpgsql.
>
> I started looking at this patch. ISTM there are some pretty
> questionable
> design decisions in it:
>
> 1. Why create a core GUC to control a behavior that's plpgsql-only?
> I think it'd make more sense for this to be a plgsql custom GUC
> (ie, "plpgsql.enable_asserts" or some such name).
>
>
> This type of assertations can be implemented in any PL language - so I
> prefer global setting. But I have not strong option in this case - this
> is question about granularity - and more ways are valid.

+1

> 2. I find the use of errdetail to report whether the assertion condition
> evaluated to FALSE or to NULL to be pretty useless. (BTW, is
> considering
> NULL to be a failure the right thing? SQL CHECK conditions consider
> NULL
> to be allowed ...)
>
>
> This is a question - I am happy with SQL CHECK for data, but I am not
> sure if same behave is safe for plpgsql (procedural) assert. More
> stricter behave is safer - and some bugs in procedures are based on
> unhandled NULLs in variables. So in this topic I prefer implemented
> behave. It is some like:

+1. I think POLA here is that an assert must be true and only true to be
valid. If someone was unhappy with that they could always coalesce(...,
true).
--
Jim Nasby, Data Architect, Blue Treble Consulting
Data in Trouble? Get it in Treble! http://BlueTreble.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2015-03-25 17:59:54 Re: deparsing utility commands
Previous Message Heikki Linnakangas 2015-03-25 17:24:26 Re: What exactly is our CRC algorithm?