Re: wishlist for 8.4

Поиск
Список
Период
Сортировка
От Sam Mason
Тема Re: wishlist for 8.4
Дата
Msg-id 20080215130516.GA1653@frubble.xen.chris-lamb.co.uk
обсуждение исходный текст
Ответ на Re: wishlist for 8.4  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On Thu, Feb 14, 2008 at 11:06:42AM -0500, Tom Lane wrote:
> Raphaël Jacquot <sxpert@sxpert.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


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Grzegorz Jaskiewicz
Дата:
Сообщение: subquery in limit
Следующее
От: "Heikki Linnakangas"
Дата:
Сообщение: Re: wishlist for 8.4