Re: getting domain information from query results

From: Karsten Hilbert <Karsten(dot)Hilbert(at)gmx(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: getting domain information from query results
Date: 2014-01-09 11:51:08
Message-ID: 20140109115108.GB4328@hermes.hilbert.loc
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Jan 09, 2014 at 12:10:34PM +0100, Marco Baringer wrote:

> assuming i have this schema:
>
> create domain almost_a_string AS text;
> create table object ( name_like_thing almost_a_string );
>
> and i'm trying to go from the results, using postgresql's
> frontend/backend protocol, of this query:
>
> select name_like_thing from object;
>
> to the domain of the column name_like_thing, almost_a_string.
>
> it seems, if my understanding of the protocol is correct, that the oid
> of the underlying type, text in this case, is returned and not the oid
> of the domain. i could get at the domain with an extra query, since the
> originating table/viem and column of each field in the result row is
> included, but i'd really rather have to make that extra query. is there
> something obvious that i'm missing?
>
> finally, i don't think i'm the first person to want to look at things
> this way; both psql's \d command and the function pg_typeof return
> almost_a_string (the domain) and not text (the type).

Maybe this

http://svana.org/~kleptog/pgsql/taggedtypes.html

gives some ideas.

Karsten
--
GPG key ID E4071346 @ gpg-keyserver.de
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Sameer Kumar 2014-01-09 14:06:34 Re: argument of CASE/WHEN must not return a set
Previous Message Marco Baringer 2014-01-09 11:10:34 getting domain information from query results