Re: Information about columns - Mailing list pgsql-general

From John DeSoi
Subject Re: Information about columns
Date
Msg-id 733356C8-5BE9-40A7-8781-3FFC12707095@pgedit.com
Whole thread Raw
In response to Re: Information about columns  (Dario Teixeira <darioteixeira@yahoo.com>)
List pgsql-general
On Jun 22, 2009, at 4:57 PM, Dario Teixeira wrote:

> *However*, if I create a new type (which has an associated pg_class
> entry),
> and define a function which returns a SETOF that type,
> RowDescription will
> not tell me its OID.  For example:
>
> CREATE TYPE foobar_t AS (quant int);
>
> CREATE FUNCTION foobar2 () RETURNS SETOF foobar_t AS
> 'SELECT * FROM foobar' LANGUAGE sql STABLE;
>
> Is this a bug or a conscious decision?  And on the latter case, how
> can
> I retrieve the pg_class OID of foobar_t?

I don't think it is a bug because the documentation clearly states "if
the field can be identified as a column of a specific table, the
object ID of the table; otherwise zero." A type is not the same as a
table.

It is not as elegant as you would like, but maybe one idea is to
create your own alias of the built in type so you can determine the
answer just by looking at the column type. For example, instead of
using "int" in CREATE TYPE above, create a your own type equivalent to
an integer.



John DeSoi, Ph.D.





pgsql-general by date:

Previous
From: Mike Toews
Date:
Subject: Re: Select ranges based on sequential breaks
Next
From: "Joshua D. Drake"
Date:
Subject: Re: Replication