Re: PL/pgSQL: SELECT INTO EXACT - Mailing list pgsql-patches

From Matt Miller
Subject Re: PL/pgSQL: SELECT INTO EXACT
Date
Msg-id 1122676993.7396.32.camel@dbamm01-linux
Whole thread Raw
In response to Re: PL/pgSQL: SELECT INTO EXACT  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-patches
On Fri, 2005-07-29 at 17:52 -0400, Tom Lane wrote:
> Matt Miller <mattm@epx.com> writes:
> > The motivation is to come closer to Oracle's SELECT INTO
> > behavior: when SELECTing INTO scalar targets,
> > raise an exception and leave the targets untouched if the query does
> > not return exactly one row.  This patch does not go so far as
> > to raise an exception

> Uh, what's the point of being only sort-of compatible?  Why not throw
> the exception?

I guess my hesitation is that the PL/SQL notion of the exception as a
program flow control technique is a bit at odds with the PL/pgSQL notion
of the exception as a transaction control mechanism.  Maybe these
notions could be reconciled by a new NOSAVE option to the EXCEPTION
block definition, to suppress the savepoint and the exception-induced
rollback for that BEGIN ... END block.  Then an automatically-thrown
exception would not be so expensive.

> I dislike the choice of "EXACT", too, as it (a) adds a new
> reserved word and (b) doesn't seem to convey quite what is
> happening anyway

The motivation is that EXACTly one row must be returned.

Maybe UNIQUE instead of EXACT?

pgsql-patches by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: [HACKERS] Autovacuum loose ends
Next
From: Matt Miller
Date:
Subject: Re: PL/pgSQL: SELECT INTO EXACT