Re: Analysis Function

Поиск
Список
Период
Сортировка
От Heikki Linnakangas
Тема Re: Analysis Function
Дата
Msg-id 4C12050A.5060100@enterprisedb.com
обсуждение исходный текст
Ответ на Re: Analysis Function  (David Jarvis <thangalin@gmail.com>)
Ответы Query about index usage  (Jayadevan M <Jayadevan.Maymala@ibsplc.com>)
Список pgsql-performance
On 11/06/10 11:25, David Jarvis wrote:
> Datum dateserial (PG_FUNCTION_ARGS) {
>    int32 p_year = PG_GETARG_INT32(0);
>    int32 p_month = PG_GETARG_INT32(1);
>    int32 p_day = PG_GETARG_INT32(2);
>
>    DateADT d = date2j (p_year, p_month, p_day) - POSTGRES_EPOCH_JDATE;
>    PG_RETURN_DATEADT(d);
> }
>
> Compiles without errors or warnings. The function is integrated as follows:
>
> CREATE OR REPLACE FUNCTION dateserial(integer, integer, integer)
>    RETURNS text AS
> 'ymd.so', 'dateserial'
>    LANGUAGE 'c' IMMUTABLE STRICT
>    COST 1;
>
> However, when I try to use it, the database segfaults:
>
> select dateserial( 2007, 1, 3 )
>
> Any ideas why?

The C function returns a DateADT, which is a typedef for int32, but the
CREATE FUNCTION statement claims that it returns 'text'.

--
   Heikki Linnakangas
   EnterpriseDB   http://www.enterprisedb.com

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

Предыдущее
От: David Jarvis
Дата:
Сообщение: Re: Analysis Function
Следующее
От: Jayadevan M
Дата:
Сообщение: Query about index usage