SELECT table_type FROM table;

From: "A(dot)M(dot)" <agentm(at)themactionfaction(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: SELECT table_type FROM table;
Date: 2006-05-26 13:37:54
Message-ID: 56244.127.0.0.1.1148650674.squirrel@localhost
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

By accident, a colleague came across something unexpected. Here is a
simple example:

create table testo(gonk integer,spoodle text);
CREATE TABLE
agentm=# insert into testo values(1,'hello');
INSERT 0 1
agentm=# insert into testo values(2,'text');
INSERT 0 1
agentm=# select testo from testo;
testo
-----------
(1,hello)
(2,text)
(2 rows)

Obviously, this is intentional behavior but where is it documented? I am
aware that testo is also a type and that a set is returned for each row
but this must be a special case, no? Alternate types don't seem to apply.

agentm=# create type nice as (gonk integer,spoodle text);
CREATE TYPE
agentm=# select nice from testo;
ERROR: column "nice" does not exist
agentm=# select *::nice from testo;
ERROR: syntax error at or near "::" at character 9
LINE 1: select *::nice from testo;
^
agentm=# select cast(* as nice) from testo;
ERROR: syntax error at or near "*" at character 13
LINE 1: select cast(* as nice) from testo;
^
Also, how can I turn each set row into an array?

-M

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Florian G. Pflug 2006-05-26 13:44:12 Re: LDAP authentication
Previous Message Tom Lane 2006-05-26 13:25:04 Re: Incomplete dump?