Re: Information about columns

From: Dario Teixeira <darioteixeira(at)yahoo(dot)com>
To: John DeSoi <desoi(at)pgedit(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 20:57:58
Message-ID: 254096.3441.qm@web111514.mail.gq1.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Hi,

> The information you want is always returned from the query
> as a row description message. This includes the type oid of
> real and computed columns.
>
> See the RowDescription message on this page for details:

Thanks for the reply. Note that is in fact RowDescription that PG'OCaml
is already using to obtain the type oid of real and computed columns.
The problem is that in some circumstances RowDescription does not provide
a pg_class OID where I (naïvely perhaps) expect it.

To be more precise, when issuing a SELECT for tables and views, the
associated pg_class OID is always provided. Doing a SELECT on 'foobar'
and 'foobar1' will work:

CREATE TABLE foobar (quant int);

CREATE VIEW foobar1 AS SELECT * FROM foobar;

*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?

Thanks again,
Dario Teixeira

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jorge Vidal - Disytel 2009-06-22 21:26:35 Compiling Pl/Java
Previous Message BlackMage 2009-06-22 19:24:17 Inserting Values into Interval