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 ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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 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----- |
| ||||
| Stef, > I am trying to write a function/Trigger in pl/perl (although any > other language which allows this is perfectly fine with me > 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 |