Re: Show type in psql SELECT

From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Mike Toews <mwtoews(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Show type in psql SELECT
Date: 2013-02-24 23:48:21
Message-ID: 512AA6C5.4000404@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 02/25/2013 07:14 AM, Peter Eisentraut wrote:
> On Sat, 2013-02-23 at 12:09 +1300, Mike Toews wrote:
>> Has anyone else thought this was a missing feature?
> I have.
As have I, repeatedly. This would be a nice convenience, though
pg_typeof can be used to achieve a similar effect a bit more clumsily.

However, the thing I want most couldn't be provided by this patch
because it seems to be a deeper server limitation: the ability to get
typmod data from calculation results like

NUMERIC(8,3) '11.131' + NUMERIC(8,3) '12.123'

The ability to get types for select results is already available, it's
just a bit clumsier:

select pg_typeof('134'), pg_typeof(1234);

It can't report typmods for calculation results. Can your proposed
change? See eg:

regress=> select pg_typeof(NUMERIC(8,3) '11.131'),
pg_typeof(NUMERIC(8,3) '12.123'), pg_typeof(NUMERIC(8,3) '11.131' +
NUMERIC(8,3) '12.123');
pg_typeof | pg_typeof | pg_typeof
-----------+-----------+-----------
numeric | numeric | numeric
(1 row)

--
Craig Ringer http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2013-02-25 00:09:53 Re: json generation enhancements
Previous Message Craig Ringer 2013-02-24 23:33:53 Re: json generation enhancements