Re: Annotated release notes

From: Joe Conway <mail(at)joeconway(dot)com>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Tatsuo Ishii <t-ishii(at)sra(dot)co(dot)jp>, peter_e(at)gmx(dot)net, neilc(at)samurai(dot)com, chriskl(at)familyhealth(dot)com(dot)au, tgl(at)sss(dot)pgh(dot)pa(dot)us, pgsql-hackers(at)postgresql(dot)org, PostgreSQL-documentation <pgsql-docs(at)postgresql(dot)org>
Subject: Re: Annotated release notes
Date: 2003-10-31 22:10:26
Message-ID: 3FA2DDD2.7000002@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs pgsql-hackers

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)

> <listitem><para>Allow user defined aggregates to use polymorphic
> functions (Joe)</para> <listitem><para>Allow polymorphic user defined
> aggregates (Joe)</para></listitem>
>
> 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

In response to

Browse pgsql-docs by date

  From Date Subject
Next Message Peter Eisentraut 2003-10-31 23:13:30 Re: Runtime Basics
Previous Message elein 2003-10-31 20:55:12 Re: Annotated release notes

Browse pgsql-hackers by date

  From Date Subject
Next Message Neil Conway 2003-10-31 22:15:55 out of date bufmgr README
Previous Message Larry Rosenman 2003-10-31 21:51:29 Re: Regression Failure: CURRENT SOURCES/union&join