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

From: "Mikheev, Vadim" <vmikheev(at)SECTORBASE(dot)COM>
To: "'Markus Wagner'" <wagner(at)imsd(dot)uni-mainz(dot)de>, pgsql-general(at)postgresql(dot)org, pgsql-sql(at)postgresql(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Re: getting the oid for a new tuple in a BEFORE trigger
Date: 2001-08-31 16:45:49
Message-ID: 3705826352029646A3E91C53F7189E32016761@sectorbase2.sectorbase.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers pgsql-sql

> 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Mikheev, Vadim 2001-08-31 16:47:59 Re: Deployment of PostgreSQL Applications
Previous Message Shaun Thomas 2001-08-31 16:44:07 Re: select from different database

Browse pgsql-hackers by date

  From Date Subject
Next Message Barry Lind 2001-08-31 17:03:04 Re: Escaping strings for inclusion into SQL queries
Previous Message Hannu Krosing 2001-08-31 16:03:57 Re: Escaping strings for inclusion into SQL queries

Browse pgsql-sql by date

  From Date Subject
Next Message Ross J. Reedstrom 2001-08-31 22:29:43 Re: 2 tables, joins and same name...
Previous Message Thomas Rehlich 2001-08-31 15:55:15 Re: 2 tables, joins and same name...