Re: how to amend SQL standard to add comments? - Mailing list pgsql-general

From Thomas Kellerer
Subject Re: how to amend SQL standard to add comments?
Date
Msg-id jo6dic$cg$1@dough.gmane.org
Whole thread Raw
In response to how to amend SQL standard to add comments?  (Aleksey Tsalolikhin <atsaloli.tech@gmail.com>)
Responses Re: how to amend SQL standard to add comments?
Re: how to amend SQL standard to add comments?
List pgsql-general
Aleksey Tsalolikhin wrote on 06.05.2012 19:24:
> Situation:  When a system administrator or database administrator looks at
> a gnarly SQL query chewing up system resources, there is no way to tell
> by looking at the query server-side which application it came from, what its
> purpose is, and who the author or responsible party is.
>
> Data: in ANSI SQL standard, you can put single-line comments by preceeding
> the line with a double-hyphen.  These comments will be thrown away by the
> database client and the server will never see them.  Hence the metadata
> (the data about the query itself) is lost.
>
> I propose it'd be a benefit, in today's day of distributed and inter-dependent
> systems, to pass that data along with the query so that it could be used
> in troubleshooting if needed.
>
> An SQL comment may look something like
>
> SELECT STUDENT_ID from STUDENTS
>    WHERE LAST_NAME = 'Smith' and FIRST_NAME = 'Joe'
>    COMMENT 'Query Author: Bob Programmer.   Purpose: Pull the student ID
>                        number, we'll need it to enroll the student for classes.';
>

You can use multi-line comments with /* .. */ to send this information to the server:

SELECT /* Query Author: Bob Programmer.
           Purpose: Pull the student ID number, we'll need it to enroll the student for classes */
      STUDENT_ID
from STUDENTS
WHERE LAST_NAME = 'Smith' and FIRST_NAME = 'Joe';

Regards
Thomas

pgsql-general by date:

Previous
From: Aleksey Tsalolikhin
Date:
Subject: how to amend SQL standard to add comments?
Next
From: Clemens Eisserer
Date:
Subject: Is there a tool for checking database integrity