Re: trailing comment ghost-timing

From: David Johnston <polobo(at)yahoo(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: trailing comment ghost-timing
Date: 2013-12-24 02:17:51
Message-ID: 1387851471430-5784484.post@n5.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andreas Karlsson wrote
> On 12/24/2013 02:05 AM, Erik Rijkers wrote:
>> With \timing on, a trailing comment yields a timing.
>>
>> # test.sql
>> select 1;
>>
>> /*
>> select 2
>> */
>>
>> $ psql -f test.sql
>> ?column?
>> ----------
>> 1
>> (1 row)
>>
>> Time: 0.651 ms
>> Time: 0.089 ms
>>
>> I assume it is timing something about that comment (right?).
>>
>> Confusing and annoying, IMHO. Is there any chance such trailing
>> ghost-timings can be removed?
>
> This seems to be caused by psql sending the comment to the server to
> evaluate as a query. I personally think timing should always output
> something for every command sent to the server. To fix this problem I
> guess one would have to modify psql_scan() to check if a scanned query
> only contains comments and then not send it to the server at all.
>
> The minimal file to reproduce it is:
>
> /**/
>
> --
> Andreas Karlsson

I need to be convinced that the server should not just silently ignore
trailing comments. I'd consider an exception if the only text sent is a
comment ( in such a case we should throw an error ) but if valid commands
are sent and there is just some comment text at the end it should be ignored
the same as if the comments were embedded in the middle of the query text.

I've encountered other clients that output phantom results in this situation
and solving it at the server seems worthwhile so client applications do not
have to care.

In the example case, I think, putting the comment before the command results
in only one timing. This inconsistency is a symptom of this situation being
handled incorrectly.

David J.

--
View this message in context: http://postgresql.1045698.n5.nabble.com/trailing-comment-ghost-timing-tp5784473p5784484.html
Sent from the PostgreSQL - hackers mailing list archive at Nabble.com.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2013-12-24 02:33:04 Re: Planning time in explain/explain analyze
Previous Message Andreas Karlsson 2013-12-24 02:02:12 Re: PoC: Partial sort