Found a bug in the procedural languages code relating to LIMIT 1

From: <drevil(at)sidereal(dot)kz>
To: pgsql-general(at)postgresql(dot)org
Subject: Found a bug in the procedural languages code relating to LIMIT 1
Date: 2001-01-11 13:13:43
Message-ID: 20010111131343.1629.qmail@mailhost.sidereal.kz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tod McQuillin 2001-01-11 15:34:51 Re: Found a bug in the procedural languages code relating to LIMIT 1
Previous Message rob 2001-01-11 12:20:26 Re: converting .xls to delimited file