Re: Name column

From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Vlad Arkhipov <arhipov(at)dc(dot)baikal(dot)ru>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Name column
Date: 2010-09-24 10:35:35
Message-ID: 4C9C7EF7.2010107@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 24/09/10 13:02, Vlad Arkhipov wrote:
> I have just come across a weird thing. It works for any table and seems
> to be not documented.
>
> SELECT c.name FROM (VALUES(1, 'A', true)) c;
> SELECT c.name FROM pg_class c;
>
> And it does not work in these cases:
>
> SELECT name FROM (VALUES(1, 'A', true));
> SELECT name FROM pg_class;

For historical reasons PostgreSQL supports calling a function with a
single argument like "column.function", in addition to
"function(column)". There is a function "name(text)" that casts the
input to the 'name' datatype, so your example casts the row to text and
from text to name.

It is mentioned in the documentation at
http://www.postgresql.org/docs/8.4/interactive/xfunc-sql.html
Section "34.4.2. SQL Functions on Composite Types".

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

In response to

  • Name column at 2010-09-24 10:02:21 from Vlad Arkhipov

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2010-09-24 10:37:44 Re: Configuring synchronous replication
Previous Message Vlad Arkhipov 2010-09-24 10:02:21 Name column