Re: [HACKERS] proposal psql \gdesc - Mailing list pgsql-hackers

From Pavel Stehule
Subject Re: [HACKERS] proposal psql \gdesc
Date
Msg-id CAFj8pRDhb30d-Pi7-9oGs4Zs2_UeOYA2u77Ss2L4+KrfBDS7PQ@mail.gmail.com
Whole thread Raw
In response to [HACKERS] proposal psql \gdesc  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: [HACKERS] proposal psql \gdesc  (Fabien COELHO <coelho@cri.ensmp.fr>)
Re: [HACKERS] proposal psql \gdesc  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
List pgsql-hackers


2017-04-28 6:08 GMT+02:00 Pavel Stehule <pavel.stehule@gmail.com>:
Hi

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.

postgres=# select * from pg_proc \gdesc
┌─────────────────┬──────────────┐
│      Name       │     Type     │
╞═════════════════╪══════════════╡
│ proname         │ name         │
│ pronamespace    │ oid          │
│ proowner        │ oid          │
│ prolang         │ oid          │
│ procost         │ real         │
│ prorows         │ real         │
│ provariadic     │ oid          │
│ protransform    │ regproc      │
│ proisagg        │ boolean      │
│ proiswindow     │ boolean      │
│ prosecdef       │ boolean      │
│ proleakproof    │ boolean      │
│ proisstrict     │ boolean      │
│ proretset       │ boolean      │
│ provolatile     │ "char"       │
│ proparallel     │ "char"       │
│ pronargs        │ smallint     │
│ pronargdefaults │ smallint     │
│ prorettype      │ oid          │
│ proargtypes     │ oidvector    │
│ proallargtypes  │ oid[]        │
│ proargmodes     │ "char"[]     │
│ proargnames     │ text[]       │
│ proargdefaults  │ pg_node_tree │
│ protrftypes     │ oid[]        │
│ prosrc          │ text         │
│ probin          │ text         │
│ proconfig       │ text[]       │
│ proacl          │ aclitem[]    │
└─────────────────┴──────────────┘
(29 rows)

 
What do you think about this idea?

Regards

Pavel    

Attachment

pgsql-hackers by date:

Previous
From: Petr Jelinek
Date:
Subject: Re: [HACKERS] Time based lag tracking for logical replication
Next
From: Heikki Linnakangas
Date:
Subject: Re: [HACKERS] scram and \password