pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Mikheev, Vadim <vmikheev@SECTORBASE.COM>
To: 'Markus Wagner' <wagner@imsd.uni-mainz.de>
To: pgsql-general@postgresql.org
To: pgsql-sql@postgresql.org
To: pgsql-hackers@postgresql.org
Subject: Re: getting the oid for a new tuple in a BEFORE trigger
Date: Fri, 31 Aug 2001 09:45:49 -0700
Message-ID: <3705826352029646A3E91C53F7189E32016761@sectorbase2.sectorbase.com> (raw)

> 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



view thread (8+ messages)  latest in thread

Message-ID: <3705826352029646A3E91C53F7189E32016761@sectorbase2.sectorbase.com>
Permalink:  ../3705826352029646A3E91C53F7189E32016761@sectorbase2.sectorbase.com/
Also on:    postgresql.org/message-id/3705826352029646A3E91C53F7189E32016761@sectorbase2.sectorbase.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: vmikheev@SECTORBASE.COM, wagner@imsd.uni-mainz.de, pgsql-general@postgresql.org, pgsql-hackers@postgresql.org
  Subject: Re: getting the oid for a new tuple in a BEFORE trigger
  In-Reply-To: <3705826352029646A3E91C53F7189E32016761@sectorbase2.sectorbase.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox