pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedFw: C function for use from PLpgSQL trigger
3+ messages / 3 participants
[nested] [flat]
* Fw: C function for use from PLpgSQL trigger
@ 2001-02-04 08:04 Joe Conway <jconway2@home.com>
0 siblings, 0 replies; 3+ messages in thread
From: Joe Conway @ 2001-02-04 08:04 UTC (permalink / raw)
To: pgsql-sql
Hello all,
I posted this (see below) Friday to the interfaces list with no response.
Does anyone know if what I'm trying to do is possible, or should I just
write the entire thing in a C function trigger? The latter would be
unfortunate because I think it would be nice to be able to extend PLpgSQL
using C functions like this.
Anyway, any help or advice will be much appreciated!
Thanks,
Joe
> Hi,
>
> I'm trying to create a C function that I can call from within a PLpgSQL
> trigger function which will return a list of all the values in the NEW
> record formatted suitably for an insert statement. I can't come up with a
> way to do this directly from within PLpgSQL (i.e. iterate through an
> arbitrary number of NEW.attribute).
>
> Can anyone tell me how I can either pass the NEW record to the C function
> (this produces an error message 'NEW used in a non-rule query') or gain
> access to the trigger tuple from within my C function? It seems that
> although PLpgSQL is called as a trigger, the C function is called as a
> regular function (makes sense) and thus has no access to the trigger tuple
> (my problem).
>
> Any help or guidance is greatly appreciated!
>
> Thanks,
>
> Joe Conway
>
^ permalink raw reply [nested|flat] 3+ messages in thread
* RE: C function for use from PLpgSQL trigger
@ 2001-02-05 15:28 Michael Davis <mdavis@sevainc.com>
2001-02-05 18:42 ` Re: RE: C function for use from PLpgSQL trigger Joe Conway <joe.conway@mail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Michael Davis @ 2001-02-05 15:28 UTC (permalink / raw)
To: 'Joe Conway' <jconway2@home.com>; pgsql-sql
You could send the column name directly into your c function. For example:
c_function_name(NEW.col1, NEW.col2, NEW.col3). Otherwise I am not sure how
to send NEW into a C function. You could try declaring NEW in your C
function as a tuple.
-----Original Message-----
From: Joe Conway [SMTP:jconway2@home.com]
Sent: Sunday, February 04, 2001 1:04 AM
To: pgsql-sql@postgresql.org
Subject: Fw: C function for use from PLpgSQL trigger
Hello all,
I posted this (see below) Friday to the interfaces list with no response.
Does anyone know if what I'm trying to do is possible, or should I just
write the entire thing in a C function trigger? The latter would be
unfortunate because I think it would be nice to be able to extend PLpgSQL
using C functions like this.
Anyway, any help or advice will be much appreciated!
Thanks,
Joe
> Hi,
>
> I'm trying to create a C function that I can call from within a PLpgSQL
> trigger function which will return a list of all the values in the NEW
> record formatted suitably for an insert statement. I can't come up with a
> way to do this directly from within PLpgSQL (i.e. iterate through an
> arbitrary number of NEW.attribute).
>
> Can anyone tell me how I can either pass the NEW record to the C function
> (this produces an error message 'NEW used in a non-rule query') or gain
> access to the trigger tuple from within my C function? It seems that
> although PLpgSQL is called as a trigger, the C function is called as a
> regular function (makes sense) and thus has no access to the trigger
tuple
> (my problem).
>
> Any help or guidance is greatly appreciated!
>
> Thanks,
>
> Joe Conway
>
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: RE: C function for use from PLpgSQL trigger
2001-02-05 15:28 RE: C function for use from PLpgSQL trigger Michael Davis <mdavis@sevainc.com>
@ 2001-02-05 18:42 ` Joe Conway <joe.conway@mail.com>
0 siblings, 0 replies; 3+ messages in thread
From: Joe Conway @ 2001-02-05 18:42 UTC (permalink / raw)
To: mdavis@sevainc.com; pgsql-sql
> You could send the column name directly into your c function. For
example:
> c_function_name(NEW.col1, NEW.col2, NEW.col3). Otherwise I am not sure
how
> to send NEW into a C function. You could try declaring NEW in your C
> function as a tuple.
Thanks for your reply. I was hoping that I could avoid hardcoding NEW.col1,
etc, so that the function could be used for multiple relations. I've also
tried to declare the input parameter to the function as a tuple, but PLpgSQL
never gets that far -- it doesn't seem to support passing NEW as a
parameter.
Oh, well. I will probably just write all of my logic into a C function and
skip PLpgSQL entirely. That's too bad because it would be far simpler (and
preferrable IMHO) to write a generic trigger function in PLpgSQL and call C
functions for only certain operations that PLpgSQL does not directly
support.
Joe
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2001-02-05 18:42 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-02-04 08:04 Fw: C function for use from PLpgSQL trigger Joe Conway <jconway2@home.com>
2001-02-05 15:28 RE: C function for use from PLpgSQL trigger Michael Davis <mdavis@sevainc.com>
2001-02-05 18:42 ` Joe Conway <joe.conway@mail.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