Re: PL/PgSQL STRICT

From: "David Johnston" <polobo(at)yahoo(dot)com>
To: "'Marko Tiikkaja'" <pgmail(at)joh(dot)to>, "'Tom Lane'" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "'PostgreSQL-development'" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: PL/PgSQL STRICT
Date: 2012-12-21 16:13:20
Message-ID: 009601cddf96$1ab06a30$50113e90$@yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> -----Original Message-----
> From: pgsql-hackers-owner(at)postgresql(dot)org [mailto:pgsql-hackers-
> owner(at)postgresql(dot)org] On Behalf Of Marko Tiikkaja
> Sent: Friday, December 21, 2012 10:53 AM
> To: Tom Lane
> Cc: PostgreSQL-development
> Subject: Re: [HACKERS] PL/PgSQL STRICT
>
> On 12/21/12 4:49 PM, I wrote:
> > On 12/21/12 4:39 PM, Tom Lane wrote:
> >> What is the use-case for this?
> >
> > Currently, the way to do this would be something like:
>
> I realize I didn't really answer the question.
>
> The use case is when you're UPDATEing or DELETEing a row and you want to
> quickly assert that there should be exactly one row. For example, if
you've
> previously locked a row with SELECT .. FOR UPDATE, and now you want to
> UPDATE or DELETE it, it better be there (or you have a bug somewhere).

There had better be exactly one row - but who cares whether that is the row
we were actually expecting to delete/update...

I've recently had the experience of missing a "WHERE pk = ..." clause in an
UPDATE statement inside a function so I do see the value in having an "easy
to implement" safety idiom along these lines.

Along the lines of "EXPLAIN (options) CMD" would something like
"UPDATE|DELETE (STRICT) identifier" work?

David J.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2012-12-21 16:22:03 Re: PL/PgSQL STRICT
Previous Message Christopher Browne 2012-12-21 16:09:28 Re: PL/PgSQL STRICT