Re: Information about columns

From: John DeSoi <desoi(at)pgedit(dot)com>
To: Dario Teixeira <darioteixeira(at)yahoo(dot)com>
Cc: Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>, pgsql-general(at)postgresql(dot)org
Subject: Re: Information about columns
Date: 2009-06-22 22:14:11
Message-ID: 733356C8-5BE9-40A7-8781-3FFC12707095@pgedit.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Joshua D. Drake 2009-06-22 22:19:41 Re: Replication
Previous Message Mike Toews 2009-06-22 22:05:14 Re: Select ranges based on sequential breaks