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.


Será que alguém poderia me ajudar ???

Agradece antecipadamente pela atenção.

Anderson Aguilar Ferreira.





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

Responder a