Re: improve FOUND in PL/PgSQL

From: Neil Conway <nconway(at)klamath(dot)dyndns(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: improve FOUND in PL/PgSQL
Date: 2002-08-14 23:00:35
Message-ID: 87it2d82r0.fsf@klamath.dyndns.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:
> Neil Conway <nconway(at)klamath(dot)dyndns(dot)org> writes:
> > <para>
> > ! There is a special variable named <literal>FOUND</literal> of
> > ! type <type>boolean</type>. It will be set to true if:
> > ! <itemizedlist>
> > ! <listitem>
> > ! <para>
> > ! A SELECT INTO statement is executed, and it returns one or
> > ! more rows.
> > ! </para>
> > ... etc ...
>
> This is better than what we had, but still seems confusing

[...]

Ok, I made this part of the documentation more clear.

> Also the initial state of FOUND should be documented (or is that in the
> other patch?)

Nope, I forgot about that. For the moment, I've documented that the
initial state of FOUND is false -- if we want to change that to be
NULL (to match Oracle's behavior), it can be done later.

> > Unfortunately, the code is a bit less elegant than I'd like.
>
> Indeed. I don't like duplicating the loop condition test, and really
> the behavior is still wrong: IMHO the FOR statements should not touch
> FOUND at all before entering the loop. I think you could do this
> much more cleanly by introducing a local boolean:

Ah, ok -- thanks for the suggestion. It required a fair amount of
work, since I had to refactor a lot of the logic in the 3 functions
that handle PL/PgSQL FOR loops.

A revised patch is attached.

Cheers,

Neil

--
Neil Conway <neilconway(at)rogers(dot)com>
PGP Key ID: DB3C29FC

Attachment Content-Type Size
plpgsql_found-5.patch text/x-patch 19.4 KB

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2002-08-14 23:10:34 Re: improve FOUND in PL/PgSQL
Previous Message Ulrich Neumann 2002-08-14 23:00:14 Antw: Re: File for /src/backend/port/netware