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

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

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: "Mikheev, Vadim" <vmikheev(at)SECTORBASE(dot)COM>
Cc: "'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: [HACKERS] getting the oid for a new tuple in a BEFORE
Date: 2001-09-04 15:33:30
Message-ID: (view raw, whole thread or download thread mbox)
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().

Does that work?  Doesn't that get overwritten when the actual INSERT

  Bruce Momjian                        |
  pgman(at)candle(dot)pha(dot)pa(dot)us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

In response to

pgsql-hackers by date

Next:From: Joe ConwayDate: 2001-09-04 15:37:35
Subject: Re: Bytea/Base64 encoders for libpq - interested?
Previous:From: Tom LaneDate: 2001-09-04 15:01:08
Subject: Re: Table vs. row level locks confusion

pgsql-sql by date

Next:From: postgresqlDate: 2001-09-06 17:11:30
Previous:From: Jeff EckermannDate: 2001-09-04 15:10:08
Subject: Re: 2 tables, joins and same name...

pgsql-general by date

Next:From: Martijn van OosterhoutDate: 2001-09-04 15:33:40
Subject: Re: many junction tables
Previous:From: Tom LaneDate: 2001-09-04 15:30:51
Subject: Re: upgrade from 7.1.2 to 7.1.3 and uh, where are my databases?

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