X-Original-To: pgsql-docs-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 2B1B4D1B510; Fri, 31 Oct 2003 22:12:35 +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 85474-10; Fri, 31 Oct 2003 18:12:05 -0400 (AST) Received: from joeconway.com (66-146-172-86.skyriver.net [66.146.172.86]) by svr1.postgresql.org (Postfix) with ESMTP id 4A794D1B4E9; Fri, 31 Oct 2003 18:12:02 -0400 (AST) Received: from [206.19.64.3] (account jconway HELO joeconway.com) by joeconway.com (CommuniGate Pro SMTP 4.1.5) with ESMTP-TLS id 459159; Fri, 31 Oct 2003 14:10:35 -0800 Message-ID: <3FA2DDD2.7000002@joeconway.com> Date: Fri, 31 Oct 2003 14:10:26 -0800 From: Joe Conway User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.3) Gecko/20030312 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Bruce Momjian Cc: Tatsuo Ishii , peter_e@gmx.net, neilc@samurai.com, chriskl@familyhealth.com.au, tgl@sss.pgh.pa.us, pgsql-hackers@postgresql.org, PostgreSQL-documentation Subject: Re: Annotated release notes References: <200310311949.h9VJn0J04943@candle.pha.pa.us> In-Reply-To: <200310311949.h9VJn0J04943@candle.pha.pa.us> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/55 X-Sequence-Number: 2075 Bruce Momjian wrote: > What had me really confused was the first release item: > > Allow polymorphic SQL functions (Joe) > > How does an SQL function query the data types passed to it? Once I > saw that I thought I didn't underestand what polymorphic functions > were. It doesn't need to. For example: CREATE OR REPLACE FUNCTION makearray(anyelement, anyelement) returns anyarray as 'select ARRAY[$1, $2]' language sql; regression=# select makearray(1,2); makearray ----------- {1,2} (1 row) regression=# select makearray('a'::text,'b'); makearray ----------- {a,b} (1 row) > Allow user defined aggregates to use polymorphic > functions (Joe) Allow polymorphic user defined > aggregates (Joe) > > These seem like duplicates. They aren't. The first says you could create an aggregate with defined base and state datatypes, but where the state/final functions might be polymorphic. The second says that the base and state types might be polymorphic. > Are polymorphic functions currently most useful for aggregates? Why > would someone want polymorphic aggregates? That is what I was hoping > for. Well, one example is a calculation aggregate (let's say median) which you might want to use for any numeric data type. Or an array accumulator, e.g. CREATE AGGREGATE myagg1 ( BASETYPE = float8, SFUNC = array_append, STYPE = float8[], INITCOND = '{}' ); CREATE AGGREGATE CREATE AGGREGATE myagg1p ( BASETYPE = anyelement, SFUNC = array_append, STYPE = anyarray, INITCOND = '{}' ); CREATE AGGREGATE Joe