PLPGSQL bug in implicit SELECT

From: Kovacs Zoltan <kovacsz(at)pc10(dot)radnoti-szeged(dot)sulinet(dot)hu>
To: pgsql-hackers(at)postgresql(dot)org
Subject: PLPGSQL bug in implicit SELECT
Date: 2001-08-16 17:47:26
Message-ID: Pine.LNX.4.21.0108161936210.26864-100000@pc10.radnoti-szeged.sulinet.hu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

After more than 3 months of hard testing I found a small bug in
PLPGSQL. (It works _too_ fine due to your excellent work... :-) Thanks!)

Consider this function:

CREATE FUNCTION testfunc () RETURNS int4 AS '
declare
ret int4;
begin
ret := column1 FROM table WHERE column2 LIKE ''%anything%''
ORDER BY column3 LIMIT 1;
return ret;
end;
' LANGUAGE 'PLPGSQL';

Unfortunately I'm getting

testdb=# select testfunc();
ERROR: query "SELECT column1 FROM table WHERE column2 LIKE '%anything%'
ORDER BY column3 LIMIT 1" returned more than one column

In psql there is no such problem. My PostgreSQL version is "PostgreSQL
7.1.1 on i686-pc-linux-gnu, compiled by GCC egcs-2.91.66" patched with
four small patches (in fact I almost have a 7.1.2).

My workaround for the test function is:

CREATE FUNCTION testfunc () RETURNS int4 AS '
declare
ret int4;
begin
SELECT column1 into ret FROM table WHERE column2 LIKE ''%anything%''
ORDER BY column3 LIMIT 1;
return ret;
end;
' LANGUAGE 'PLPGSQL';

Is this bug a reported one?

Regards,
Zoltan

--
Kov\'acs, Zolt\'an
kovacsz(at)pc10(dot)radnoti-szeged(dot)sulinet(dot)hu
http://www.math.u-szeged.hu/~kovzol
ftp://pc10.radnoti-szeged.sulinet.hu/home/kovacsz

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Rene Pijlman 2001-08-16 17:53:39 Re: Re: [JDBC] JDBC pg_description update needed for CVS tip
Previous Message Tom Lane 2001-08-16 17:47:05 Re: Patches (current CVS) for changes if index AM tables