Thread: question on trigger

question on trigger

From
"rui zhong"
Date:
Hi,all:

This is my first time to use trigger. I try an example from programmer's
guide. Firstly I save the procedure named trigf.c, then i try to comlile it
by using SQL statement " create function trigf() returns opaque as
'...path_to_so' language 'c' ", then I got error message as " Load of file
/home/postgres/trigf.c failed: invalid ELF header ".  I don't know how to
fix this, please help me out. Lots of thanks.

The including H file in trigf.c is :


#include "executor/spi.h"  /*this is what you need to work with SPI */
#include "commands/trigger.h"   /*-"- and triggers */

extern Datum trigf(PG_FUNCTION_ARGS);

PG_FUNCTION_INFO_V1(trigf);

Datum
trigf(PG_FUNCTION_ARGS)
{ ... }




Rui






_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com

Re: question on trigger

From
GH
Date:
And you forwarded this to -jdbc because...?

On Sat, Jun 23, 2001 at 11:10:58PM -0000, some SMTP stream spewed forth:
> Hi,all:
> This is my first time to use trigger. I try an example from programmer's
> guide. Firstly I save the procedure named trigf.c, then i try to comlile it
> by using SQL statement " create function trigf() returns opaque as
> '...path_to_so' language 'c' ", then I got error message as " Load of file
> /home/postgres/trigf.c failed: invalid ELF header ".  I don't know how to
> fix this, please help me out. Lots of thanks.

As far as I know, you need to compile the function as a dynamic object:

from:
http://postgresql.crimelabs.net/users-lounge/docs/7.0/user/sql-createfunction.htm
obj_file , link_symbol

       This form of the AS clause is used for dynamically-linked, C
language functions when the function name in the C language source code
is not the
       same as the name of the SQL function. The string obj_file is the
name of the file containing the dynamically loadable object, and
link_symbol, is
       the object's link symbol which is the same as the name of the
function in the C language source code.

Where did you find this example?

gh


Re: question on trigger

From
"rui zhong"
Date:

>Where did you find this example?
>
>gh

Hi, gh:

  Thank you.
This example can be found  from following link.

http://www.ca.postgresql.org/devel-corner/docs/programmer/trigger-examples.html
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com


Re: question on trigger

From
Daniel Åkerud
Date:
Judging by the error message, I would say it looks for a compiled version of
your file.

Daniel Åkerud


>
> Hi,all:
>
> This is my first time to use trigger. I try an example from programmer's
> guide. Firstly I save the procedure named trigf.c, then i try to comlile
it
> by using SQL statement " create function trigf() returns opaque as
> '...path_to_so' language 'c' ", then I got error message as " Load of file
> /home/postgres/trigf.c failed: invalid ELF header ".  I don't know how to
> fix this, please help me out. Lots of thanks.
>
> The including H file in trigf.c is :
>
>
> #include "executor/spi.h"  /*this is what you need to work with SPI */
> #include "commands/trigger.h"   /*-"- and triggers */
>
> extern Datum trigf(PG_FUNCTION_ARGS);
>
> PG_FUNCTION_INFO_V1(trigf);
>
> Datum
> trigf(PG_FUNCTION_ARGS)
> { ... }
>
>
>
>
> Rui
>
>
>
>
>
>
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com
>


----------------------------------------------------------------------------
----


>


----------------------------------------------------------------------------
----


>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>