Faleu patrão, deu certo. Muito obrigado.....

----- Original Message ----- 
From: "Osvaldo Kussama" <[email protected]>
To: "Comunidade PostgreSQL Brasileira" <[email protected]>
Sent: Monday, May 04, 2009 4:34 PM
Subject: Re: [pgbr-geral]Criando função na linguagem C em postgresql


2009/5/4 Anderson <[email protected]>:
> Boa tarde a todos.
>
> Estou com um probleminha ao criar uma função no PostgreSQL que vincula com
> uma função feita em C.
>
> Esta função em C é apenas de teste e segue abaixo:
>
> Nome do arquivo "teste.c"
>
> #include "postgres.h"
>
> #include <string.h>
>
> #include "fmgr.h"
>
> PG_FUNCTION_INFO_V1(somar_um);
>
> Datum
>
> somar_um(PG_FUNCTION_ARGS){
>
> int32 arg = PG_GETARG_INT32(0);
>
> PG_RETURN_INT32(arg + 1);
>
> }
>
>
>
> Estou compilando da seguinte forma:
>
> # cc -fpic -c -I/root/postgresql-8.2.6/src/include/ teste.c
> # cc -shared -o teste.so teste.o
>
> Estou instalando o arquivo teste.so na biblioteca do postgresql:
>
> # install teste.so /usr/local/pgsql/lib/teste.so
>
> E na hora de criar a função no banco de dados, com o seguinte comando:
>
> CREATE FUNCTION replicacao.somar_um(integer) RETURNS integer
> AS 'teste', 'somar_um'
> LANGUAGE C;
>
> Está dando o seguinte erro:
>
> ERROR: incompatible library "/usr/local/pgsql/lib/teste.so": missing magic
> block
> SQL state: XX000
> Hint: Extension libraries are required to use the PG_MODULE_MAGIC macro.
>
>


Tente colocar:
#ifdef PG_MODULE_MAGIC
PG_MODULE_MAGIC;
#endif
no início de seu programa.

Osvaldo
_______________________________________________
pgbr-geral mailing list
[email protected]
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral 

_______________________________________________
pgbr-geral mailing list
[email protected]
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral

Responder a