Re: Comments with embedded single quotes - Mailing list pgsql-general

From Tom Lane
Subject Re: Comments with embedded single quotes
Date
Msg-id 18683.962247574@sss.pgh.pa.us
Whole thread Raw
In response to Comments with embedded single quotes  (Richard Harvey Chapman <hchapman@3gfp.com>)
Responses Re: Comments with embedded single quotes
List pgsql-general
Richard Harvey Chapman <hchapman@3gfp.com> writes:
> Are single quotation marks not allowed in comments?

> test2=# /* John's cat is fat. */
> test2'#
> test2'# '*/
> test2-# ;
> ERROR:  Unterminated quoted string
> test2=#

They are, but it looks like psql's primitive parser is confused here.
What the backend sees when this is sent is
    /* comment */

    '*/

and it quite properly complains that the string starting '*/ is not
terminated.  But it looks like psql mistakenly thinks that ' nests
inside /* ... */:

regression=# /*aaa
regression*# 'sss
regression'# ddd
regression'# */
regression'# 'sss
regression*# */
regression-#

Notice the pattern of the 'state' markers in the prompts.  It seems
to get the reverse case correct though:

regression-# 'foo
regression'# /*bar
regression'# '
regression-#

Over to you, Peter...

            regards, tom lane

pgsql-general by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Comments with embedded single quotes
Next
From: igor
Date:
Subject: test