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 -- Sent via pgsql-performance mailing list (pgsql-performance@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance