Re: Tables cannot have INSTEAD OF triggers

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Tables cannot have INSTEAD OF triggers
Дата
Msg-id 10915.1427909373@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Tables cannot have INSTEAD OF triggers  (Andres Freund <andres@anarazel.de>)
Ответы Re: Tables cannot have INSTEAD OF triggers  (Andres Freund <andres@anarazel.de>)
Список pgsql-hackers
Andres Freund <andres@anarazel.de> writes:
> On 2015-04-01 13:15:26 -0400, Tom Lane wrote:
>> If you have such a trigger, it's impossible to insert any rows, which
>> means the table doesn't need storage, which means it may as well be a
>> view, no?  So this still seems to me like a wart not a useful feature.
>> I think it would create confusion because a table with such a trigger
>> would act so much unlike other tables.

> For one you can't easily add partitions to a view (and
> constraint_exclusion = partition IIRC doesn't work if you use UNION ALL),
> for another there's WHEN for triggers that should allow dealing with
> that.

WHEN won't help; if there are any INSTEAD OF triggers, no insert will
happen, whether the triggers actually fire or not.

As for partitioning, you could do this:

create table parent(...);
create table child(...) inherits(parent); -- repeat as needed
create view v as select * from parent;
attach INSTEAD OF triggers to v

Now the application deals only with v, and thinks that's the real
table.
        regards, tom lane



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

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: Tables cannot have INSTEAD OF triggers
Следующее
От: Andres Freund
Дата:
Сообщение: Re: Tables cannot have INSTEAD OF triggers