Re: proposal psql \gdesc

Pavel Stehule <pavel.stehule@gmail.com>

From: Pavel Stehule <pavel.stehule@gmail.com>
To: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2017-05-03T06:56:12Z
Lists: pgsql-hackers

Attachments

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
>

Commits

  1. Add \gdesc psql command.