Thread: question about sql comments

question about sql comments

From
Alan Stange
Date:
Hello all,

In order to track down some bugs, we thought it would be useful to
append some comments to the sql being sent to postgresql like this:     
    select foo from bar;  -- a comment with some metadata
however, the postgresql server was not including the appended comment in
the log file.

If we instead sent    
    select foo from /* a comment with some metadata */ bar;
then the comment was included in the server log file as we had hoped.

Simply put, an appended comment appears to be stripped from the sql
query by the jdbc code.

Is this something that can be turned off or disabled? I looked for
possible options in the documentation but didn't see anything.

Thank you,

Alan



Re: question about sql comments

From
Thomas Kellerer
Date:
Alan Stange schrieb am 06.08.2021 um 22:31:
> Hello all,
>
> In order to track down some bugs, we thought it would be useful to
> append some comments to the sql being sent to postgresql like this:
>      select foo from bar;  -- a comment with some metadata
> however, the postgresql server was not including the appended comment in
> the log file.

The ; ends the statement, so the comment you sent actually belongs to
the _next_ statement.

Did you try adding the single line comment before the statement?

     -- a comment
     select foo from bar;


Thomas