Re: proposal psql \gdesc

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: proposal psql \gdesc
Date: 2017-05-09 19:10:03
Message-ID: CAFj8pRDHs9DnoXEKOYdkGV2-YEPiq-wj7_Q+XJsZrTUQMgegWQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2017-05-09 20:37 GMT+02:00 Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>:

>
> Hello Pavel,
>
> [...] it is little bit worse. I cannot to distinguish between SELECT\gdesc
>> and TRUNCATE xxx\gdesc . All are valid commands and produce empty result,
>> so result of \gdesc command should be empty result too.
>>
>> postgres=# truncate table xx\gdesc
>> ┌──────┬──────┐
>> │ Name │ Type │
>> ╞══════╪══════╡
>> └──────┴──────┘
>> (0 rows)
>>
>
> Hmmm. At least it is better than the previous error.
>
> What about detecting the empty result (eg PQntuples()==0?) and writing
> "Empty result" instead of the strange looking empty table above? That would
> just mean skipping the PrintQueryResult call in this case?

PQntuples == 0 every time - the query is not executed.

I am not sure, what is more correct. The "Empty result" string is not used
every time in psql. For the case "SELECT;" the empty table is correct. For
TRUNCATE and similar command I am not sure. The empty table is maybe
unusual, but it is valid - like "SELECT;". The implementation is not
problem in any case. The question is what is more natural for users a) the
string "Empty result", b) empty table.

I prefer @b due consistency with current behave (that is only reason, I
have not any other).

postgres=# select 'ahoj' where false;
┌──────────┐
│ ?column? │
╞══════════╡
└──────────┘
(0 rows)

>
>
> --
> Fabien.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2017-05-09 19:15:41 Re: CTE inlining
Previous Message Petr Jelinek 2017-05-09 19:00:05 Re: snapbuild woes