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

From: "Florian G(dot) Pflug" <fgp(at)phlo(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, 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 18:31:04
Message-ID: 4AFEF768.80207@phlo.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane wrote:
> Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
>> Yes, and I have used it, but it really would be nicer to have some
>> introspection facilities built in, especially for use in triggers.
>
> Maybe, but the proposal at hand is spectacularly ugly --- in particular
> it seems designed around the assumption that a given trigger will only
> care about handling a predetermined set of datatypes, which hardly
> fits with PG's normal goals for datatype extensibility. If the argument
> is that you don't like hstore or other PLs because they'll smash
> everything to text, then I think you have to do better than this.

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. Plus, the set of datatypes an application deals with is
usually much smaller than the set of tables, and less likely to change
over time.

I'd also argue that this restriction does not conflict with PG's goal of
datatype extensibility at all. Datatype extensibility in PG's boils down
to being able to create new datatypes without modifying postgres itself
- but it still expects that you do so while designing your application.
Which also is when trigger functions that use record_value() or a
similar function would be written.

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.

best regards,
Florian Pflug

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2009-11-14 18:31:29 Re: Unicode UTF-8 table formatting for psql text output
Previous Message Florian G. Pflug 2009-11-14 18:21:39 Re: Inspection of row types in pl/pgsql and pl/sql