pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedRe: [SQL] getting the oid for a new tuple in a BEFORE trigger
8+ messages / 8 participants
[nested] [flat]
* Re: [SQL] getting the oid for a new tuple in a BEFORE trigger
@ 1970-01-01 00:00 omid omoomi <oomoomi@hotmail.com>
2001-08-30 03:40 ` Re: Re: [SQL] getting the oid for a new tuple in a BEFORE trigger Horst Herb <hherb@malleenet.net.au>
0 siblings, 1 reply; 8+ messages in thread
From: omid omoomi @ 1970-01-01 00:00 UTC (permalink / raw)
To: wagner@imsd.uni-mainz.de; pgsql-general@postgresql.org; pgsql-sql; pgsql-hackers@postgresql.org
hi,
Idon't know the best way but how about a quick insert in a temp table and
adding 1 to the inserted oid column each time the trigger will run.!
regards
Omid
>From: Markus Wagner <wagner@imsd.uni-mainz.de>
>To: pgsql-general@postgresql.org, pgsql-sql@postgresql.org,
>pgsql-hackers@postgresql.org
>Subject: [SQL] getting the oid for a new tuple in a BEFORE trigger
>Date: Wed, 29 Aug 2001 11:15:08 +0200
>
>Hi,
>
>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?
>
>Thank you very much,
>
>Markus
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 3: if posting/reading through Usenet, please send an appropriate
>subscribe-nomail command to majordomo@postgresql.org so that your
>message can get through to the mailing list cleanly
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Re: [SQL] getting the oid for a new tuple in a BEFORE trigger
1970-01-01 00:00 Re: [SQL] getting the oid for a new tuple in a BEFORE trigger omid omoomi <oomoomi@hotmail.com>
@ 2001-08-30 03:40 ` Horst Herb <hherb@malleenet.net.au>
0 siblings, 0 replies; 8+ messages in thread
From: Horst Herb @ 2001-08-30 03:40 UTC (permalink / raw)
To: omid omoomi <oomoomi@hotmail.com>; PostgreSQL-development <pgsql-hackers@postgresql.org>
On Wednesday 29 August 2001 20:05, you wrote:
> hi,
> Idon't know the best way but how about a quick insert in a temp table and
> adding 1 to the inserted oid column each time the trigger will run.!
> regards
As you don't know how many users access the server concurrently and in which
order they will be served you will probably noty get what you want unless you
work on a single user single client-server connection all the time.
Horst
^ permalink raw reply [nested|flat] 8+ messages in thread
* getting the oid for a new tuple in a BEFORE trigger
@ 2001-08-29 09:15 Markus Wagner <wagner@imsd.uni-mainz.de>
2001-08-29 14:38 ` Re: getting the oid for a new tuple in a BEFORE trigger Josh Berkus <josh@agliodbs.com>
2001-08-30 09:05 ` Re: [SQL] getting the oid for a new tuple in a BEFORE trigger Francesco Casadei <f_casadei@libero.it>
2001-08-30 13:28 ` Re: getting the oid for a new tuple in a BEFORE trigger Peter Eisentraut <peter_e@gmx.net>
0 siblings, 3 replies; 8+ messages in thread
From: Markus Wagner @ 2001-08-29 09:15 UTC (permalink / raw)
To: pgsql-general@postgresql.org; pgsql-sql; pgsql-hackers@postgresql.org
Hi,
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?
Thank you very much,
Markus
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: getting the oid for a new tuple in a BEFORE trigger
2001-08-29 09:15 getting the oid for a new tuple in a BEFORE trigger Markus Wagner <wagner@imsd.uni-mainz.de>
@ 2001-08-29 14:38 ` Josh Berkus <josh@agliodbs.com>
2 siblings, 0 replies; 8+ messages in thread
From: Josh Berkus @ 2001-08-29 14:38 UTC (permalink / raw)
To: Markus Wagner <wagner@imsd.uni-mainz.de>; pgsql-sql
Mark,
The responses to your problem are gonna be kinda slow, as 2/3 of the
core team, and many of the users, are at the Expo right now (and if
anyone on the list is in the SF Bay Area, join us! BOF session
tonight!)
> 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.
What problem?
> 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.
Once again, why?
> Is there any way (even hack) to get the oid the newly inserted tuple
> will
> receive?
This specific answer will have to come from someone else.
I could suggest a couple of workarounds, if you gave a fuller
description of exactly what you're trying to accomplish.
-Josh Berkus
P.S. Please do not cross-post to more than 2 lists at a time. The
Postgres lists have been kept to a managable volume to date; let's keep
it that way.
______AGLIO DATABASE SOLUTIONS___________________________
Josh Berkus
Complete information technology josh@agliodbs.com
and data management solutions (415) 565-7293
for law firms, small businesses fax 621-2533
and non-profit organizations. San Francisco
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: [SQL] getting the oid for a new tuple in a BEFORE trigger
2001-08-29 09:15 getting the oid for a new tuple in a BEFORE trigger Markus Wagner <wagner@imsd.uni-mainz.de>
@ 2001-08-30 09:05 ` Francesco Casadei <f_casadei@libero.it>
2 siblings, 0 replies; 8+ messages in thread
From: Francesco Casadei @ 2001-08-30 09:05 UTC (permalink / raw)
To: Markus Wagner <wagner@imsd.uni-mainz.de>; +Cc: pgsql-general@postgresql.org; pgsql-sql; pgsql-hackers@postgresql.org
On Wed, Aug 29, 2001 at 11:15:08AM +0200, Markus Wagner wrote:
> Hi,
>
> 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?
>
> Thank you very much,
>
> Markus
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly
>
> end of the original message
Read section 24.2.5.4 'Obtaining other results status' of the Programmer's
Guide. This is for the PL/pgSQL language, though.
Francesco Casadei
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: getting the oid for a new tuple in a BEFORE trigger
2001-08-29 09:15 getting the oid for a new tuple in a BEFORE trigger Markus Wagner <wagner@imsd.uni-mainz.de>
@ 2001-08-30 13:28 ` Peter Eisentraut <peter_e@gmx.net>
2 siblings, 0 replies; 8+ messages in thread
From: Peter Eisentraut @ 2001-08-30 13:28 UTC (permalink / raw)
To: Markus Wagner <wagner@imsd.uni-mainz.de>; +Cc: pgsql-sql
Markus Wagner writes:
> 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'.
A less hackish way to do this might be using a sequence object for the
primary key and fetch the next sequence value manually.
--
Peter Eisentraut peter_e@gmx.net http://funkturm.homeip.net/~peter
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: getting the oid for a new tuple in a BEFORE trigger
@ 2001-08-31 16:45 Mikheev, Vadim <vmikheev@SECTORBASE.COM>
2001-09-04 15:33 ` Re: [HACKERS] getting the oid for a new tuple in a BEFORE Bruce Momjian <pgman@candle.pha.pa.us>
0 siblings, 1 reply; 8+ messages in thread
From: Mikheev, Vadim @ 2001-08-31 16:45 UTC (permalink / raw)
To: 'Markus Wagner' <wagner@imsd.uni-mainz.de>; pgsql-general@postgresql.org; pgsql-sql; pgsql-hackers@postgresql.org
> 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
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: [HACKERS] getting the oid for a new tuple in a BEFORE
2001-08-31 16:45 Re: getting the oid for a new tuple in a BEFORE trigger Mikheev, Vadim <vmikheev@SECTORBASE.COM>
@ 2001-09-04 15:33 ` Bruce Momjian <pgman@candle.pha.pa.us>
0 siblings, 0 replies; 8+ messages in thread
From: Bruce Momjian @ 2001-09-04 15:33 UTC (permalink / raw)
To: Mikheev, Vadim <vmikheev@SECTORBASE.COM>; +Cc: 'Markus Wagner' <wagner@imsd.uni-mainz.de>; pgsql-general@postgresql.org; pgsql-sql; pgsql-hackers@postgresql.org
> > 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
happens?
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
^ permalink raw reply [nested|flat] 8+ messages in thread
end of thread, other threads:[~2001-09-04 15:33 UTC | newest]
Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1970-01-01 00:00 Re: [SQL] getting the oid for a new tuple in a BEFORE trigger omid omoomi <oomoomi@hotmail.com>
2001-08-30 03:40 ` Horst Herb <hherb@malleenet.net.au>
2001-08-29 09:15 getting the oid for a new tuple in a BEFORE trigger Markus Wagner <wagner@imsd.uni-mainz.de>
2001-08-29 14:38 ` Josh Berkus <josh@agliodbs.com>
2001-08-30 09:05 ` Francesco Casadei <f_casadei@libero.it>
2001-08-30 13:28 ` Peter Eisentraut <peter_e@gmx.net>
2001-08-31 16:45 Re: getting the oid for a new tuple in a BEFORE trigger Mikheev, Vadim <vmikheev@SECTORBASE.COM>
2001-09-04 15:33 ` Re: [HACKERS] getting the oid for a new tuple in a BEFORE Bruce Momjian <pgman@candle.pha.pa.us>
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