From: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
To: David Jarvis <thangalin@gmail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Analysis Function
Date: Fri, 11 Jun 2010 12:42:34 +0300
Message-ID: <4C12050A.5060100@enterprisedb.com> (raw)
In-Reply-To: <AANLkTikjNlFDmQyZuUrDMtYhFe7sB7GOxS6t9eFibSpV@mail.gmail.com>
References: <AANLkTikihIMleazgqo1NhLo7LA5Tiujz4TIfBL1agxAp@mail.gmail.com>
<AANLkTikZKwBCR8QfGph3aH34A2dJ2NQyOjq-Pt3eZ3_z@mail.gmail.com>
<4C119B3E.3090608@squeakycode.net>
<AANLkTinjUmGWmB3jsjj-6w_44c0K7f_wSrH_1TALPaOY@mail.gmail.com>
<AANLkTikjNlFDmQyZuUrDMtYhFe7sB7GOxS6t9eFibSpV@mail.gmail.com>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: heikki.linnakangas@enterprisedb.com, thangalin@gmail.com
Subject: Re: Analysis Function
In-Reply-To: <4C12050A.5060100@enterprisedb.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox