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

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Inspection of row types in pl/pgsql and pl/sql
Дата
Msg-id 17611.1258228566@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Inspection of row types in pl/pgsql and pl/sql  ("Florian G. Pflug" <fgp@phlo.org>)
Ответы Postgres and likewise authentication
Re: Inspection of row types in pl/pgsql and pl/sql
Список pgsql-hackers
"Florian G. Pflug" <fgp@phlo.org> writes:
> Tom Lane wrote:
>> 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*?

> I need to build a global index table of all values of a certain type
> together with a pointer to the row and table that contains them. Since
> all involved tables have an "id" column, storing that pointer is the
> easy part. The hard part is collecting all those values in an
> insert/update/delete trigger so that I can update the global index
> accordingly.

So in this case it seems like you don't actually need any polymorphism
at all; the target columns are always of a known datatype.  You just
don't want to commit to their names.  I wonder though why you're willing
to pin down the name of the "id" column but not the name of the data
column.

> Currently, a set of plpgsql functions generate a seperate trigger
> function for each table. Yuck!

Would you be happy with an approach similar to what Andrew mentioned,
ie, you generate CREATE TRIGGER commands that list the names of the
target column(s) as TG_ARGV arguments?  The alternative to that seems
to be that you iterate at runtime through all the table columns to
see which ones are of the desired type.  Which might be less trouble
to set up, but the performance penalty of figuring out
basically-unchanging information again on every single tuple update
seems awful high.
        regards, tom lane


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

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: operator exclusion constraints
Следующее
От: Greg Stark
Дата:
Сообщение: Re: patch - per-tablespace random_page_cost/seq_page_cost