Re: LEAST and GREATEST functions?

From: Ang Chin Han <angch(at)bytecraft(dot)com(dot)my>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: LEAST and GREATEST functions?
Date: 2003-07-02 07:11:01
Message-ID: 3F028585.1020600@bytecraft.com.my
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Tom Lane wrote:

> create function greatest(anyelement, anyelement) returns anyelement as
> 'select case when $1>$2 then $1 else $2 end' language sql;

Any chance of this making it into 7.4's contrib? Maybe with enough
documentation to make it a tutorial for PostgreSQL's user functions?

> You do have to create several greatest() functions for different numbers
> of arguments, but not one for each datatype you want to handle.

Insignificant, compared with the flexiblity.

> I have not seen enough requests for a native LEAST/GREATEST
> implementation to make me think we need to do more than this...
> certainly I'd rather spend development effort on general facilities
> like polymorphism and inlining than on creating one-use facilities
> like built-in LEAST/GREATEST.

Nice. It would speed up our current functions too. Thanks, developers,
esp. Tom and Joe for this!

Wow, less reasons to use VIEWs when CREATE FUNCTION can be just as fast,
but more flexible. Can't wait, IMHO, the advocacy people can and should
be promoting this(functions returning sets, and how it can be used) as a
killer feature for 7.3 and 7.4. I know I was pretty happy to discover
that gem lurking in the documentation in 7.3.

--
Linux homer 2.4.18-14 #1 Wed Sep 4 13:35:50 EDT 2002 i686 i686 i386
GNU/Linux
2:30pm up 188 days, 5:35, 4 users, load average: 5.04, 5.15, 5.16

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Együd Csaba 2003-07-02 10:00:48 Re: Getting all rows even if not a member of any groups
Previous Message Tom Lane 2003-07-02 06:36:44 Re: LEAST and GREATEST functions?