Re: wishlist for 8.4 - Mailing list pgsql-hackers

From Martijn van Oosterhout
Subject Re: wishlist for 8.4
Date
Msg-id 20080214133015.GB13453@svana.org
Whole thread Raw
In response to wishlist for 8.4  (Raphaël Jacquot <sxpert@sxpert.org>)
List pgsql-hackers
On Thu, Feb 14, 2008 at 07:51:31AM +0100, Raphaël Jacquot wrote:
> in fact, I got stuck in pl/pgsql with the fact that there's no way to
> access the NEW tuple in an indirect way, having the name of the column
> in some variable. (I found that it could be done in plperl, but that
> left me with a taste of un-completeness...)
>
> so, I propose the use of
>
>     NEW[variable_containing_the_column_name]

It's not that simple. pl/pgsql is a statically typed language. Which
means the types of the variable aren't really allowed to change
between executions. The problem with your construct is that you can't
tell a priori what its type is.

The problem stems (I beleive) from the postgresql parser itself, since
SQL doesn't have the structure you want either, and pl/pgsql uses the
SQL parser for all the hard work. The reason why other languages can do
it is because they are typed at run-time, not compile time.

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Those who make peaceful revolution impossible will make violent revolution inevitable.
>  -- John F Kennedy

pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: Show INHERIT in \du
Next
From: Simon Riggs
Date:
Subject: Reworking WAL locking