Rounding/create C function question

Поиск
Список
Период
Сортировка
От Robert
Тема Rounding/create C function question
Дата
Msg-id 3903194D.3B00C0CA@robert.cz
обсуждение исходный текст
Ответы Re: Rounding/create C function question  (wieck@debis.com (Jan Wieck))
Список pgsql-general
Hi,

 I need some custom rounding function (say 1 or two decimal points),
what would be the simplest way to make one?

- Robert



P.S. I tried to create one in C like

    #include <string.h>
    #include "postgres.h"

    double tst5(double x) {
        return x; // ... whatever needed
    }

and compiled it with (on RadHat 6.1, PG 6.5.3)

    gcc -I/usr/include/pgsql -fPIC -shared
        -o libeucto.so.0.0.2 -Wl,-soname,libeucto.so.0.0.2 eucto_round.c

    CREATE FUNCTION tst5(float8) RETURNS float8
        AS '/mnt/lotrando_c/projekty/eucto/bin/libeucto.so.0.0.2' LANGUAGE
'c';

This works as long as the function is int4/int4, but for float8 'backend
terminated abnormally'. Thanks for any help.

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

Предыдущее
От: Juhan Ernits
Дата:
Сообщение: recreate system indexes in 6.5?
Следующее
От: Jesse Scott
Дата:
Сообщение: Upgrade question..