Creating server-side functions: one simple error

Поиск
Список
Период
Сортировка
От Ruslan A Dautkhanov
Тема Creating server-side functions: one simple error
Дата
Msg-id 3DA4157A.1DA9078C@scn.ru
обсуждение исходный текст
Ответы Re: Creating server-side functions: one simple error
Список pgsql-bugs
Hi,

I have to create my own function in C lanuage, which
will use SPI. The problem that when I had done all things,
PostgreSQL says:
    isbs=# select pgf1test('123');
    ERROR:  Can't find function pgf1test in file /usr/local/pgsql/lib/pgf1test.so

I don't know where problems is. The program is very short, please
point me where my mistake?

pgf1test.c
----------
    #include "executor/spi.h"
    #include <ctype.h>

    Datum           pgf1test(PG_FUNCTION_ARGS);
    PG_FUNCTION_INFO_V1(pgf1test);

    Datum
    pgf1test(PG_FUNCTION_ARGS)
    {
    //      text  tnum = PG_GETARG_NAME(0);
            char *cnum = PG_GETARG_CSTRING(0);
            PG_RETURN_INT32( atoi(cnum) );
    }


compile.sh
----------
    #!/bin/sh

    NAME=pgf1test

    gcc -pipe -O2 -Wall -Wmissing-prototypes -Wmissing-declarations -fpic -DPIC \
        -I. -I/usr/home/rd/postgresql/src/include -c -o ${NAME}.o ${NAME}.c

    /usr/libexec/elf/ld -x -shared -o ${NAME}.so ${NAME}.o
    rm ${NAME}.o

pgf1test-createfunc.sql
-----------------------
    CREATE OR REPLACE FUNCTION pgf1test (text)
            RETURNS int4
            AS '$libdir/pgf1test'
            LANGUAGE 'C' WITH (isStrict);



    All that files worked well - I have created .so object and installed it
    into /usr/local/pgsql/lib/, after that I execute pgf1test-createfunc.sql -
    it's complete successfully, but
        isbs=# select pgf1test('123');
        ERROR:  Can't find function pgf1test in file /usr/local/pgsql/lib/pgf1test.so

show errors. Why PostgreSQL can't found C-function? I know that problem
is not complex, and it's very simple question for you. Thanks.

---
 best regards,
Ruslan A Dautkhanov

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Ruslan A Dautkhanov
Дата:
Сообщение: Postmaster crash!
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Creating server-side functions: one simple error