Unix Technical Forum

C function and enum types parameters

This is a discussion on C function and enum types parameters within the Pgsql General forums, part of the PostgreSQL category; --> I use a C function in my database from 2002, all goes well also with postgresql 8.3 but with ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-10-2008, 12:22 AM
Edoardo Panfili
 
Posts: n/a
Default C function and enum types parameters

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?

thank you
edoardo
--
Jabber: edoardopa@talk.google.com
tel: 075 9142766

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-10-2008, 12:22 AM
Edoardo Panfili
 
Posts: n/a
Default Re: C function and enum types parameters

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@talk.google.com
tel: 075 9142766

-
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 11:27 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com