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

From Pavel Stehule
Subject Re: [HACKERS] proposal psql \gdesc
Date
Msg-id CAFj8pRDHs9DnoXEKOYdkGV2-YEPiq-wj7_Q+XJsZrTUQMgegWQ@mail.gmail.com
Whole thread Raw
In response to Re: [HACKERS] proposal psql \gdesc  (Fabien COELHO <coelho@cri.ensmp.fr>)
Responses Re: [HACKERS] proposal psql \gdesc  (Fabien COELHO <coelho@cri.ensmp.fr>)
List pgsql-hackers


2017-05-09 20:37 GMT+02:00 Fabien COELHO <coelho@cri.ensmp.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.

pgsql-hackers by date:

Previous
From: Petr Jelinek
Date:
Subject: Re: [HACKERS] snapbuild woes
Next
From: Peter Eisentraut
Date:
Subject: Re: [HACKERS] CTE inlining