Found a bug in the procedural languages code relating to LIMIT 1 - Mailing list pgsql-general

From
Subject Found a bug in the procedural languages code relating to LIMIT 1
Date
Msg-id 20010111131343.1629.qmail@mailhost.sidereal.kz
Whole thread Raw
Responses Re: Found a bug in the procedural languages code relating to LIMIT 1  (Tod McQuillin <devin@spamcop.net>)
Re: Found a bug in the procedural languages code relating to LIMIT 1  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Try a function like this:

CREATE FUNCTION foo(...) RETURNS INT4 AS '
SELECT shoesize FROM customers ORDER BY time LIMIT 1
' LANGUAGE 'sql';

It gives an error that returning multiple values is not allowed.  It
clearly does not return multiple values; it has a LIMIT 1.  So I think
this is a bug.  Is there any other better way to do this perhaps?  Is
there a way to find a row where some field is the most in its range?
In my application I'm having to do this a lot.

The workaround that I found is to do this in plpgsql.  I can do it
like this:

DECLARE result INT4;
SELECT shoesize INTO result ...
RETURN result;
END;

but I should be able to do this in sql, not plpgsql.

Thanks for any help

pgsql-general by date:

Previous
From: "rob"
Date:
Subject: Re: [HACKERS] Re: still no log
Next
From: Tod McQuillin
Date:
Subject: Re: Found a bug in the procedural languages code relating to LIMIT 1