Re: SRF question

Lists: pgsql-general
From: Franco Bruno Borghesi <franco(at)akyasociados(dot)com(dot)ar>
To: pgsql-general(at)postgresql(dot)org
Subject: SRF question
Date: 2003-09-08 14:21:39
Message-ID: 1063030898.6309.1.camel@taz.oficina
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Hi everyone.

I need to create a C function that returns a row, and the type of this
row must be the same of a type that I've created using CREATE TYPE.

I've seen the function:
TupleDesc TypeGetTupleDesc(Oid typeoid, List *colaliases)
but I don't understand two things:

1)I just know the name of the type, not its oid... woud it be ok if I
execute a SELECT on pg_type asking for typname to find the oid of the
type I want to return? or is there any function like
RelationNameGetTupleDesc (maybe TypeNameGetTupleDesc) that I can call
passing just the typename as a char *?

2)in case TypeGetTupleDesc is the only option, what is the second
argument?

Thanks in advance.

PS: sorry if you receive this message twice, I sent it on saturday but
it seems it never arrived :)


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Franco Bruno Borghesi <franco(at)akyasociados(dot)com(dot)ar>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: SRF question
Date: 2003-09-08 15:02:40
Message-ID: 13509.1063033360@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Franco Bruno Borghesi <franco(at)akyasociados(dot)com(dot)ar> writes:
> 1)I just know the name of the type, not its oid... woud it be ok if I
> execute a SELECT on pg_type asking for typname to find the oid of the
> type I want to return? or is there any function like
> RelationNameGetTupleDesc (maybe TypeNameGetTupleDesc) that I can call
> passing just the typename as a char *?

A SELECT seems like the hard way. Look into parse_type.c for some
routines that might help. Offhand parseTypeString() is probably your
best bet.

> 2)in case TypeGetTupleDesc is the only option, what is the second
> argument?

I believe you can just set it to NIL, since you are only interested in
composite types.

regards, tom lane


From: Franco Bruno Borghesi <franco(at)akyasociados(dot)com(dot)ar>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: SRF question
Date: 2003-09-08 17:48:51
Message-ID: 1063043331.6897.7.camel@taz.oficina
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

yes, parseTypeString() seems to be the way.

I've found parseTypeString() in plpgsql.so... would it be ok to call
dlopen('plpgsql.so', ...) from my C code to access this function or is
there some other method I sould use?

thanks tom.

On Mon, 2003-09-08 at 12:02, Tom Lane wrote:

> Franco Bruno Borghesi <franco(at)akyasociados(dot)com(dot)ar> writes:
> > 1)I just know the name of the type, not its oid... woud it be ok if I
> > execute a SELECT on pg_type asking for typname to find the oid of the
> > type I want to return? or is there any function like
> > RelationNameGetTupleDesc (maybe TypeNameGetTupleDesc) that I can call
> > passing just the typename as a char *?
>
> A SELECT seems like the hard way. Look into parse_type.c for some
> routines that might help. Offhand parseTypeString() is probably your
> best bet.
>
> > 2)in case TypeGetTupleDesc is the only option, what is the second
> > argument?
>
> I believe you can just set it to NIL, since you are only interested in
> composite types.
>
> regards, tom lane
>


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Franco Bruno Borghesi <franco(at)akyasociados(dot)com(dot)ar>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: SRF question
Date: 2003-09-08 18:14:00
Message-ID: 23506.1063044840@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Franco Bruno Borghesi <franco(at)akyasociados(dot)com(dot)ar> writes:
> I've found parseTypeString() in plpgsql.so... would it be ok to call
> dlopen('plpgsql.so', ...) from my C code to access this function

Why would you need to do that!??! It's in the main executable.

regards, tom lane