X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 17ADDD1B4EC for ; Sat, 18 Oct 2003 02:52:23 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 79012-04 for ; Fri, 17 Oct 2003 23:51:56 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id A46D6D1B53D for ; Fri, 17 Oct 2003 23:51:51 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id h9I2pruo027574; Fri, 17 Oct 2003 22:51:53 -0400 (EDT) To: miker@n2bb.com Cc: Rodrigo Gesswein , pgsql-sql@postgresql.org Subject: Re: new max function In-reply-to: <200310171732.50292.miker@n2bb.com> References: <200310171732.50292.miker@n2bb.com> Comments: In-reply-to Mike Rylander message dated "Fri, 17 Oct 2003 17:32:50 -0400" Date: Fri, 17 Oct 2003 22:51:52 -0400 Message-ID: <27573.1066445512@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/217 X-Sequence-Number: 15617 Mike Rylander writes: > Here's mine: > CREATE FUNCTION max2 (INTEGER,INTEGER) RETURNS INTEGER > LANGUAGE SQL AS > 'SELECT CASE WHEN $1 > $2 THEN $1 ELSE $2 END'; BTW, most of the standard datatypes have these already, because they are the transition functions for the MAX() and MIN() aggregates. The one above is int4larger(). regression=# \df *larger List of functions Result data type | Schema | Name | Argument data types -----------------------------+------------+--------------------+---------------------------------------------------------- money | pg_catalog | cashlarger | money, money date | pg_catalog | date_larger | date, date real | pg_catalog | float4larger | real, real double precision | pg_catalog | float8larger | double precision, double precision smallint | pg_catalog | int2larger | smallint, smallint integer | pg_catalog | int4larger | integer, integer bigint | pg_catalog | int8larger | bigint, bigint interval | pg_catalog | interval_larger | interval, interval numeric | pg_catalog | numeric_larger | numeric, numeric oid | pg_catalog | oidlarger | oid, oid text | pg_catalog | text_larger | text, text time without time zone | pg_catalog | time_larger | time without time zone, time without time zone timestamp without time zone | pg_catalog | timestamp_larger | timestamp without time zone, timestamp without time zone timestamp with time zone | pg_catalog | timestamptz_larger | timestamp with time zone, timestamp with time zone time with time zone | pg_catalog | timetz_larger | time with time zone, time with time zone (15 rows) All of these have matching xxxsmaller() as well. regards, tom lane