Re: proposal psql \gdesc
Pavel Stehule <pavel.stehule@gmail.com>
From: Pavel Stehule <pavel.stehule@gmail.com>
To: Fabien COELHO <coelho@cri.ensmp.fr>
Cc: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2017-05-15T19:25:35Z
Lists: pgsql-hackers
Attachments
- psql-gdesc-04.patch (text/x-patch) patch
2017-05-09 23:00 GMT+02:00 Fabien COELHO <coelho@cri.ensmp.fr>: > > 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 meant to test the query which collects type names, which is executed? > How it can help? > > Or check that PQnfields() == 0 on the PQdescribePrepared() result, so that > there is no need to execute the type name collection query? > > For the case "SELECT;" the empty table is correct. >> > > Ok. Then write "Empty table"? > > For TRUNCATE and similar command I am not sure. The empty table is maybe >> unusual, but it is valid - like "SELECT;". >> > > I would partly disagree: > > "SELECT;" does indeed return an empty relation, so I agree that an empty > table is valid whether spelled out as "Empty table" or explicitly. > > However, ISTM that "TRUNCATE stuff;" does *NOT* return a relation, so > maybe "No table" would be ok, but not an empty table... ?! > > So I could be okay with both: > > SELECT \gdesc > -- "Empty table" or some other string > Or > -- Name | Type > > Although I prefer the first one, because the second looks like a bug > somehow: I asked for a description, but nothing is described... even if the > answer is somehow valid, it looks pretty strange. > > The same results do not realy suit "TRUNCATE Foo \gdesc", where "No table" > would seem more appropriate? > > In both case, "Empty result" is kind of neutral, it does not promise a > table or not. Hmmm. At least not too much. Or maybe some other string such > as "Nothing" or "No result"? > > Now I wonder whether the No vs Empty cases can be distinguished? No with standard libpq API :( I am sending a variant with message instead empty result. Personally I prefer empty result instead message. It is hard to choose some good text of this message. Empty result is just empty result for all cases. Regards Pavel > > -- > Fabien. >
Commits
-
Add \gdesc psql command.
- 49ca462eb165 11.0 landed