From: | Sam Mason <sam(at)samason(dot)me(dot)uk> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: wishlist for 8.4 |
Date: | 2008-02-15 13:05:16 |
Message-ID: | 20080215130516.GA1653@frubble.xen.chris-lamb.co.uk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Thu, Feb 14, 2008 at 11:06:42AM -0500, Tom Lane wrote:
> =?UTF-8?B?UmFwaGHDq2wgSmFjcXVvdA==?= <sxpert(at)sxpert(dot)org> writes:
> > so, I propose the use of
> > NEW[variable_containing_the_column_name]
> > (which can obviously be extended to any tuples)
> > to allow such access.
>
> > what do you experts think ?
>
> Zero chance. plplgsql is a strongly typed language, and a construct
> like that couldn't have any known-in-advance data type.
If "variable_containing_the_column_name" was a string then I agree,
if columns were first class objects then it wouldn't be a problem.
Introducing sub-types would make this all nice and tidy, but
unfortunately sub-types are a long way away from what PG currently
supports and I don't know the SQL spec well enough to know if there
would be any serious incompatibilities with them--they are pretty
expressive so I'd doubt there would be any fundamental incompatibility.
If you want an example, Java has sub-types and 1.5+ has parametric
polymorphism making it possible to create an interface that named the
column you were interested in and then to write a function like:
interface Column<Row,ColType> {
public ColType get(Row r);
}
public <Row,ColType> ColType foo(Row row, Column<Row,ColType> col) {
return col.get(row);
}
In PG you'd want the sub-types to be generated automatically, the above
example is somewhat unreadable. The only real purpose of the above was
to show how a strong type system can express what the OP wanted.
The anyelement and supporting polymorphism would all be subsumed into
the features provided by sub-typing and would all be done in a much
tidier way.
It's a very big change for PG though!
Sam
From | Date | Subject | |
---|---|---|---|
Next Message | Heikki Linnakangas | 2008-02-15 13:37:49 | Re: wishlist for 8.4 |
Previous Message | Grzegorz Jaskiewicz | 2008-02-15 11:35:28 | subquery in limit |