Re: [GENERAL] getting the oid for a new tuple in a BEFORE trigger

Поиск
Список
Период
Сортировка
От Mikheev, Vadim
Тема Re: [GENERAL] getting the oid for a new tuple in a BEFORE trigger
Дата
Msg-id 3705826352029646A3E91C53F7189E32016761@sectorbase2.sectorbase.com
обсуждение исходный текст
Ответы Re: [GENERAL] getting the oid for a new tuple in a BEFORE  (Bruce Momjian <pgman@candle.pha.pa.us>)
Список pgsql-hackers
> we need to control database changes within BEFORE triggers.
> There is no problem with triggers called by update, but there is
> a problem with triggers called by insert.
>
> We strongly need to know the oid of a newly inserted tuple.
> In this case, we use tg_newtuple of the TriggerData structure
> passed to thetrigger function, and its t_data -> t_oid will
> have the value '0'.
>
> Using BEFORE and AFTER triggers would make our lives much harder.
>
> Is there any way (even hack) to get the oid the newly
> inserted tuple will receive?

Just set t_data->t_oid = newoid() - this is what backend does
in heapam.c:heap_insert().

Vadim

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

Предыдущее
От: Hannu Krosing
Дата:
Сообщение: Re: [OT] Re: User locks code
Следующее
От: Barry Lind
Дата:
Сообщение: Re: Escaping strings for inclusion into SQL queries