pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedAnother INSTEAD OF TRIGGER question
5+ messages / 3 participants
[nested] [flat]
* Another INSTEAD OF TRIGGER question
@ 2020-03-08 14:29 stan <stanb@panix.com>
2020-03-08 14:31 ` Re: Another INSTEAD OF TRIGGER question stan <stanb@panix.com>
0 siblings, 1 reply; 5+ messages in thread
From: stan @ 2020-03-08 14:29 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
Still working on updateable views.
Wish list item, a way to see the entire query that caused the trigger to
fire.
Now on to something i hope I can get. Can I see what the verb that caused
the trigger to fire is? IE UPDATE, INSERT, DELETE?
--
"They that would give up essential liberty for temporary safety deserve
neither liberty nor safety."
-- Benjamin Franklin
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Another INSTEAD OF TRIGGER question
2020-03-08 14:29 Another INSTEAD OF TRIGGER question stan <stanb@panix.com>
@ 2020-03-08 14:31 ` stan <stanb@panix.com>
2020-03-08 14:33 ` Re: Another INSTEAD OF TRIGGER question Rob Sargent <robjsargent@gmail.com>
2020-03-08 14:56 ` Re: Another INSTEAD OF TRIGGER question Sándor Daku <daku.sandor@gmail.com>
0 siblings, 2 replies; 5+ messages in thread
From: stan @ 2020-03-08 14:31 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On Sun, Mar 08, 2020 at 10:29:09AM -0400, stan wrote:
> Still working on updateable views.
>
> Wish list item, a way to see the entire query that caused the trigger to
> fire.
>
> Now on to something i hope I can get. Can I see what the verb that caused
> the trigger to fire is? IE UPDATE, INSERT, DELETE?
>
> --
> "They that would give up essential liberty for temporary safety deserve
> neither liberty nor safety."
> -- Benjamin Franklin
>
>
OH, what was I thinking, that is controled by the trigger.
--
"They that would give up essential liberty for temporary safety deserve
neither liberty nor safety."
-- Benjamin Franklin
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Another INSTEAD OF TRIGGER question
2020-03-08 14:29 Another INSTEAD OF TRIGGER question stan <stanb@panix.com>
2020-03-08 14:31 ` Re: Another INSTEAD OF TRIGGER question stan <stanb@panix.com>
@ 2020-03-08 14:33 ` Rob Sargent <robjsargent@gmail.com>
1 sibling, 0 replies; 5+ messages in thread
From: Rob Sargent @ 2020-03-08 14:33 UTC (permalink / raw)
To: stan <stanb@panix.com>; +Cc: pgsql-general@lists.postgresql.org
> On Mar 8, 2020, at 8:31 AM, stan <stanb@panix.com> wrote:
>
> On Sun, Mar 08, 2020 at 10:29:09AM -0400, stan wrote:
>> Still working on updateable views.
>>
>> Wish list item, a way to see the entire query that caused the trigger to
>> fire.
>>
>> Now on to something i hope I can get. Can I see what the verb that caused
>> the trigger to fire is? IE UPDATE, INSERT, DELETE?
>>
>> --
>> "They that would give up essential liberty for temporary safety deserve
>> neither liberty nor safety."
>> -- Benjamin Franklin
>>
>>
>
> OH, what was I thinking, that is controled by the trigger.
>
> --
> "They that would give up essential liberty for temporary safety deserve
> neither liberty nor safety."
> -- Benjamin Franklin
>
Or that is what controls which trigger is fired.
>
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Another INSTEAD OF TRIGGER question
2020-03-08 14:29 Another INSTEAD OF TRIGGER question stan <stanb@panix.com>
2020-03-08 14:31 ` Re: Another INSTEAD OF TRIGGER question stan <stanb@panix.com>
@ 2020-03-08 14:56 ` Sándor Daku <daku.sandor@gmail.com>
2020-03-08 21:13 ` Re: Another INSTEAD OF TRIGGER question stan <stanb@panix.com>
1 sibling, 1 reply; 5+ messages in thread
From: Sándor Daku @ 2020-03-08 14:56 UTC (permalink / raw)
To: stan <stanb@panix.com>; +Cc: pgsql-general@lists.postgresql.org
On Sun, 8 Mar 2020 at 15:31, stan <stanb@panix.com> wrote:
> On Sun, Mar 08, 2020 at 10:29:09AM -0400, stan wrote:
> > Still working on updateable views.
> >
> > Wish list item, a way to see the entire query that caused the trigger to
> > fire.
> >
> > Now on to something i hope I can get. Can I see what the verb that caused
> > the trigger to fire is? IE UPDATE, INSERT, DELETE?
> >
> > --
> > "They that would give up essential liberty for temporary safety deserve
> > neither liberty nor safety."
> > -- Benjamin Franklin
> >
> >
>
> OH, what was I thinking, that is controled by the trigger.
>
> --
> "They that would give up essential liberty for temporary safety deserve
> neither liberty nor safety."
> -- Benjamin Franklin
>
Hi,
Still, you can access that information in the TG_OP variable available in
trigger functions because you can define triggers firing on
multiple operation types.
For instance this is an example from the Postgres documentation:
CREATE TRIGGER emp_audit
INSTEAD OF INSERT OR UPDATE OR DELETE ON emp_view
FOR EACH ROW EXECUTE FUNCTION update_emp_view();
Regards,
Sándor
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Another INSTEAD OF TRIGGER question
2020-03-08 14:29 Another INSTEAD OF TRIGGER question stan <stanb@panix.com>
2020-03-08 14:31 ` Re: Another INSTEAD OF TRIGGER question stan <stanb@panix.com>
2020-03-08 14:56 ` Re: Another INSTEAD OF TRIGGER question Sándor Daku <daku.sandor@gmail.com>
@ 2020-03-08 21:13 ` stan <stanb@panix.com>
0 siblings, 0 replies; 5+ messages in thread
From: stan @ 2020-03-08 21:13 UTC (permalink / raw)
To: S??ndor Daku <daku.sandor@gmail.com>; +Cc: pgsql-general@lists.postgresql.org
On Sun, Mar 08, 2020 at 10:07:24PM +0100, S??ndor Daku wrote:
> On Sun, 8 Mar 2020 at 21:26, stan <stanb@panix.com> wrote:
>
> > On Sun, Mar 08, 2020 at 03:56:56PM +0100, S??ndor Daku wrote:
> > > On Sun, 8 Mar 2020 at 15:31, stan <stanb@panix.com> wrote:
> > >
> > > > On Sun, Mar 08, 2020 at 10:29:09AM -0400, stan wrote:
> > > > > Still working on updateable views.
> > > > >
> > > > > Wish list item, a way to see the entire query that caused the
> > trigger to
> > > > > fire.
> > > > >
> > > > > Now on to something i hope I can get. Can I see what the verb that
> > caused
> > > > > the trigger to fire is? IE UPDATE, INSERT, DELETE?
> > > > >
> > > > > --
> > > > > "They that would give up essential liberty for temporary safety
> > deserve
> > > > > neither liberty nor safety."
> > > > > -- Benjamin Franklin
> > > > >
> > > > >
> > > >
> > > > OH, what was I thinking, that is controled by the trigger.
> > > >
> > > > --
> > > > "They that would give up essential liberty for temporary safety deserve
> > > > neither liberty nor safety."
> > > > -- Benjamin Franklin
> > > >
> > >
> > > Hi,
> > >
> > > Still, you can access that information in the TG_OP variable available in
> > > trigger functions because you can define triggers firing on
> > > multiple operation types.
> > > For instance this is an example from the Postgres documentation:
> > >
> > > CREATE TRIGGER emp_audit
> > > INSTEAD OF INSERT OR UPDATE OR DELETE ON emp_view
> > > FOR EACH ROW EXECUTE FUNCTION update_emp_view();
> > >
> >
> > Thaks for the info.
> >
> > Could yoou clarify how to acces this variable:
> >
> > This does not work:
> >
> > elog( NOTICE, "For OP $_TD->{TG_OP}" )
> >
> > But this does work
> >
> > elog( NOTICE, "On Table $_TD->{table_name}" );
> > --
> > "They that would give up essential liberty for temporary safety deserve
> > neither liberty nor safety."
> > -- Benjamin Franklin
> >
>
> Hi,
>
> Sorry I didn't know you are using something different than plpgsql.
> You can check the actual syntax for your language(plperl I guess) here:
>
> https://www.postgresql.org/docs/11/server-programming.html
>
> Look for the "Trigger functions" section below the corresponding language.
>
Yes, it is not there, which explains why I did not see it.
I can execute an SQL queryy from within plperl, do you think that will get
this value?
--
"They that would give up essential liberty for temporary safety deserve
neither liberty nor safety."
-- Benjamin Franklin
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2020-03-08 21:13 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-03-08 14:29 Another INSTEAD OF TRIGGER question stan <stanb@panix.com>
2020-03-08 14:31 ` stan <stanb@panix.com>
2020-03-08 14:33 ` Rob Sargent <robjsargent@gmail.com>
2020-03-08 14:56 ` Sándor Daku <daku.sandor@gmail.com>
2020-03-08 21:13 ` stan <stanb@panix.com>
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