Re: C-Language function invocation from another one.

Поиск
Список
Период
Сортировка
От Ilya Urikh
Тема Re: C-Language function invocation from another one.
Дата
Msg-id adf175f70905132356p2895160fg71d318593284b471@mail.gmail.com
обсуждение исходный текст
Ответ на Re: C-Language function invocation from another one.  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-novice
Thanks! That's help.

When I compile functions in the same library they work fine. But if I put one to another shared library function execution failed with error:
can't load library "/usr/lib/pgsql/calculateAccount.so": /usr/lib/pgsql/calculateAccount.so: undefined symbol: calculateAccountService

Details:
------------------------------------------------------
File calculateAccount.c is compiled to calculateAccount.so:

Datum calculateAccount(PG_FUNCTION_ARGS)
{
    ...
   DirectFunctionCall3(calculateAccountService, accountId, atoi(SPI_getvalue(tuple, tupdesc, 1)), startDate);

   PG_RETURN_NULL();
}

-----------------------------------------------------
File calculateAccountService.c is compiled to calculateAccountService.so:

Datum calculateAccountService(PG_FUNCTION_ARGS)
{
    ...

    PG_RETURN_VOID();
}

------------------------------------------
Define the functions to PostgreSQL

CREATE OR REPLACE FUNCTION calculateAccountService(integer, smallint, date)
    RETURNS void AS
    'calculateAccountService.so', 'calculateAccountService'
    LANGUAGE C STRICT;

CREATE OR REPLACE FUNCTION calculateAccount(integer, date, date)
    RETURNS void AS
    'calculateAccount.so', 'calculateAccount'
    LANGUAGE C STRICT;

----------------------------------------
Try to execute:
SELECT calculateAccount(2, '2008-02-23', '2009-04-13');

And receive Error message:
can't load library "/usr/lib/pgsql/calculateAccount.so": /usr/lib/pgsql/calculateAccount.so: undefined symbol: calculateAccountService


Thanks in advance,

Ilya Urikh.


On Thu, May 14, 2009 at 10:44 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Ilya Urikh <ilya.urikh@gmail.com> writes:
> What is the best way to call C-Language function from another one?

Try DirectFunctionCallN --- there are many examples in the source code.

                       regards, tom lane



--
Best regards,
Ilya Urikh.

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

Предыдущее
От: "A. Kretschmer"
Дата:
Сообщение: Re: update problem
Следующее
От: Mark
Дата:
Сообщение: 'Hot' backup of PostgreSQL dbases