Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
Thread:
Lists: pgsql-generalpgsql-hackerspgsql-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

pgsql-hackers by date

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

pgsql-sql by date

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

pgsql-general by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group