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

Re: Whats the correct way to change trigdata->tg_relation

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Charles Gomes <charlesrg(at)outlook(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Whats the correct way to change trigdata->tg_relation
Date: 2013-01-02 21:51:40
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
On Fri, Dec 28, 2012 at 1:06 PM, Charles Gomes <charlesrg(at)outlook(dot)com> wrote:
> I'm creating a simple trigger that will be called during an insert and change the destination table.
> All values are going to be preserved, just the destination table will be different.
> From what I see I can't modify trigdata->tg_relation.
> All examples use: return Datum(trigdata->tg_trigtuple); // however tg_relation does not belong there. I'm trying to avoind having to do a SPI_EXEC;
> Should I create a new heap_tuple and call heap_insert() and then Return Datum(NULL); ? Or is there another more straight forward way of doing it?  Looks like if I call heap_insert I will have to update the indexes somehow.

I think you need to use SPI_EXEC.  Otherwise something horrible will
probably happen.

Robert Haas
The Enterprise PostgreSQL Company

In response to

pgsql-hackers by date

Next:From: Robert HaasDate: 2013-01-02 22:36:33
Subject: Re: multiple CREATE FUNCTION AS items for PLs
Previous:From: Robert HaasDate: 2013-01-02 21:45:35
Subject: Re: json api WIP patch

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