Re: RfD: more powerful "any" types

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, "David E(dot) Wheeler" <david(at)kineticode(dot)com>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: RfD: more powerful "any" types
Date: 2009-09-10 18:24:53
Message-ID: 603c8f070909101124o69b6b2b3t796cfa8e971db5b0@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Sep 9, 2009 at 3:44 PM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> wrote:
>> Really, I think we need a type system that doesn't try to represent
>> every type as a 32-bit integer.  Right now, for example, there's no
>> reasonable way to write a function that takes another function as an
>> argument.  What we need is a system where base types are represented
>> by an OID, but derived types (list and functional types) are built up
>> using type constructors that take other types as arguments.  So you
>> could have a types like list(integer) or list(anyelement) or
>> function(integer,bool) [meaning either taking an integer and returning
>> a bool, or the other way around, depending on your notational
>> preference].  Then you can have functions with complex types like:
>>
>> maplist : function(anyelement,anyelement2,function(list(anyelement),list(anyelement2)))
>>
>> This would have the fringe benefit of eliminating types like anyarray
>> (which is just list(anyelement)) and the need to list every type twice
>> in pg_type, once for the base type and once for the derived array
>> type.
>
> it would be nice, but probably it could significant increase parsing
> query time. And this is +/- equal to what my transformationHook does.

I can't believe that this is even close to being correct.
Transformationhook is a cheap syntax hack (sorry, but it is). It's
not going to solve the problem of people who want anyelement and
anyelement2, nor will it solve the problem of people who want to pass
functions as arguments or treat them as first-class objects.

The major downside of such a system is that every place where we now
count on being able to store a type in a fixed-size field would need
to be touched. I don't believe that the overall slowdown in parsing
time would be significant, but I do think it would be a massive,
highly invasive, highly destabilizing patch. For the level of pain
involved, there might be better uses of our time, which is not to say
that I'd be in favor of rejecting such a patch out of hand if someone
felt called to develop it (Tom might, though).

...Robert

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2009-09-10 18:25:00 Re: RfD: more powerful "any" types
Previous Message Hannu Krosing 2009-09-10 18:20:23 Re: Ragged CSV import