Unix Technical Forum

Obtaining Firing Statement clause in (pl/perlu) Trigger Function

This is a discussion on Obtaining Firing Statement clause in (pl/perlu) Trigger Function within the pgsql Hackers forums, part of the PostgreSQL category; --> Hello Everyone, Apologies in advance, its time for another of my whacky 'can we do this' emails I am ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Hackers

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-11-2008, 04:02 AM
Stef
 
Posts: n/a
Default Obtaining Firing Statement clause in (pl/perlu) Trigger Function

Hello Everyone,
Apologies in advance, its time for another of my whacky 'can we do
this' emails

I am trying to write a function/Trigger in pl/perl (although any
other language which allows this is perfectly fine with me and I need to
find the firing statement. I understand that if the trigger was fired in
a long sequence, then of course, the calling statement will be the
previous trigger.

The scenario comes from that I am trying to setup a function which
queries a remote Sybase server. I have the functionality such that this
works;

select * from test_func('where userid=2313423');

It then returns a SETOF the table in question. However, the syntax
is, to put it politely, klunky (it smells of a kludge, which, it is .
Therefore, if I can get access to the where section of the calling
statement in the Trigger itself, i can have a syntax which reads as
follows;

select * from test_func() where userid=2324142;

The reason for needing the syntax inside the Trigger, is obviously
with large tables, grabbing all the tuples and then parsing them down
once obtained is, rather crazy. Some of the tables in question have at
least 3 million records. Flinging them all around only to get a few (or
most of the time one) seems rather crazy.

Do any of the pl/XXXX languages support getting at the calling
trigger statement ?
I am not adverse to trying to 'fix' pl/perl, however, if the trigger
never even gets passed this information in the first place, well, things are
going to start getting messy, and probably spiral outside of my control


Regards and Thanks
Stef

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQFCkgHCjI9jiT2RxJQRAuv+AJ4mtP4FFsvIdhQ5qPvvL7 0PJmpz3wCfQmBE
hipBfpTDfdWdBdfx7RtFSXg=
=jORc
-----END PGP SIGNATURE-----

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-11-2008, 04:02 AM
Josh Berkus
 
Posts: n/a
Default Re: Obtaining Firing Statement clause in (pl/perlu) Trigger Function

Stef,

> I am trying to write a function/Trigger in pl/perl (although any
> other language which allows this is perfectly fine with me and I need to
> find the firing statement. I understand that if the trigger was fired in
> a long sequence, then of course, the calling statement will be the
> previous trigger.


Talk to David Fetter (author of DBI-Link) about this. You're also probably
unnecessarily replicating his work.

It's not currently possible, unfortunately. Tge real way to do this would be
through RULES. However, RULEs currently don't give you a handle on query
substructures like where clauses (let alone join clauses). DF and I have
talked about it, but it would take some major back-end hacking to enable
it. :-(

--
Josh Berkus
Aglio Database Solutions
San Francisco

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 11:27 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com