Re: proposal psql \gdesc

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: proposal psql \gdesc
Date: 2017-05-09 19:33:32
Message-ID: CAFj8pRB6SAdDJwqU-COo7YeftupKPs9LHNvwO2DPTEM6uC4otw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2017-05-09 21:23 GMT+02:00 Peter Eisentraut <
peter(dot)eisentraut(at)2ndquadrant(dot)com>:

> On 5/3/17 02:56, Pavel Stehule wrote:
> > Sometimes I have to solve the result types of some query. It is
> > invisible in psql. You have to materialize table or you have to
> > create view. Now, when we can enhance \g command, we can introduce
> > query describing
> >
> > some like
> >
> > select a, b from foo
> > \gdesc
> >
> > | type | length | collation | ....
> > ------------------------------------------------
> > a | varchar | 30 |
> > b | numeric | 20 |
> >
> >
> > here is the patch. It is based on PQdescribePrepared result.
>
> I have often wished for functionality like this, so I'm in favor of
> investigating this.
>
> I don't think you need a separate call to prepare the query. You can
> get the result column types using PQftype(). (Hmm, you can get the
> typmod that way, but not the collation.)
>

the describe command is used and collation info is not available

looks to the attached patches

> My thinking in the past has been to put the column types either in the
> column headers, like "colname (coltype)", or in the footer, along with
> the actual query result.
>

My first idea was like classic gui implementation

colname1
type
==========
data

but the header is not multi line.

Merging with result is another way, but mostly you don't need this info. So
special command looks better.

>
> --
> Peter Eisentraut http://www.2ndQuadrant.com/
> PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2017-05-09 19:36:42 Re: CTE inlining
Previous Message Serge Rielau 2017-05-09 19:29:31 Re: CTE inlining