Re: RfD: more powerful "any" types - Mailing list pgsql-hackers

From Dimitri Fontaine
Subject Re: RfD: more powerful "any" types
Date
Msg-id m2ocpjg37k.fsf@hi-media.com
Whole thread Raw
In response to Re: RfD: more powerful "any" types  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: RfD: more powerful "any" types
List pgsql-hackers
Hi,

Tom Lane <tgl@sss.pgh.pa.us> writes:
> Hannu Krosing <hannu@2ndQuadrant.com> writes:
>> anyelement(1), anyelement(2), ..., anyelement(N) and then match them by
>> the number in parentheses
>
> Yeah, that idea occurred to me too.  The immediate practical problem is
> that we don't store a typmod for function argument/result types.
> I guess we could look into doing that ...

But still, it looks terrible...

On Sep 9, 2009, at 4:44 AM, Peter Eisentraut wrote:
> That's beginning to sound a bit like a generics feature.  E.g.,
>
> CREATE FUNCTION the_same<T>(arg_a T, arg_b T) RETURNS bool AS $$
> SELECT arg_a IS DISTINCT FROM arg_b;
> $$;

And even if we don't want to go this far (I'd be in favor of going there
FWIW), we could maybe have a syntax allowing the users to name or
declare the any types he'll need?

CREATE FUNCTION foo(a anyelement x, b anyelement x, c anyelement y)RETURNS anyelement y[]
AS $$
... 
$$;

Now we have anyelement and anyelement2, but without the ugly names or
the typmod feature stretching, and we can even have any number of user
defined anyelement types. That behave just like anyelement.

Then, maybe we need VARIADIC anyelement any[] to declare the function as able
to cope with a variable length list of all different kinds of elements?

Regards,
-- 
dim


pgsql-hackers by date:

Previous
From: David Fetter
Date:
Subject: Bug in aggregates in windowing context
Next
From: Tom Lane
Date:
Subject: Re: Bug in aggregates in windowing context