Re: C function and enum types parameters

From: Edoardo Panfili <edoardo(at)aspix(dot)it>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: C function and enum types parameters
Date: 2008-03-24 15:01:24
Message-ID: 47E7C244.7010506@aspix.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Edoardo Panfili ha scritto:
> I use a C function in my database from 2002, all goes well also with
> postgresql 8.3 but with 8.3.1 it no longer works, the problem is with
> this line:
>
> text *hibrid = (PG_ARGISNULL( 0) ||
> VARSIZE(PG_GETARG_TEXT_P( 0))==VARHDRSZ ?NULL:PG_GETARG_TEXT_P(0));
>
> the argument number 0 is an enum defined by
>
> CREATE TYPE hibridationLevel AS ENUM('none','genus','specie');
>
> the error is "ERROR: invalid memory alloc request size 2298488997"
>
> I can't figure by now how to correct my error, can anyone help me?
>
I am still working on this after further investigation I can see that
the function is not correct also under postgres 8.3 (but it not raises
the error)

Is seems OK to retrieve the enum argument using
Oid oid = PG_GETARG_OID(0);
But using this way I can see only the Oid.

Can anyone confirm that this is the correct way to work with enum inside
a function?.

This is my little test case
-----------------------function--------------------------------
Datum prova1(PG_FUNCTION_ARGS){
Oid oid = PG_GETARG_OID(0);
ereport(WARNING, (errmsg_internal("(1) parametro1: %d", oid)));
}
-----------------------SQL definition--------------------------
CREATE FUNCTION prova1(hibridationLevel,text) RETURNS int
AS 'funzioniGDB2.so' LANGUAGE C WITH (iscachable);"
---------------------------------------------------------------

thank you
Edoardo
--
Jabber: edoardopa(at)talk(dot)google(dot)com
tel: 075 9142766

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alain Roger 2008-03-24 15:15:48 Re: date and time
Previous Message Raymond O'Donnell 2008-03-24 14:57:10 Re: date and time