>> 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?
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?
--
Fabien.