Re: Confused with LABEL and LOOP

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Patrick Fiche" <patrick(dot)fiche(at)aqsacom(dot)com>
Cc: "Pgsql-General (E-mail)" <pgsql-general(at)postgresql(dot)org>, Jan Wieck <JanWieck(at)Yahoo(dot)com>
Subject: Re: Confused with LABEL and LOOP
Date: 2004-10-12 14:38:24
Message-ID: 2158.1097591904@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Patrick Fiche" <patrick(dot)fiche(at)aqsacom(dot)com> writes:
> I'm a bit confused with the use of Label for loops in PostgreSQL.
> I'm using PostgreSQL 8.0 Beta2 version on WIN32 platform.

> CREATE OR REPLACE FUNCTION TEST( ) RETURNS int4 AS '
> BEGIN
> <<LOOP1>>
> LOOP
> Raise Notice ''Loop 1'';
> EXIT LOOP1;
> END LOOP;
> RETURN 0;
> END'
> LANGUAGE 'plpgsql';

> When I call SELECT TEST(), I get the error message :
> ERROR: control reached end of function without RETURN
> CONTEXT: PL/pgSQL function "test"

Hmm. I think this *should* work, and experimentation shows that it did
work up through PG 7.2. It's broken in 7.3 and later.

Jan, do you see any fine point that makes this function wrong? Sure
looks like a bug to me.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2004-10-12 14:43:09 Re: 'NOW' in UTC with no timezone
Previous Message Robin Ericsson 2004-10-12 14:38:03 Re: query gone haywire :)