Re: [HACKERS] proposal psql \gdesc

Поиск
Список
Период
Сортировка
От Pavel Stehule
Тема Re: [HACKERS] proposal psql \gdesc
Дата
Msg-id CAFj8pRDjXxnEyWdFP5Qx_qtrnvGtPn8rfPv4Q=JZQbnh2Y_xVA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [HACKERS] proposal psql \gdesc  (Fabien COELHO <coelho@cri.ensmp.fr>)
Ответы Re: [HACKERS] proposal psql \gdesc  (Fabien COELHO <coelho@cri.ensmp.fr>)
Список pgsql-hackers


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.

Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Kevin Grittner
Дата:
Сообщение: Re: [HACKERS] transition table behavior with inheritance appearsbroken (was: Declarative partitioning - another take)
Следующее
От: Robert Haas
Дата:
Сообщение: Re: [HACKERS] Hash Functions