Re: Inspection of row types in pl/pgsql and pl/sql

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Florian G(dot) Pflug" <fgp(at)phlo(dot)org>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Postgresql-Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Inspection of row types in pl/pgsql and pl/sql
Date: 2009-11-14 19:06:40
Message-ID: 4AFEFFC0.5080808@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane wrote:
> "Florian G. Pflug" <fgp(at)phlo(dot)org> writes:
>
>> While I agree that handling arbitrary datatypes at runtime would be
>> nice, I really don't see how that could ever be done from within a
>> plpgsql procedure, unless plpgsql somehow morphs into a dynamically
>> typed language.
>>
>
> Which is not likely to happen, which is why this is fundamentally a
> dead end. I don't think it's appropriate to put ugly, hard to use
> band-aids over the fact that plpgsql isn't designed to do this.
> One of the principal reasons why we work so hard to support multiple
> PLs is that they have different strengths. If you need something that's
> more dynamically typed than plpgsql, you should go use something else.
>
>
>> Plus, fully generic handling of data of arbitrary type is a somewhat
>> strange notion anyway, because it leaves you with very few operations
>> guaranteed to be defined for those values. In the case of PG, you'd be
>> pretty much limited to casting those values from and to text.
>>
>
> Well, that's the wrong way to look at it. To me, the right design
> would involve saying that my trigger needs to do operation X on the
> data, and therefore it should support all datatypes that can do X.
> It should not need a hard-wired list of which types those are.
>
> Perhaps it would help if we looked at some specific use-cases that
> people need, rather than debating abstractly. What do you need your
> generic trigger to *do*?
>
>
>

The two things I have wanted most badly in the past are

a) to be able to address a field in NEW and OLD by a string name
(usually passed in via a trigger argument) and
b) to be able to discover the names if the fields in NEW and OLD

cheers

andrew

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeff Davis 2009-11-14 19:27:29 Re: operator exclusion constraints
Previous Message Greg Stark 2009-11-14 18:58:30 Re: operator exclusion constraints